Skip to content

Changes by create-pull-request action #127

Changes by create-pull-request action

Changes by create-pull-request action #127

Workflow file for this run

# Workflow to check code coverage on push.
# This action caches the built Docker image for a month unless any change in the Dockerfile.
name: 100% Coverage
on:
workflow_dispatch:
pull_request:
branches:
- main
env:
PATH_CACHE: /tmp/docker-img-arch
jobs:
go:
name: Run code coverage via container
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- 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@v3
with:
path: ${{ env.PATH_CACHE }}
key: coverage-${{ steps.cacheid.outputs.hash }}
- name: Load Docker images if exist
if: steps.cache.outputs.cache-hit == 'true'
run: |
docker load --input ${{ env.PATH_CACHE }}/github_coverage_1.tar
- name: Pull base images if no-exist
if: steps.cache.outputs.cache-hit != 'true'
run: |
: # Pull images before build for stability
docker pull golang:1.15-alpine
- name: Build Docker images if no-exists
if: steps.cache.outputs.cache-hit != 'true'
run: |
docker-compose --file ./.github/docker-compose.yml build coverage
- name: Save built images if no-exists
if: steps.cache.outputs.cache-hit != 'true'
run: |
: # 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