From 78f796ad3c5c9398184f0e0f45b57e771d9d2c02 Mon Sep 17 00:00:00 2001 From: lbdreyer Date: Wed, 9 Feb 2022 09:36:20 +0000 Subject: [PATCH 1/2] Add dynamic matrix to refresh lockfile job --- .github/workflows/refresh-lockfiles.yml | 26 +++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/refresh-lockfiles.yml b/.github/workflows/refresh-lockfiles.yml index 614bd7bb65..9ed5363785 100644 --- a/.github/workflows/refresh-lockfiles.yml +++ b/.github/workflows/refresh-lockfiles.yml @@ -23,19 +23,29 @@ on: jobs: + get_python_matrix: + # Determines which Python versions should be included in the matrix used in + # the gen_lockfiles job. + if: "github.repository == 'SciTools/iris'" + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.get_py.outputs.matrix }} + steps: + - uses: actions/checkout@v2 + - id: get_py + run: echo "::set-output name=matrix::$(ls -1 requirements/ci/py??.yml | xargs -n1 basename | cut -c-4 | jq -cnR '[inputs | select(length>0)]')" + gen_lockfiles: # this is a matrix job: it splits to create new lockfiles for each # of the CI test python versions. - # this list below should be changed when covering more python versions - # TODO: generate this matrix automatically from the list of available py**.yml files - # ref: https://tomasvotruba.com/blog/2020/11/16/how-to-make-dynamic-matrix-in-github-actions/ if: "github.repository == 'SciTools/iris'" runs-on: ubuntu-latest + needs: get_python_matrix strategy: matrix: - python: ['38'] - + python: ${{ fromJSON(needs.get_python_matrix.outputs.matrix) }} + steps: - uses: actions/checkout@v3 - name: install conda-lock @@ -44,12 +54,12 @@ jobs: conda install -y -c conda-forge conda-lock - name: generate lockfile run: | - $CONDA/bin/conda-lock lock -p linux-64 -f requirements/ci/py${{matrix.python}}.yml - mv conda-linux-64.lock py${{matrix.python}}-linux-64.lock + $CONDA/bin/conda-lock lock -p linux-64 -f requirements/ci/${{matrix.python}}.yml + mv conda-linux-64.lock ${{matrix.python}}-linux-64.lock - name: output lockfile uses: actions/upload-artifact@v2 with: - path: py${{matrix.python}}-linux-64.lock + path: ${{matrix.python}}-linux-64.lock create_pr: # once the matrix job has completed all the lock files will have been uploaded as artifacts. From 7b946487863163095b0bc61231ddbebce7db5d5e Mon Sep 17 00:00:00 2001 From: lbdreyer Date: Tue, 8 Mar 2022 15:50:29 +0000 Subject: [PATCH 2/2] review actions --- .github/workflows/refresh-lockfiles.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/refresh-lockfiles.yml b/.github/workflows/refresh-lockfiles.yml index 9ed5363785..a2644280a0 100644 --- a/.github/workflows/refresh-lockfiles.yml +++ b/.github/workflows/refresh-lockfiles.yml @@ -31,9 +31,9 @@ jobs: outputs: matrix: ${{ steps.get_py.outputs.matrix }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - id: get_py - run: echo "::set-output name=matrix::$(ls -1 requirements/ci/py??.yml | xargs -n1 basename | cut -c-4 | jq -cnR '[inputs | select(length>0)]')" + run: echo "::set-output name=matrix::$(ls -1 requirements/ci/py??.yml | xargs -n1 basename | sed 's/....$//' | jq -cnR '[inputs]')" gen_lockfiles: # this is a matrix job: it splits to create new lockfiles for each