generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 13
179 lines (167 loc) · 6.08 KB
/
validator.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Validator
on:
push:
branches:
- main
paths:
- ".github/workflows/validator.yaml"
- "components/central-application-connectivity-validator/**"
- "!components/central-application-connectivity-validator/**.md"
- "tests/**"
- "!tests/**.md"
- "!tests/Dockerfile.*"
- "tests/Dockerfile.connectivity-validator"
pull_request_target:
types: [opened, synchronize, reopened]
paths:
- ".github/workflows/validator.yaml"
- "components/central-application-connectivity-validator/**"
- "!components/central-application-connectivity-validator/**.md"
- "tests/**"
- "!tests/**.md"
- "!tests/Dockerfile.*"
- "tests/Dockerfile.connectivity-validator"
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
runs-on: ubuntu-latest
outputs:
validator: ${{ steps.detect-files.outputs.validator_any_changed || steps.fallback-values.outputs.validator_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
id: detect-files
uses: tj-actions/changed-files@d6babd6899969df1a11d14c368283ea4436bca78
with:
files_yaml: |
validator:
- components/central-application-connectivity-validator/**
- .github/workflows/validator.yaml
test:
- tests/**
- .github/workflows/validator.yaml
- name: Fallback values
id: fallback-values
if: steps.detect-files.outcome != 'success'
run: |
echo "validator_any_changed=true" >> $GITHUB_OUTPUT
echo "test_any_changed=true" >> $GITHUB_OUTPUT
unit-tests:
needs: setup
if: needs.setup.outputs.validator == 'true'
runs-on: ubuntu-latest
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/central-application-connectivity-validator/go.mod
cache-dependency-path: components/central-application-connectivity-validator/go.sum
- name: Run unit tests
working-directory: ./components/central-application-connectivity-validator
run: make test | tee test.log
- name: Archive test results
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: validator-unit-test.log
path: ./components/central-application-connectivity-validator/test.log
- name: Unit test summary
if: success() || failure()
run: |
{
echo '## Validator Unit Tests'
echo "<details>"
echo "<summary>click to expand logs</summary>"
printf '\n```\n'
cat ./components/central-application-connectivity-validator/test.log
printf '\n```\n'
echo "</details>"
} >> $GITHUB_STEP_SUMMARY
integration-tests:
runs-on: ubuntu-latest
steps:
- uses: azure/setup-helm@v4.1.0
id: install
- name: Checkout code
uses: actions/checkout@v4
- name: Set up go environment
uses: actions/setup-go@v4
with:
go-version: 1.23.1
- name: Install k3d
env:
K3D_URL: https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh
DEFAULT_K3D_VERSION: v5.6.0
run: curl --silent --fail $K3D_URL | TAG=$DEFAULT_K3D_VERSION bash
- name: Insall yq
run: sudo add-apt-repository ppa:rmescandon/yq && sudo apt update && sudo apt install yq -y
- name: Run unit tests
run: make -C tests/hack/ci k3d-validator-tests
- name: Archive test results
if: always()
uses: actions/upload-artifact@v4
with:
name: validator-integration-test.log
path: application-connectivity-validator-test.log
- name: Integration test summary
if: success() || failure()
run: |
{
echo '## CRA Integration Tests'
echo "<details>"
echo "<summary>click to expand logs</summary>"
printf '\n```\n'
cat application-connectivity-validator-test.log
printf '\n```\n'
echo "</details>"
} >> $GITHUB_STEP_SUMMARY
build-test-image:
needs: setup
if: needs.setup.outputs.test == 'true'
uses: kyma-project/test-infra/.github/workflows/image-builder.yml@main
with:
name: connectivity-validator-test
dockerfile: Dockerfile.connectivity-validator
context: tests
build-image:
needs: setup
if: needs.setup.outputs.validator == 'true'
uses: kyma-project/test-infra/.github/workflows/image-builder.yml@main
with:
name: central-application-connectivity-validator
dockerfile: Dockerfile
context: components/central-application-connectivity-validator
export-tags: true
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 '## Validator 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