Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Fix semver tag-push patterns. #4

Open
wants to merge 9 commits into
base: Develop
Choose a base branch
from
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
41 changes: 33 additions & 8 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,13 +42,33 @@ 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/wretry.action@v1.0.36
with:
attempt_limit: 5
attempt_delay: 10000
action: codecov/codecov-action@v3
with: |
fail_ci_if_error: true
files: ./coverage.txt
flags: defradb-tests
name: codecov-report-no-token
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:
fail_ci_if_error: true
token: ${{ env.codecov_secret }}
files: ./coverage.txt
flags: defra-tests
name: codecov-umbrella
flags: defradb-tests
name: codecov-report-token
fail_ci_if_error: true
verbose: true
# path_to_write_report: ./coverage/codecov_report.txt
# directory: ./coverage/reports/
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
67 changes: 67 additions & 0 deletions .github/workflows/generate-code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Copyright 2023 Democratized Data Foundation
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.txt.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0, included in the file
# licenses/APL.txt.

name: Generate Code Coverage Workflow

on:
pull_request:
branches:
- master
- Develop

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

env:
# Note: latest head on PR is different (on pull_request) than the head on merge commit
# that triggers this (on push).
# Reference: https://github.com/orgs/community/discussions/26325
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}

jobs:
generate-code-coverage:
name: Generate code coverage job

runs-on: ubuntu-latest

steps:
- name: Print pull_request head and github SHA
run: |
echo "COMMIT_SHA=[${COMMIT_SHA}]\n"
echo "github.event.pull_request.head.sha=[${{github.event.pull_request.head.sha}}]\n"
echo "github.sha=[${{github.sha}}]\n"

- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github.event.workflow_run) }}
run: echo "$GITHUB_CONTEXT"

- name: Checkout code
uses: actions/checkout@v3

- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.19"
check-latest: true

- name: Generate full test coverage report
run: make test:coverage

- name: Save coverage report as artifact
uses: actions/upload-artifact@v3
with:
name: coverage-report-artifact-${{ env.COMMIT_SHA }}
path: coverage.txt
retention-days: 90
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
94 changes: 94 additions & 0 deletions .github/workflows/upload-code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Copyright 2023 Democratized Data Foundation
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.txt.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0, included in the file
# licenses/APL.txt.

name: Upload Code Coverage Workflow

on:
workflow_run:
# Warning: this workflow must NOT:
# - interact with any new code.
# - checkout new code.
# - build/compile/run any thing
# - make any indirect calls (i.e. make xyz, or npm install, etc.)
# Note this workflow:
# - will use the base's workflow file state.
# - doesn't run on the PR or the branch coming in, it runs on the default branch.
# - has read-write repo token
# - has access to secrets
workflows: ["Generate Code Coverage Workflow"]
types:
- completed

env:
# Note: Since this runs on the state of workflow on the default branch, the
# HEAD i.e. `github.sha` is always the default branch, so we try to fetch the
# head sha whose workflow triggered this action by `github.event.workflow_run.head_sha`.
COMMIT_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}

jobs:
upload-code-coverage:
name: Upload code coverage job

if: ${{ github.event.workflow_run.conclusion == 'success' }}

runs-on: ubuntu-latest

steps:
- name: Print workflow_run head and github SHA
run: |
echo "COMMIT_SHA=[${COMMIT_SHA}]\n"
echo "github.event.workflow_run.head_sha=[${{github.event.workflow_run.head_sha}}]\n"
echo "github.sha=[${{github.sha}}]\n"

- name: Load the coverage report stored as an artifact
uses: dawidd6/action-download-artifact@v2
with:
repo: ${{ github.repository }}
workflow: generate-code-coverage.yml
workflow_conclusion: success
commit: ${{ env.COMMIT_SHA }}
name: coverage-report-artifact-${{ env.COMMIT_SHA }}
name_is_regexp: false
search_artifacts: false
check_artifacts: false
if_no_artifact_found: fail

- name: Upload coverage to Codecov without token, retry on failure
env:
CODECOV_SECRET: ${{ secrets.CODECOV_TOKEN }}
if: env.CODECOV_SECRET == ''
uses: Wandalen/wretry.action@v1.0.36
with:
attempt_limit: 5
attempt_delay: 10000
action: codecov/codecov-action@v3
with: |
files: ./coverage.txt
flags: defradb-tests
name: codecov-report
sha: ${{ env.COMMIT_SHA }}
fail_ci_if_error: true
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 }}
files: ./coverage.txt
flags: defradb-tests
name: codecov-report
sha: ${{ env.COMMIT_SHA }}
fail_ci_if_error: true
verbose: true
# path_to_write_report: ./coverage/codecov_report.txt
# directory: ./coverage/reports/