|
| 1 | +name: Setup conda |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + os: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + |
| 10 | + numpy: |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + |
| 14 | + python: |
| 15 | + required: true |
| 16 | + type: string |
| 17 | + |
| 18 | +defaults: |
| 19 | + run: |
| 20 | + shell: bash -l {0} |
| 21 | + |
| 22 | +jobs: |
| 23 | + setup: |
| 24 | + runs-on: ${{ inputs.os }} |
| 25 | + name: conda-setup-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }} |
| 26 | + env: |
| 27 | + # To colorize output of make tasks. |
| 28 | + TERM: xterm-256color |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout |
| 32 | + uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Cache conda env |
| 35 | + uses: actions/cache@v4 |
| 36 | + with: |
| 37 | + path: | |
| 38 | + /usr/share/miniconda/envs/openfisca |
| 39 | + ~/.conda/envs/openfisca |
| 40 | + .env.yaml |
| 41 | + key: conda-env-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }} |
| 42 | + restore-keys: conda-env-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}- |
| 43 | + id: cache-env |
| 44 | + |
| 45 | + - name: Cache conda deps |
| 46 | + uses: actions/cache@v4 |
| 47 | + with: |
| 48 | + path: ~/conda_pkgs_dir |
| 49 | + key: conda-deps-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }} |
| 50 | + restore-keys: conda-deps-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}- |
| 51 | + id: cache-deps |
| 52 | + |
| 53 | + - name: Cache release |
| 54 | + uses: actions/cache@v4 |
| 55 | + with: |
| 56 | + path: ~/conda-rel |
| 57 | + key: conda-release-${{ inputs.os }}-np${{ inputs.numpy }}-py${{ inputs.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }} |
| 58 | + |
| 59 | + - name: Setup conda |
| 60 | + uses: conda-incubator/setup-miniconda@v3 |
| 61 | + with: |
| 62 | + activate-environment: openfisca |
| 63 | + miniforge-version: latest |
| 64 | + python-version: ${{ inputs.python }} |
| 65 | + use-mamba: true |
| 66 | + if: steps.cache-env.outputs.cache-hit != 'true' |
| 67 | + |
| 68 | + - name: Install dependencies |
| 69 | + run: mamba install boa rattler-build anaconda-client |
| 70 | + if: steps.cache-env.outputs.cache-hit != 'true' |
| 71 | + |
| 72 | + - name: Update conda & dependencies |
| 73 | + uses: conda-incubator/setup-miniconda@v3 |
| 74 | + with: |
| 75 | + activate-environment: openfisca |
| 76 | + environment-file: .env.yaml |
| 77 | + miniforge-version: latest |
| 78 | + use-mamba: true |
| 79 | + if: steps.cache-env.outputs.cache-hit == 'true' |
| 80 | + |
| 81 | + - name: Build pylint plugin package |
| 82 | + run: | |
| 83 | + rattler-build build \ |
| 84 | + --recipe .conda/pylint-per-file-ignores \ |
| 85 | + --output-dir ~/conda-rel |
| 86 | +
|
| 87 | + - name: Build core package |
| 88 | + run: | |
| 89 | + conda mambabuild .conda/openfisca-core \ |
| 90 | + --use-local \ |
| 91 | + --no-anaconda-upload \ |
| 92 | + --output-folder ~/conda-rel \ |
| 93 | + --numpy ${{ inputs.numpy }} \ |
| 94 | + --python ${{ inputs.python }} |
| 95 | +
|
| 96 | + - name: Build country template package |
| 97 | + run: | |
| 98 | + rattler-build build \ |
| 99 | + --recipe .conda/openfisca-country-template \ |
| 100 | + --output-dir ~/conda-rel \ |
| 101 | +
|
| 102 | + - name: Build extension template package |
| 103 | + run: | |
| 104 | + rattler-build build \ |
| 105 | + --recipe .conda/openfisca-extension-template \ |
| 106 | + --output-dir ~/conda-rel |
| 107 | +
|
| 108 | + - name: Export env |
| 109 | + run: mamba env export --name openfisca > .env.yaml |
0 commit comments