Repository navigation
97 lines (93 loc) · 3.98 KB
/
Copy pathtest-reusable.yaml
File metadata and controls
97 lines (93 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Unit Tests (Reusable)
on:
workflow_call:
secrets:
CODECOV_TOKEN:
required: false
push:
branches:
- main
- release-4.22
permissions:
contents: read
jobs:
changes:
name: Detect Changes
runs-on: arc-runner-set
timeout-minutes: 5
outputs:
run_tests: ${{ steps.changes.outputs.run_tests }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
env:
HOME: /tmp
with:
go-version-file: go.mod
cache: false
- name: Check for non-contrib changes
id: changes
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "run_tests=true" >> "$GITHUB_OUTPUT"
exit 0
elif [ "${{ github.event_name }}" = "pull_request" ]; then
FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
else
if [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then
echo "run_tests=true" >> "$GITHUB_OUTPUT"
exit 0
fi
FILES=$(git diff --name-only ${{ github.event.before }}..${{ github.sha }})
fi
if echo "$FILES" | grep -qvE '^(contrib|\.github|docs)/'; then
echo "run_tests=true" >> "$GITHUB_OUTPUT"
else
echo "run_tests=false" >> "$GITHUB_OUTPUT"
fi
test:
name: Unit Tests (${{ matrix.shard }})
needs: changes
if: needs.changes.outputs.run_tests == 'true'
runs-on: arc-runner-set
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- shard: cpo-hostedcontrolplane
packages: ./control-plane-operator/controllers/hostedcontrolplane/...
- shard: cpo-other
packages: ./control-plane-operator/controllers/awsprivatelink/... ./control-plane-operator/controllers/azureprivatelinkservice/... ./control-plane-operator/controllers/gcpprivateserviceconnect/... ./control-plane-operator/controllers/healthcheck/... ./control-plane-operator/controllers/openshiftmanager/... ./control-plane-operator/endpoint-resolver/... ./control-plane-operator/hostedclusterconfigoperator/... ./control-plane-operator/metrics-proxy/...
- shard: hypershift-operator
packages: ./hypershift-operator/...
- shard: cmd-support
packages: ./cmd/... ./support/...
- shard: other
packages: ./karpenter-operator/... ./control-plane-pki-operator/... ./contrib/... ./ignition-server/... ./pkg/... ./dnsresolver/... ./product-cli/... ./client/... ./test/integration/... ./test/e2e/util/... ./test/util/... ./availability-prober/... ./konnectivity-socks5-proxy/... ./konnectivity-https-proxy/... ./kubernetes-default-proxy/... ./kubevirtexternalinfra/... ./etcd-defrag/... ./etcd-backup/... ./etcd-recovery/... ./etcd-upload/... ./kas-bootstrap/... ./sharedingress-config-generator/... ./sync-fg-configmap/... ./sync-global-pullsecret/... ./token-minter/...
env:
GOMODCACHE: /tmp/go-mod-cache
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
env:
HOME: /tmp
with:
go-version-file: go.mod
cache: false
- name: Run tests
run: make test-shard TEST_PACKAGES="${{ matrix.packages }}" COVER_PROFILE="cover-${{ matrix.shard }}.out"
- name: Upload to Codecov
uses: codecov/codecov-action@0b35c9ecc4f0529d0eb674914510c22f85b196b4 # v7.1.0
env:
HOME: /tmp
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: cover-${{ matrix.shard }}.out
flags: ${{ matrix.shard }}