generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 13
158 lines (146 loc) · 5.06 KB
/
cra.yaml
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: CRA
on:
push:
branches:
- main
paths:
- ".github/workflows/cra.yaml"
- "components/compass-runtime-agent/**"
- "!components/compass-runtime-agent/**.md"
- "!components/compass-runtime-agent/hack/boilerplate.go.txt"
- "tests/**"
- "!tests/**.md"
- "!tests/Dockerfile.*"
- "tests/Dockerfile.compass-runtime-agent"
pull_request_target:
types: [opened, synchronize, reopened]
paths:
- ".github/workflows/cra.yaml"
- "components/compass-runtime-agent/**"
- "!components/compass-runtime-agent/**.md"
- "!components/compass-runtime-agent/hack/boilerplate.go.txt"
- "tests/**"
- "!tests/**.md"
- "!tests/Dockerfile.*"
- "tests/Dockerfile.compass-runtime-agent"
permissions:
id-token: write # This is required for requesting the JWT token
contents: read # This is required for actions/checkout
jobs:
setup:
permissions:
contents: read
pull-requests: read
runs-on: ubuntu-latest
outputs:
cra: ${{ steps.detect-files.outputs.cra_any_changed || steps.fallback-values.outputs.cra_any_changed }}
test: ${{ steps.detect-files.outputs.test_any_changed || steps.fallback-values.outputs.test_any_changed }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Detect files
continue-on-error: true
id: detect-files
uses: tj-actions/changed-files@d6babd6899969df1a11d14c368283ea4436bca78
with:
files_yaml: |
cra:
- components/compass-runtime-agent/**
- .github/workflows/cra.yaml
test:
- tests/**
- .github/workflows/cra.yaml
- name: Fallback values
id: fallback-values
if: steps.detect-files.outcome != 'success'
run: |
echo "cra_any_changed=true" >> $GITHUB_OUTPUT
echo "test_any_changed=true" >> $GITHUB_OUTPUT
unit-tests:
permissions:
contents: read
runs-on: ubuntu-latest
needs: setup
if: needs.setup.outputs.cra == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Set up go environment
uses: actions/setup-go@v5
with:
go-version-file: components/compass-runtime-agent/go.mod
cache-dependency-path: components/compass-runtime-agent/go.sum
- name: Run unit tests
working-directory: ./components/compass-runtime-agent
run: |
touch test.log
make test | tee -a test.log
- name: Archive test results
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: cra-unit-test.log
path: ./components/compass-runtime-agent/test.log
- name: Unit test summary
if: success() || failure()
run: |
{
echo '## CRA Unit Tests'
echo "<details>"
echo "<summary>click to expand logs</summary>"
printf '\n```\n'
cat ./components/compass-runtime-agent/test.log
printf '\n```\n'
echo "</details>"
} >> $GITHUB_STEP_SUMMARY
k3d-integration:
# we're using reusable because we can't modify workflows as contributors
# it could cause the secret leakeages
uses: "./.github/workflows/reusable-k3d-agent-test.yml"
with:
k3d-version: v5.6.0
secrets:
compass-host: ${{ secrets.COMPASS_HOST }}
compass-client-id: ${{ secrets.COMPASS_CLIENT_ID }}
compass-client-secret: ${{ secrets.COMPASS_CLIENT_SECRET }}
build-test-image:
needs: setup
if: needs.setup.outputs.test == 'true'
uses: kyma-project/test-infra/.github/workflows/image-builder.yml@main
with:
name: compass-runtime-agent-test
dockerfile: Dockerfile.compass-runtime-agent
context: tests
build-image:
needs: setup
if: needs.setup.outputs.cra == 'true'
uses: kyma-project/test-infra/.github/workflows/image-builder.yml@main
with:
name: compass-runtime-agent
dockerfile: Dockerfile
context: components/compass-runtime-agent
print-images:
runs-on: ubuntu-latest
# if any of the build jobs succeeded - run this job
needs: [build-image, build-test-image]
if: always() && contains(needs.*.result, 'success')
steps:
- name: "Generate summary"
run: |
{
echo '## CRA Images'
printf '\n```json\n'
if [ "${{ needs.build-image.result }}" == "success" ]; then
echo '${{ needs.build-image.outputs.images }}' | jq
fi
if [ "${{ needs.build-test-image.result }}" == "success" ]; then
echo '${{ needs.build-test-image.outputs.images }}' | jq
fi
printf '\n```\n'
} >> $GITHUB_STEP_SUMMARY