Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/codecov-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Codecov Config Checks

on:
push:
branches:
- main
- 'release-[0-9]+.[0-9]+'
paths:
- codecov.yml
- .github/workflows/codecov-checks.yaml
pull_request:
branches:
- main
Comment thread
rm3l marked this conversation as resolved.
- 'release-[0-9]+.[0-9]+'

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
validate:
name: Validate Codecov Config
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false

- name: Get changed files
if: github.event_name == 'pull_request'
id: changed-files
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files: |
codecov.yml
.github/workflows/codecov-checks.yaml

- name: Validate codecov.yml
if: github.event_name != 'pull_request' || steps.changed-files.outputs.any_changed == 'true'
run: |
response=$(curl -s -w "\n%{http_code}" --retry 3 --retry-delay 5 \
-X POST \
--data-binary @codecov.yml \
https://codecov.io/validate)

http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')

echo "HTTP Status: ${http_code}"
echo "Response: ${body}"

if [ "$http_code" -eq 400 ]; then
echo "::error::Invalid codecov.yml configuration"
exit 1
elif [ "$http_code" -ne 200 ]; then
echo "::warning::Could not validate codecov.yml (HTTP ${http_code}). Transient issue?"
exit 1
fi

echo "codecov.yml is valid"
68 changes: 67 additions & 1 deletion .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Nightly E2E Tests
name: Nightly Tests

on:
schedule:
Expand All @@ -9,6 +9,72 @@ permissions:
contents: read

jobs:
lint:
name: Lint (${{ matrix.branch }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
branch:
- main
# release-1.10 is bash-based and has no golangci-lint config
- release-2.1
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ matrix.branch }}
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
with:
go-version-file: go.mod

- name: Run lint
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9
with:
version: v2.14.0

unit-tests:
name: Unit Tests (${{ matrix.branch }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
branch:
- main
- release-1.10
- release-2.1
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ matrix.branch }}
fetch-depth: 0
Comment thread
rm3l marked this conversation as resolved.

- name: Capture commit SHA
run: echo "COMMIT_SHA=$(git rev-parse HEAD)" >> "$GITHUB_ENV"

- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
with:
go-version-file: go.mod

- name: Run tests
run: make test

# release-1.10 is bash-based; its Makefile does not produce cover.out
- name: Upload coverage to Codecov
if: matrix.branch != 'release-1.10'
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v6
with:
files: cover.out
flags: unittests,nightly
fail_ci_if_error: false
override_commit: ${{ env.COMMIT_SHA }}
override_branch: ${{ matrix.branch }}

e2e-tests:
name: Nightly E2E Tests (${{ matrix.branch }})
runs-on: ubuntu-latest
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ jobs:
if: steps.changed-files.outputs.any_changed == 'true'
run: make test

- name: Upload coverage to Codecov
if: steps.changed-files.outputs.any_changed == 'true'
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v6
with:
files: cover.out
flags: unittests
fail_ci_if_error: false
override_commit: ${{ github.event.pull_request.head.sha }}
override_pr: ${{ github.event.number }}

- name: Run lint
if: steps.changed-files.outputs.any_changed == 'true'
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ rhdh-must-gather-output.tar.gz

# Go
*.test
cover.out
coverage.out

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ endif

.PHONY: test
test: ## Run unit tests
$(GO) test -mod=mod ./... -v -count=1
$(GO) test -mod=mod ./... -v -count=1 -coverprofile=cover.out

.PHONY: lint
lint: ## Run linter (golangci-lint)
Expand Down
34 changes: 34 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
coverage:
status:
project:
default:
target: auto
threshold: 1%
informational: true
patch:
default:
target: auto
threshold: 5%
informational: true

comment:
layout: "reach, diff, flags, files"
behavior: default

flags:
unittests:
paths:
- cmd/
- internal/
carryforward: true
Comment thread
rm3l marked this conversation as resolved.
nightly:
paths:
- cmd/
- internal/
carryforward: true

ignore:
- tests/
- hack/
- scripts/
- cmd/gather/main.go
Loading