Skip to content

Commit

Permalink
chore: Add e2e and unit test comment reports (#2123)
Browse files Browse the repository at this point in the history
Signed-off-by: zachaller <[email protected]>
  • Loading branch information
zachaller authored Jul 11, 2022
1 parent 03b7f5e commit c4205e8
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 5 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/e2e-test-results.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Test Results

on:
workflow_run:
workflows: ["E2E Tests", "Go"]
types:
- completed
permissions: {}

jobs:
test-results:
name: "${{ github.event.workflow.name }} Test Results"
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion != 'skipped'
permissions:
checks: write
pull-requests: write
actions: read
steps:
- name: Download and Extract Artifacts
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
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
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 }}
files: "artifacts/**/*.xml"
compare_to_earlier_commit: false
test_changes_limit: 0
fail_on: "errors"
19 changes: 19 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ concurrency:
cancel-in-progress: true

jobs:
event_file:
name: "Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v2
with:
name: Event File
path: ${{ github.event_path }}
test-e2e:
name: Run end-to-end tests
runs-on: ubuntu-latest
Expand Down Expand Up @@ -58,6 +67,16 @@ jobs:
- name: Run e2e tests
run: make test-e2e
if: ${{ !(github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled) }}
- 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@v2
with:
name: E2E Test Results
path: |
junit.xml
- name: Upload e2e-controller logs
uses: actions/upload-artifact@v2
with:
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ concurrency:
cancel-in-progress: true

jobs:
event_file:
name: "Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v2
with:
name: Event File
path: ${{ github.event_path }}
lint-go:
name: Lint Go code
runs-on: ubuntu-latest
Expand Down Expand Up @@ -58,7 +67,15 @@ jobs:
run: make controller plugin

- name: Test
run: go test -failfast -covermode=count -coverprofile=coverage.out ./...
run: make test-unit

- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: Unit Test Results
path: |
junit.xml
- name: Generate code coverage artifacts
uses: actions/upload-artifact@v2
Expand Down
17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ DEV_IMAGE=false
# E2E variables
E2E_INSTANCE_ID ?= argo-rollouts-e2e
E2E_TEST_OPTIONS ?=
E2E_PARALLEL ?= 4
E2E_PARALLEL ?= 1
E2E_WAIT_TIMEOUT ?= 120

override LDFLAGS += \
Expand Down Expand Up @@ -79,9 +79,13 @@ install-go-tools-local: go-mod-vendor
install-protoc-local:
./hack/installers/install-protoc.sh

.PHONY: install-devtools-local
install-devtools-local:
./hack/installers/install-dev-tools.sh

# Installs all tools required to build and test locally
.PHONY: install-tools-local
install-tools-local: install-go-tools-local install-protoc-local
install-tools-local: install-go-tools-local install-protoc-local install-devtools-local

TYPES := $(shell find pkg/apis/rollouts/v1alpha1 -type f -name '*.go' -not -name openapi_generated.go -not -name '*generated*' -not -name '*test.go')
APIMACHINERY_PKGS=k8s.io/apimachinery/pkg/util/intstr,+k8s.io/apimachinery/pkg/api/resource,+k8s.io/apimachinery/pkg/runtime/schema,+k8s.io/apimachinery/pkg/runtime,k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/api/core/v1,k8s.io/api/batch/v1
Expand Down Expand Up @@ -212,8 +216,13 @@ start-e2e:
go run ./cmd/rollouts-controller/main.go --instance-id ${E2E_INSTANCE_ID} --loglevel debug --kloglevel 6

.PHONY: test-e2e
test-e2e:
go test -timeout 30m -v -count 1 --tags e2e -p ${E2E_PARALLEL} --short ./test/e2e ${E2E_TEST_OPTIONS}
test-e2e: install-devtools-local
${DIST_DIR}/gotestsum --rerun-fails-report=rerunreport.txt --junitfile=junit.xml --format=testname --packages="./test/e2e" --rerun-fails=5 -- -timeout 60m -count 1 --tags e2e -p ${E2E_PARALLEL} -parallel ${E2E_PARALLEL} -v --short ./test/e2e ${E2E_TEST_OPTIONS}

.PHONY: test-unit
test-unit: install-devtools-local
${DIST_DIR}/gotestsum --junitfile=junit.xml --format=testname --packages="./..." -- -covermode=count -coverprofile=coverage.out ./...


.PHONY: coverage
coverage: test
Expand Down
33 changes: 33 additions & 0 deletions docs/features/kustomize/rollout_cr_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,17 @@
},
"type": "object"
},
"influxdb": {
"properties": {
"profile": {
"type": "string"
},
"query": {
"type": "string"
}
},
"type": "object"
},
"job": {
"properties": {
"metadata": {
Expand Down Expand Up @@ -4515,6 +4526,17 @@
},
"type": "object"
},
"influxdb": {
"properties": {
"profile": {
"type": "string"
},
"query": {
"type": "string"
}
},
"type": "object"
},
"job": {
"properties": {
"metadata": {
Expand Down Expand Up @@ -8764,6 +8786,17 @@
},
"type": "object"
},
"influxdb": {
"properties": {
"profile": {
"type": "string"
},
"query": {
"type": "string"
}
},
"type": "object"
},
"job": {
"properties": {
"metadata": {
Expand Down
24 changes: 24 additions & 0 deletions hack/installers/install-dev-tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -eux -o pipefail

PROJECT_ROOT=$(cd $(dirname ${BASH_SOURCE})/../..; pwd)
DIST_PATH="${PROJECT_ROOT}/dist"
PATH="${DIST_PATH}:${PATH}"

mkdir -p ${DIST_PATH}

gotestsum_version=1.8.1

OS=$(go env GOOS)
ARCH=$(go env GOARCH)

export TARGET_FILE=gotestsum_${gotestsum_version}_${OS}_${ARCH}.tar.gz
temp_path="/tmp/${TARGET_FILE}"
url=https://github.com/gotestyourself/gotestsum/releases/download/v${gotestsum_version}/gotestsum_${gotestsum_version}_${OS}_${ARCH}.tar.gz
[ -e ${temp_path} ] || curl -sLf --retry 3 -o ${temp_path} ${url}

mkdir -p /tmp/gotestsum-${gotestsum_version}
tar -xvzf ${temp_path} -C /tmp/gotestsum-${gotestsum_version}
cp /tmp/gotestsum-${gotestsum_version}/gotestsum ${DIST_PATH}/gotestsum
chmod +x ${DIST_PATH}/gotestsum
gotestsum --version

0 comments on commit c4205e8

Please sign in to comment.