Skip to content

Commit

Permalink
first pass at coverage for e2e
Browse files Browse the repository at this point in the history
Signed-off-by: Zach Aller <[email protected]>
  • Loading branch information
zachaller committed Jul 23, 2024
1 parent 63c0eec commit d06df9b
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 25 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ on:
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 }}
Expand All @@ -33,6 +36,50 @@ jobs:
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/[email protected]
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: code-coverage
path: coverage.out
# - name: Upload code coverage information to codecov.io
# uses: codecov/[email protected]
# with:
# file: coverage.out
# fail_ci_if_error: false
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
test-e2e:
strategy:
fail-fast: false
Expand Down Expand Up @@ -96,3 +143,30 @@ jobs:
name: e2e-controller-k8s-${{ matrix.kubernetes-minor-version }}.log
path: /tmp/e2e-controller.log
if: ${{ always() }}
- name: Generate code coverage artifacts
uses: actions/upload-artifact@v4
with:
name: e2e-coverage-output
path: e2e-coverage-output
coverage-process:
name: Run end-to-end tests
runs-on: ubuntu-latest
needs:
- test-unit
- test-e2e
steps:
- name: Set up Go
uses: actions/[email protected]
with:
go-version: ${{ env.GOLANG_VERSION }}
id: go
- name: Get e2e code coverage
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: e2e-coverage-output
path: e2e-coverage-output
- name: Get unit test code coverage
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: code-coverage
path: coverage.out
48 changes: 24 additions & 24 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,30 +72,30 @@ 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/[email protected]
with:
file: coverage.out
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# - 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/[email protected]
# with:
# file: coverage.out
# fail_ci_if_error: false
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

codegen:
name: Verify Codegen
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ plugin-bin/
# static
server/static/*
!server/static/.gitkeep
e2e-coverage-output/
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ test-kustomize: ## run kustomize tests

.PHONY: start-e2e
start-e2e: ## start e2e test environment
go run ./cmd/rollouts-controller/main.go --instance-id ${E2E_INSTANCE_ID} --loglevel debug --kloglevel 6
mkdir -p e2e-coverage-output
GOCOVERDIR=e2e-coverage-output go run -cover ./cmd/rollouts-controller/main.go --instance-id ${E2E_INSTANCE_ID} --loglevel debug --kloglevel 6

.PHONY: test-e2e
test-e2e: install-devtools-local
Expand Down

0 comments on commit d06df9b

Please sign in to comment.