Skip to content

Commit

Permalink
ci: fix conda cache
Browse files Browse the repository at this point in the history
  • Loading branch information
bonjourmauko committed Oct 2, 2024
1 parent 6fbaec0 commit bb7fbc4
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 41 deletions.
106 changes: 82 additions & 24 deletions .github/workflows/_before-conda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,108 @@ on:
required: true
type: string

defaults:
run:
shell: bash -l {0}

jobs:
build-conda:
deps-conda:
runs-on: ${{ inputs.os }}
name: build-conda-${{ inputs.os }}-py${{ inputs.python }}
name: deps-conda-${{ inputs.os }}-py${{ inputs.python }}
env:
# To colorize output of make tasks.
TERM: xterm-256color

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Cache conda env
uses: actions/cache@v4
with:
# Fetch all the tags
fetch-depth: 0
path: |
/usr/share/miniconda/envs/openfisca
.env.yaml
key: conda-env-${{ inputs.os }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}
restore-keys: conda-env-${{ inputs.os }}-py${{ inputs.python }}-

- name: Cache dependencies
id: restore-pkgs
- name: Cache conda deps
uses: actions/cache@v4
with:
path: ~/conda_pkgs_dir
key: pkgs-${{ inputs.os }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}
restore-keys: pkgs-${{ inputs.os }}-py${{ inputs.python }}-
key: conda-deps-${{ inputs.os }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}
restore-keys: conda-deps-${{ inputs.os }}-py${{ inputs.python }}-

- uses: conda-incubator/setup-miniconda@v2
- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: openfisca
auto-activate-base: false
auto-update-conda: true
python-version: ${{ inputs.python }}
# Add conda-forge for OpenFisca-Core
channels: conda-forge
activate-environment: true
python-version: ${{ inputs.python }}

- name: Display version
run: echo "version=`python setup.py --version`"
- name: Install dependencies
run: conda install --name openfisca conda-build anaconda-client

- name: Conda Config
run: |
conda install conda-build anaconda-client
conda info
- name: Export env
run: conda env export --name openfisca > .env.yaml

build-conda:
runs-on: ${{ inputs.os }}
needs: [deps-conda]
name: build-conda-${{ inputs.os }}-py${{ inputs.python }}
env:
# To colorize output of make tasks.
TERM: xterm-256color

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build Conda package
run: conda build --croot /tmp/conda .conda
- name: Cache conda env
uses: actions/cache@v4
with:
path: |
/usr/share/miniconda/envs/openfisca
.env.yaml
key: conda-env-${{ inputs.os }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}

- name: Upload Conda build
uses: actions/upload-artifact@v3
- name: Cache conda deps
uses: actions/cache@v4
with:
name: conda-build-`python setup.py --version`-${{ github.sha }}
path: /tmp/conda
path: ~/conda_pkgs_dir
key: conda-deps-${{ inputs.os }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}

- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: openfisca
environment-file: .env.yaml

- name: Cache build
uses: actions/cache@v4
with:
path: |
/usr/share/miniconda/envs/openfisca
/tmp/conda
~/conda_pkgs_dir
.env.yaml
key: conda-build-${{ inputs.os }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }}
restore-keys: |
conda-build-${{ inputs.os }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}-
conda-build-${{ inputs.os }}-py${{ inputs.python }}-
- name: Cache release
uses: actions/cache@v4
with:
path: ~/openfisca
key: conda-release-${{ inputs.os }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }}

- name: Build conda package
run: |
mkdir -p ~/openfisca
conda build --use-local --croot /tmp/conda --output ~/openfisca .conda
- name: Export env
run: conda env export --name openfisca > .env.yaml
16 changes: 5 additions & 11 deletions .github/workflows/_before.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,11 @@ jobs:
run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"

- name: Cache dependencies
id: restore-deps
uses: actions/cache@v4
with:
path: venv
key: deps-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{
hashFiles('setup.py') }}
restore-keys: deps-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python
}}-
key: deps-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}
restore-keys: deps-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-

- name: Install dependencies
run: |
Expand Down Expand Up @@ -83,15 +80,13 @@ jobs:
uses: actions/cache@v4
with:
path: venv
key: deps-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{
hashFiles('setup.py') }}
key: deps-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}

- name: Cache build
uses: actions/cache@v4
with:
path: venv/**/[Oo]pen[Ff]isca*
key: build-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{
hashFiles('setup.py') }}-${{ github.sha }}
key: build-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }}
restore-keys: |
build-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}-
build-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-
Expand All @@ -100,8 +95,7 @@ jobs:
uses: actions/cache@v4
with:
path: dist
key: release-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{
hashFiles('setup.py') }}-${{ github.sha }}
key: release-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }}

- name: Build package
run: |
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/_lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ jobs:
uses: actions/cache@v4
with:
path: venv
key: deps-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{
hashFiles('setup.py') }}
key: deps-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}

- name: Lint doc
run: |
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,13 @@ jobs:
uses: actions/cache@v4
with:
path: venv
key: deps-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{
hashFiles('setup.py') }}
key: deps-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}

- name: Cache build
uses: actions/cache@v4
with:
path: venv/**/[Oo]pen[Ff]isca*
key: build-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{
hashFiles('setup.py') }}-${{ github.sha }}
key: build-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }}

- name: Run Openfisca Core tests
run: |
Expand Down

0 comments on commit bb7fbc4

Please sign in to comment.