Skip to content

Commit

Permalink
ci: Reconfigure CodeCov action to ensure stability (#1414)
Browse files Browse the repository at this point in the history
## Relevant issue(s)
Resolves #1413

## Description
- Ensures Codecov doesn't run on every push (code coverage reports will
only generate for every PR, or pushes on `master` and `develop`). This
also means contributors don't need to have codecov to have a build run
successfully on their fork pushes.
- If for whatever reason the code cov token doesn't exist, still run the
action (but might be flakey - so retry until passes up to 5 times).

Future: Should probably rework this to do the `pull_request` -> trigger
a `workflow_run` that will be passed the code coverage report that will
then have the secrets in the second privileged action run. But until
then hopefully this can get us by.

## How has this been tested?
Fork pushes and this PR pushes.
  • Loading branch information
shahzadlone committed May 17, 2023
1 parent b04c423 commit 0621856
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-ami-with-packer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ name: Build AMI With Packer Workflow

on:
push:
tags: ["v[0-9].[0-9]+.[0-9]+"]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

env:
PACKER_LOG: 1
Expand All @@ -28,7 +29,6 @@ jobs:
- name: Checkout code into the directory
uses: actions/checkout@v3


- name: Environment version target
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
# run: echo ${{ env.RELEASE_VERSION }}
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/build-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ name: Build Dependencies Workflow

on:
pull_request:
branches:
- master
- develop

push:
tags:
- v*
- 'v[0-9]+.[0-9]+.[0-9]+'
branches:
- master
- develop
Expand Down
35 changes: 30 additions & 5 deletions .github/workflows/code-test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ name: Code Test Coverage Workflow

on:
pull_request:
branches:
- master
- develop

push:

tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
branches:
- master
- develop

jobs:
code-test-coverage:
Expand All @@ -25,10 +32,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Setup Go
- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.19"
Expand All @@ -37,9 +42,29 @@ jobs:
- name: Generate full test coverage report using go-acc
run: make test:coverage

- name: Upload coverage to Codecov
- name: Upload coverage to Codecov without token, retry on failure
env:
codecov_secret: ${{ secrets.CODECOV_TOKEN }}
if: env.codecov_secret == ''
uses: Wandalen/[email protected]
with:
attempt_limit: 5
attempt_delay: 10000
action: codecov/codecov-action@v3
with: |
fail_ci_if_error: true
files: ./coverage.txt
flags: defra-tests
name: codecov-umbrella
verbose: true
- name: Upload coverage to Codecov with token
env:
codecov_secret: ${{ secrets.CODECOV_TOKEN }}
if: env.codecov_secret != ''
uses: codecov/codecov-action@v3
with:
token: ${{ env.codecov_secret }}
fail_ci_if_error: true
files: ./coverage.txt
flags: defra-tests
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/deploy-ami-with-terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ on:
- completed

pull_request:
branches:
- master
- develop

jobs:
deploy-ami-with-terraform:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/detect-change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ name: Detect Change Workflow

on:
pull_request:
branches:
- master
- develop

push:
tags:
- v*
- 'v[0-9]+.[0-9]+.[0-9]+'
branches:
- master
- develop
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-then-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:

push:
tags:
- v*
- 'v[0-9]+.[0-9]+.[0-9]+'
branches:
- master
- develop
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ name: Run Tests Workflow

on:
pull_request:
branches:
- master
- develop

push:

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/start-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ name: Start Binary Workflow

on:
pull_request:
branches:
- master
- develop

push:
tags:
- v*
- 'v[0-9]+.[0-9]+.[0-9]+'
branches:
- master
- develop
Expand Down

0 comments on commit 0621856

Please sign in to comment.