@@ -13,14 +13,16 @@ jobs:
1313 tests_and_docker_build :
1414 name : ' Run unit tests and build docker image'
1515 runs-on : ' ubuntu-20.04'
16+ env :
17+ latest : ${{ matrix.python_version == '3.11' && 'true' || '' }}
1618 strategy :
1719 matrix :
18- version :
19- - {'python': ' 3.7', 'latest': false}
20- - {'python': ' 3.8', 'latest': false}
21- - {'python': ' 3.9', 'latest': false}
22- - {'python': ' 3.10', 'latest': false}
23- - {'python': ' 3.11', 'latest': true}
20+ python_version :
21+ - ' 3.7'
22+ - ' 3.8'
23+ - ' 3.9'
24+ - ' 3.10'
25+ - ' 3.11'
2426 steps :
2527 - name : ' Checkout repository'
2628 uses : actions/checkout@v4
3234 uses : actions/cache@v3
3335 with :
3436 path : /tmp/.buildx-cache
35- key : ${{ runner.os }}-buildx-python${{ matrix.version.python }}-${{ github.sha }}
37+ key : ${{ runner.os }}-buildx-python${{ matrix.python_version }}-${{ github.sha }}
3638 restore-keys : |
37- ${{ runner.os }}-buildx-python${{ matrix.version.python }}-
39+ ${{ runner.os }}-buildx-python${{ matrix.python_version }}-
3840
3941 - name : Login to DockerHub
4042 uses : docker/login-action@v3
@@ -55,19 +57,19 @@ jobs:
5557 -e "GITHUB_REPOSITORY=$GITHUB_REPOSITORY"
5658 -e "GITHUB_RUN_ID=$GITHUB_RUN_ID"
5759 -e "GITHUB_TOKEN=$GITHUB_TOKEN"
58- "${BASE_IMAGE_NAME}:${BASE_IMAGE_TAG}-python${{ matrix.version.python }}"
60+ "${BASE_IMAGE_NAME}:${BASE_IMAGE_TAG}-python${{ matrix.python_version }}"
5961 bash -c "
6062 python setup.py sdist &&
6163 coverage run --omit=nansat/mappers/*,nansat/tests/*,nansat/nansatmap.py --source=nansat setup.py test"
6264
6365 - name : ' Install Python 3.11'
64- if : ${{ matrix.version .latest }}
66+ if : ${{ env .latest }}
6567 uses : actions/setup-python@v4
6668 with :
6769 python-version : ' 3.11'
6870
6971 - name : ' Upload coverage to coveralls.io'
70- if : ${{ matrix.version .latest }}
72+ if : ${{ env .latest }}
7173 env :
7274 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
7375 run : pip install coveralls && coveralls --service=github
@@ -77,14 +79,14 @@ jobs:
7779 with :
7880 context : .
7981 build-args : |
80- BASE_IMAGE=${{ env.BASE_IMAGE_NAME }}:${{ env.BASE_IMAGE_TAG }}-python${{ matrix.version.python }}
82+ BASE_IMAGE=${{ env.BASE_IMAGE_NAME }}:${{ env.BASE_IMAGE_TAG }}-python${{ matrix.python_version }}
8183 NANSAT_RELEASE=${{ github.ref_type == 'tag' && github.ref_name || '0.0.0' }}
8284 push : ${{ github.ref_type == 'tag' }}
8385 tags : |
84- ${{ env.IMAGE_NAME }}:${{ github.ref_name }}-python${{ matrix.version.python }}
85- ${{ matrix.version .latest && format('{0}:{1}', env.IMAGE_NAME, github.ref_name) || '' }}
86- ${{ env.IMAGE_NAME }}:latest-python${{ matrix.version.python }}
87- ${{ matrix.version .latest && format('{0}:latest', env.IMAGE_NAME) || '' }}
86+ ${{ env.IMAGE_NAME }}:${{ github.ref_name }}-python${{ matrix.python_version }}
87+ ${{ env .latest && format('{0}:{1}', env.IMAGE_NAME, github.ref_name) || '' }}
88+ ${{ env.IMAGE_NAME }}:latest-python${{ matrix.python_version }}
89+ ${{ env .latest && format('{0}:latest', env.IMAGE_NAME) || '' }}
8890 cache-from : type=local,src=/tmp/.buildx-cache
8991 cache-to : type=local,dest=/tmp/.buildx-cache-new
9092
0 commit comments