-
Notifications
You must be signed in to change notification settings - Fork 24
187 lines (154 loc) · 5.77 KB
/
integration-test-containers.yml
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
180
181
182
183
184
185
186
187
name: Build Integration Test Containers
on:
workflow_call:
inputs:
collector-tag:
type: string
required: true
description: |
The tag used to build the collector image
collector-qa-tag:
type: string
required: true
description: Tag used for QA containers
rebuild-qa-containers:
type: boolean
required: true
description: Whether the QA containers should be rebuilt
is-konflux:
type: boolean
default: false
description: The current workflow is tied to konflux
outputs:
collector-tests-tag:
description: The tag used for the integration test image
value: ${{ jobs.build-test-image.outputs.collector-tests-tag || 'collector-tests-master' }}
jobs:
should-build-test-image:
name: Determine if tests image needs to be built
runs-on: ubuntu-24.04
outputs:
build-image: ${{ steps.changed.outputs.tests-changed }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changed
with:
filters: |
tests-changed:
- integration-tests/pkg/**
- integration-tests/suites/**
- integration-tests/*.go
- integration-tests/go.mod
- integration-tests/go.sum
- integration-tests/images.yml
- integration-tests/Dockerfile
- .github/workflows/integration-test-containers.yml
build-test-image:
name: Build the integration test image
runs-on: ubuntu-24.04
needs:
- should-build-test-image
if: |
(github.event_name != 'pull_request' || needs.should-build-test-image.outputs.build-image == 'true') &&
!contains(github.event.pull_request.labels.*.name, 'skip-integration-tests')
outputs:
collector-tests-tag: ${{ steps.tests-tag.outputs.collector-tests-tag }}
env:
DEFAULT_TESTS_TAG: collector-tests-master
steps:
- uses: actions/checkout@v4
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
- name: Create Ansible Vars (inc. Secrets)
run: |
cat << EOF > ${{ github.workspace }}/ansible/secrets.yml
---
rhacs_eng_username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }}
rhacs_eng_password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }}
EOF
if [[ "${RUNNER_DEBUG}" == "1" ]]; then
echo "ANSIBLE_STDOUT_CALLBACK=debug" >> "${GITHUB_ENV}"
fi
- name: Define tests tag
id: tests-tag
run: |
COLLECTOR_TESTS_TAG="${DEFAULT_TESTS_TAG}"
if [[ "${{ github.event_name }}" == 'pull_request' || \
"${{ github.ref_type }}" == 'tag' || \
"${{ github.ref_name }}" =~ ^release- ]]; then
COLLECTOR_TESTS_TAG="collector-tests-${{ inputs.collector-tag }}"
fi
echo "COLLECTOR_TESTS_TAG=${COLLECTOR_TESTS_TAG}" >> "$GITHUB_ENV"
echo "collector-tests-tag=${COLLECTOR_TESTS_TAG}" >> "$GITHUB_OUTPUT"
- name: Check if multiarch is needed
run: |
BUILD_MULTI_ARCH="false"
if [[ "${GITHUB_EVENT_NAME}" != "pull_request" ]]; then
BUILD_MULTI_ARCH="true"
fi
if [[ "${{ inputs.is-konflux }}" == "true" ]]; then
BUILD_MULTI_ARCH="true"
fi
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds') }}" == "true" ]]; then
BUILD_MULTI_ARCH="true"
fi
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'run-cpaas-steps') }}" == "true" ]]; then
BUILD_MULTI_ARCH="true"
fi
echo "BUILD_MULTI_ARCH=${BUILD_MULTI_ARCH}" >> "$GITHUB_ENV"
- name: Build images
run: |
ansible-galaxy install -r ansible/requirements.yml
# build_multi_arch passed in as json to ensure boolean type
ansible-playbook \
--connection local -i localhost, --limit localhost \
-e test_image="quay.io/rhacs-eng/qa-multi-arch:${COLLECTOR_TESTS_TAG}" \
-e "{\"build_multi_arch\": $BUILD_MULTI_ARCH}" \
-e @'${{ github.workspace }}/ansible/secrets.yml' \
ansible/ci-build-tests.yml
common-variables:
runs-on: ubuntu-24.04
outputs:
build-dirs: ${{ steps.variables.outputs.build-dirs }}
steps:
- uses: actions/checkout@v4
- name: Set variables
id: variables
run: |
dirs=$(find integration-tests/container/ -type d -mindepth 1 -maxdepth 1)
json_dirs="$(echo "$dirs" | jq --raw-input --slurp 'split("\n") | map(select(. != ""))')"
{
echo "build-dirs<<EOS"
echo "$json_dirs"
echo "EOS"
} >> "$GITHUB_OUTPUT"
rebuild-containers:
needs:
- common-variables
if: inputs.rebuild-qa-containers
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
directory: ${{ fromJSON(needs.common-variables.outputs.build-dirs) }}
env:
PLATFORM: linux/amd64,linux/s390x,linux/ppc64le,linux/arm64
COLLECTOR_QA_TAG: ${{ inputs.collector-qa-tag }}
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to quay.io/rhacs-eng
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }}
password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }}
- name: Build and Push containers
run: |
make -C "${{ matrix.directory }}" build-and-push