11# =============================================================================
2- # Unit Tests on Go v1.15, 16, 17 and latest
2+ # Unit Tests on Go v1.16, 17 and latest
33# =============================================================================
44# This Workflow runs unit tests on various Go versions over Docker on any push.
5- # This action caches the built Docker image for a day unless any change in the
6- # Dockerfile was made.
7- name : Go 1.15~latest
5+ #
6+ # This action caches the built Docker image for a day unless any change was made
7+ # in the go.mod or Dockerfile.
8+ #
9+ # Due to the use of "embed" module, the Go 1.15 check is deprecated.
10+ name : Go 1.16~latest
811
912on :
1013 workflow_dispatch :
@@ -25,13 +28,14 @@ jobs:
2528 id : imagetag
2629 run : |
2730 HASH_IMAGE=${{ hashFiles('./.github/Dockerfile') }}
31+ HASH_MOD=${{ hashFiles('./go.mod') }}
2832 VARIANT=$(TZ=UTC-9 date '+%Y%m%d')
29- TAG="${HASH_IMAGE:0:7}:${VARIANT}"
30- PATH_TAR=${{ env.PATH_CACHE }}" /tar"
33+ TAG="${HASH_IMAGE:0:7}${HASH_MOD:0:7} :${VARIANT}"
34+ PATH_TAR=" ${{ env.PATH_CACHE }}/tar"
3135 echo "::set-output name=TAG::${TAG}"
3236 echo "::set-output name=PATH_TAR::${PATH_TAR}"
3337
34- - name : Cache or restore image archive
38+ - name : Enable Cache to save/ restore image archive
3539 id : cache
3640 uses : actions/cache@v2
3741 with :
4145 - name : Load Docker images if exist
4246 if : steps.cache.outputs.cache-hit == 'true'
4347 run : |
44- docker load --input ${{ steps.imagetag.outputs.PATH_TAR }}/github_v1_15_1.tar
4548 docker load --input ${{ steps.imagetag.outputs.PATH_TAR }}/github_v1_16_1.tar
4649 docker load --input ${{ steps.imagetag.outputs.PATH_TAR }}/github_v1_17_1.tar
4750 docker load --input ${{ steps.imagetag.outputs.PATH_TAR }}/github_latest_1.tar
5154 if : steps.cache.outputs.cache-hit != 'true'
5255 run : |
5356 : # Pull images one-by-one for stability
54- docker pull golang:1.15-alpine
5557 docker pull golang:1.16-alpine
5658 docker pull golang:1.17-alpine
5759 docker pull golang:alpine
@@ -67,14 +69,11 @@ jobs:
6769 - name : Save built images if no-exists
6870 if : steps.cache.outputs.cache-hit != 'true'
6971 run : |
70- docker save --output ${{ steps.imagetag.outputs.PATH_TAR }}/github_v1_15_1.tar github_v1_15:latest
7172 docker save --output ${{ steps.imagetag.outputs.PATH_TAR }}/github_v1_16_1.tar github_v1_16:latest
7273 docker save --output ${{ steps.imagetag.outputs.PATH_TAR }}/github_v1_17_1.tar github_v1_17:latest
7374 docker save --output ${{ steps.imagetag.outputs.PATH_TAR }}/github_latest_1.tar github_latest:latest
7475 docker save --output ${{ steps.imagetag.outputs.PATH_TAR }}/github_mergeability_1.tar github_mergeability:latest
7576
76- - name : Run tests on Go 1.15
77- run : docker-compose --file ./.github/docker-compose.yml up --abort-on-container-exit v1_15
7877 - name : Run tests on Go 1.16
7978 run : docker-compose --file ./.github/docker-compose.yml up --abort-on-container-exit v1_16
8079 - name : Run tests on Go 1.17
0 commit comments