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

chore: code coverage for e2e #3740

Merged
merged 18 commits into from
Jul 24, 2024
Merged
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
98 changes: 0 additions & 98 deletions .github/workflows/e2e.yaml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ permissions:
contents: read

jobs:
event_file:
name: 'Event File'
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v4
with:
name: Event File
path: ${{ github.event_path }}
lint-go:
permissions:
contents: read # for actions/checkout to fetch code
Expand Down Expand Up @@ -72,31 +63,6 @@ jobs:
- name: Compile all packages
run: make controller plugin

- name: Test
run: make test-unit

- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: Unit Test Results
path: |
junit.xml
- name: Generate code coverage artifacts
uses: actions/upload-artifact@v4
with:
name: code-coverage
path: coverage.out

- name: Upload code coverage information to codecov.io
uses: codecov/codecov-action@v4.5.0
with:
file: coverage.out
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

codegen:
name: Verify Codegen
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# use separate workflow to support fork repositories and dependabot branches when publishing test results: see https://github.com/EnricoMi/publish-unit-test-result-action#support-fork-repositories-and-dependabot-branches
name: Test Results
name: Testing Results

on:
workflow_run:
workflows: ["E2E Tests", "Go"]
workflows: ["Testing"]
types:
- completed
permissions: {}
Expand All @@ -19,27 +19,19 @@ jobs:
actions: read
steps:
- name: Download and Extract Artifacts
# TODO repace with native actions/download-artifact once it supports downloading from another workflow: https://github.com/actions/download-artifact/issues/3
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
mkdir -p artifacts && cd artifacts
artifacts_url=${{ github.event.workflow_run.artifacts_url }}
gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact
do
IFS=$'\t' read name url <<< "$artifact"
gh api $url > "$name.zip"
unzip -d "$name" "$name.zip"
done
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
run_id: ${{ github.event.workflow_run.id }}
path: artifacts

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
check_name: "${{ github.event.workflow.name }} Published Test Results"
commit: ${{ github.event.workflow_run.head_sha }}
event_file: artifacts/Event File/event.json
event_name: ${{ github.event.workflow_run.event }}
junit_files: "artifacts/**/junit.xml"
compare_to_earlier_commit: false
test_changes_limit: 0
fail_on: "errors"
commit: ${{ github.event.workflow_run.head_sha }}
event_file: artifacts/Event File/event.json
event_name: ${{ github.event.workflow_run.event }}
files: "artifacts/**/*.xml"
182 changes: 182 additions & 0 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
name: Testing

on:
push:
branches:
- 'master'
- 'release-*'
pull_request:
branches:
- 'master'
- 'release-*'
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
env:
# Golang version to use across CI steps
GOLANG_VERSION: '1.22'

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

permissions:
contents: read

jobs:
event_file:
name: 'Event File'
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v4
with:
name: Event File
path: ${{ github.event_path }}
test-unit:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5.0.2
with:
go-version: ${{ env.GOLANG_VERSION }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Restore go build cache
uses: actions/cache@v4
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-v1-${{ github.run_id }}

- name: Download all Go modules
run: |
go mod download
- name: Test
run: make test-unit

- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: Unit Test Results
path: |
junit.xml
- name: Generate code coverage artifacts
uses: actions/upload-artifact@v4
with:
name: coverage-output-unit
path: coverage-output-unit/coverage.out

test-e2e:
strategy:
fail-fast: false
matrix:
kubernetes:
- version: 1.26
latest: false
- version: 1.27
latest: false
- version: 1.28
latest: false
- version: 1.29
latest: true
name: Run end-to-end tests
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5.0.2
with:
go-version: '1.22'
- uses: actions/checkout@v4
- name: Setup k3s
env:
INSTALL_K3S_CHANNEL: v${{ matrix.kubernetes.version }}
run: |
curl -sfL https://get.k3s.io | sh -
sudo mkdir ~/.kube
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chmod 755 ~/.kube/config
kubectl version
kubectl create ns argo-rollouts
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download cache
run: go mod download
- name: Install CRDs
run: |
kubectl apply -k manifests/crds
kubectl apply -f test/e2e/crds
- name: Start controller
run: make start-e2e 2>&1 | sed -r "s/[[:cntrl:]]\[[0-9]{1,3}m//g" > /tmp/e2e-controller.log &
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true'}}
- name: Run e2e tests
run: make test-e2e
if: ${{ !(github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true') }}
- name: Output Rerun Overview
run: |
[[ -f rerunreport.txt ]] && cat rerunreport.txt || echo "No rerun report found"
- name: Upload E2E Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: E2E Test Results (k8s ${{ matrix.kubernetes.version }})
path: |
junit.xml
- name: Upload e2e-controller logs
uses: actions/upload-artifact@v4
with:
name: e2e-controller-k8s-${{ matrix.kubernetes.version }}.log
path: /tmp/e2e-controller.log
if: ${{ always() }}
- name: Upload code coverage artifacts
uses: actions/upload-artifact@v4
with:
name: coverage-output-e2e
path: coverage-output-e2e
if: ${{ matrix.kubernetes.latest }}

coverage-process:
name: Process Coverage Files
runs-on: ubuntu-latest
needs:
- test-unit
- test-e2e
steps:
- name: Set up Go
uses: actions/setup-go@v5.0.2
with:
go-version: ${{ env.GOLANG_VERSION }}
id: go
- name: Get e2e code coverage
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: coverage-output-e2e
path: coverage-output-e2e
- name: Get unit test code coverage
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: coverage-output-unit
path: coverage-output-unit
- name: combine-go-coverage
run: |
go tool covdata percent -i=coverage-output-unit/,coverage-output-e2e/ -o full-coverage.out
- name: Upload code coverage information to codecov.io
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
file: full-coverage.out
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ plugin-bin/
# static
server/static/*
!server/static/.gitkeep
coverage-output-e2e/
coverage-output-unit/
Loading
Loading