Skip to content

Commit

Permalink
chore: bump-up versions of actions (PR #44)
Browse files Browse the repository at this point in the history
fix #42
fix #45 

* refactor: use file hash action for file hash
* refactor: coverage tests to use file cache action
* fix: bump-up actions/cache@v2 --> v3
* fix: bump-up actions/checkout@v2 --> v3
* fix: bump-up actions/setup-go@v2 --> v3
* fix: bump-up goreleaser/goreleaser-action@v2 --> v3
* fix: cache conflict
  • Loading branch information
KEINOS authored Nov 7, 2022
1 parent acb8bfd commit 9b0e6cd
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 65 deletions.
22 changes: 17 additions & 5 deletions .github/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# =============================================================================
# Docker Compose file for testing on Go versions 1.14~1.17 and latest.
# Docker Compose file for testing on Go versions 1.14~1.17 and latest.
# =============================================================================
# It is recommended to run specifying a specific Go version and not at once.
# This file is somewhat similar to makefile, but for Docker.
#
# Since the service `tidy` will update/re-write the "go.mod" file to the latest
# version, during it's process the "go.mod" file will be gone temporarily. Thus,
# it will cause failure in the other containers becaue of missing "go.mod" file.
# Notes:
# It is recommended to run specifying a specific service and not at once.
#
# Since the service `tidy` will update/re-write the "go.mod" file to the latest
# version, during it's process the "go.mod" file will be gone temporarily. Thus,
# it will cause failure in the other containers becaue of missing "go.mod" file.
#
# Recommended usage:
# docker-compose --file ./.github/docker-compose.yml up tidy && \
Expand Down Expand Up @@ -63,6 +66,15 @@ services:
VARIANT: 1.17-alpine
volumes:
- ..:/workspaces
# Service v1_18 runs the tests on Go v1.18.
v1_18:
build:
context: ..
dockerfile: ./.github/Dockerfile
args:
VARIANT: 1.18-alpine
volumes:
- ..:/workspaces
# Service latest runs the tests on latest Go docker image.
latest:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeQL-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
34 changes: 18 additions & 16 deletions .github/workflows/coverage-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,30 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Create image tag
id: imagetag
run: |
HASH_IMAGE=${{ hashFiles('./.github/Dockerfile') }}
VARIANT=$(TZ=UTC-9 date '+%Y%m')
TAG="${HASH_IMAGE:0:7}:${VARIANT}"
PATH_TAR=${{ env.PATH_CACHE }}"/tar"
echo "::set-output name=TAG::${TAG}"
echo "::set-output name=PATH_TAR::${PATH_TAR}"
- name: Create cache ID from file hash
uses: KEINOS/gh-action-hash-for-cache@main
id: cacheid
# Udate the hash if Dockerfile/go.mod is changed or the month has changed.
with:
path: |
./go.mod
./.github/Dockerfile
./.github/docker-compose.yml
variant: $(TZ=UTC-9 date '+%Y%m')

- name: Cache or restore image archive
id: cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ env.PATH_CACHE }}
key: ${{ steps.imagetag.outputs.TAG }}
key: ${{ steps.cacheid.outputs.hash }}

- name: Load Docker images if exist
if: steps.cache.outputs.cache-hit == 'true'
run: |
docker load --input ${{ steps.imagetag.outputs.PATH_TAR }}/github_coverage_1.tar
docker load --input ${{ env.PATH_CACHE }}/github_coverage_1.tar
- name: Pull base images if no-exist
if: steps.cache.outputs.cache-hit != 'true'
Expand All @@ -50,14 +51,15 @@ jobs:
- name: Build Docker images if no-exists
if: steps.cache.outputs.cache-hit != 'true'
run: |
mkdir -p ${{ steps.imagetag.outputs.PATH_TAR }}
: # Build container images
docker-compose --file ./.github/docker-compose.yml build coverage
- name: Save built images if no-exists
if: steps.cache.outputs.cache-hit != 'true'
run: |
docker save --output ${{ steps.imagetag.outputs.PATH_TAR }}/github_coverage_1.tar github_coverage:latest
: # Ensure the directory exists
mkdir -p ${{ env.PATH_CACHE }}
: # Save container images
docker save --output ${{ env.PATH_CACHE }}/github_coverage_1.tar github_coverage:latest
- name: Run code coverage
run: docker-compose --file ./.github/docker-compose.yml run coverage
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --config ./.golangci.yml
6 changes: 3 additions & 3 deletions .github/workflows/platform-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ jobs:
runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: '^1.17'

- name: Use Cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/release_bin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Run tests
run: docker-compose --file ./.github/docker-compose.yml up mergeability
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: '1.17.x'
go-version: '1.19'
check-latest: true
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --config .goreleaser.yml
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/update-codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: '1.15'
go-version: '1.17'
check-latest: true
- name: Run coverage
run: go test -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage to Codecov
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-mod-monthly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Check current install functionality
run: |
Expand Down
64 changes: 34 additions & 30 deletions .github/workflows/version-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Unit Tests on Go v1.15, 16, 17 and latest
# =============================================================================
# This Workflow runs unit tests on various Go versions over Docker on any push.
# This action caches the built Docker image for a day unless any change in the
# Dockerfile was made.
# This action caches the built Docker image for a month unless any changes in
# the Dockerfile or go.mod were made.
name: Go 1.15~latest

on:
Expand All @@ -19,66 +19,70 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Create image tag
id: imagetag
run: |
HASH_IMAGE=${{ hashFiles('./.github/Dockerfile') }}
VARIANT=$(TZ=UTC-9 date '+%Y%m%d')
TAG="${HASH_IMAGE:0:7}:${VARIANT}"
PATH_TAR=${{ env.PATH_CACHE }}"/tar"
echo "::set-output name=TAG::${TAG}"
echo "::set-output name=PATH_TAR::${PATH_TAR}"
- name: Create cache ID from file hash
uses: KEINOS/gh-action-hash-for-cache@main
id: cacheid
# Udate the hash if Dockerfile/go.mod is changed or the month has changed.
with:
path: |
./go.mod
./.github/Dockerfile
./.github/docker-compose.yml
variant: $(TZ=UTC-9 date '+%Y%m')

- name: Cache or restore image archive
id: cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ env.PATH_CACHE }}
key: ${{ steps.imagetag.outputs.TAG }}
key: ${{ steps.cacheid.outputs.hash }}

- name: Load Docker images if exist
if: steps.cache.outputs.cache-hit == 'true'
run: |
docker load --input ${{ steps.imagetag.outputs.PATH_TAR }}/github_v1_15_1.tar
docker load --input ${{ steps.imagetag.outputs.PATH_TAR }}/github_v1_16_1.tar
docker load --input ${{ steps.imagetag.outputs.PATH_TAR }}/github_v1_17_1.tar
docker load --input ${{ steps.imagetag.outputs.PATH_TAR }}/github_latest_1.tar
docker load --input ${{ steps.imagetag.outputs.PATH_TAR }}/github_mergeability_1.tar
docker load --input ${{ env.PATH_CACHE }}/github_v1_15_1.tar
docker load --input ${{ env.PATH_CACHE }}/github_v1_16_1.tar
docker load --input ${{ env.PATH_CACHE }}/github_v1_17_1.tar
docker load --input ${{ env.PATH_CACHE }}/github_v1_18_1.tar
docker load --input ${{ env.PATH_CACHE }}/github_latest_1.tar
docker load --input ${{ env.PATH_CACHE }}/github_mergeability_1.tar
- name: Pull base images if no-exist
- name: Build Docker images if no-exists
if: steps.cache.outputs.cache-hit != 'true'
run: |
: # Pull images one-by-one for stability
docker pull golang:1.15-alpine
docker pull golang:1.16-alpine
docker pull golang:1.17-alpine
docker pull golang:1.18-alpine
docker pull golang:alpine
docker pull ghcr.io/keinos/vscode-dev-container-go:latest
- name: Build Docker images if no-exists
if: steps.cache.outputs.cache-hit != 'true'
run: |
mkdir -p ${{ steps.imagetag.outputs.PATH_TAR }}
: # Build container images
docker-compose --file ./.github/docker-compose.yml build
- name: Save built images if no-exists
if: steps.cache.outputs.cache-hit != 'true'
run: |
docker save --output ${{ steps.imagetag.outputs.PATH_TAR }}/github_v1_15_1.tar github_v1_15:latest
docker save --output ${{ steps.imagetag.outputs.PATH_TAR }}/github_v1_16_1.tar github_v1_16:latest
docker save --output ${{ steps.imagetag.outputs.PATH_TAR }}/github_v1_17_1.tar github_v1_17:latest
docker save --output ${{ steps.imagetag.outputs.PATH_TAR }}/github_latest_1.tar github_latest:latest
docker save --output ${{ steps.imagetag.outputs.PATH_TAR }}/github_mergeability_1.tar github_mergeability:latest
: # Ensure the directory exists
mkdir -p ${{ env.PATH_CACHE }}
: # Save images to cache directory
docker save --output ${{ env.PATH_CACHE }}/github_v1_15_1.tar github_v1_15:latest
docker save --output ${{ env.PATH_CACHE }}/github_v1_16_1.tar github_v1_16:latest
docker save --output ${{ env.PATH_CACHE }}/github_v1_17_1.tar github_v1_17:latest
docker save --output ${{ env.PATH_CACHE }}/github_v1_18_1.tar github_v1_18:latest
docker save --output ${{ env.PATH_CACHE }}/github_latest_1.tar github_latest:latest
docker save --output ${{ env.PATH_CACHE }}/github_mergeability_1.tar github_mergeability:latest
- name: Run tests on Go 1.15
run: docker-compose --file ./.github/docker-compose.yml run v1_15
- name: Run tests on Go 1.16
run: docker-compose --file ./.github/docker-compose.yml run v1_16
- name: Run tests on Go 1.17
run: docker-compose --file ./.github/docker-compose.yml run v1_17
- name: Run tests on Go 1.18
run: docker-compose --file ./.github/docker-compose.yml run v1_18
- name: Run tests on latest Go
run: docker-compose --file ./.github/docker-compose.yml run latest
- name: Run tests for mergeability
Expand Down

0 comments on commit 9b0e6cd

Please sign in to comment.