Skip to content

Commit b7ce34b

Browse files
committed
Run integration tests on PR
A tests will be executed automatically on each PR after a PR gets approved. To reduce amount of test run we don't run a test on PR push event and instead trigger it by label. JIRA: ISV-4199 Signed-off-by: Ales Raszka <[email protected]>
1 parent bc17cea commit b7ce34b

File tree

8 files changed

+96
-169
lines changed

8 files changed

+96
-169
lines changed

.github/workflows/integration-tests.yml renamed to .github/workflows/build-and-test.yml

+76-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,88 @@
11
---
2-
name: Integration Tests
2+
name: Build and test
33

44
on: # yamllint disable-line rule:truthy
5-
workflow_run:
6-
workflows:
7-
- Build
5+
push:
86
branches:
97
- main
10-
types:
11-
- completed
8+
pull_request:
9+
types: [opened, synchronize, reopened, labeled]
1210
workflow_dispatch:
1311

1412

1513
jobs:
14+
tox:
15+
name: Run unit tests and linters
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up PDM
22+
uses: pdm-project/setup-pdm@v4
23+
with:
24+
python-version: "3.12"
25+
26+
- name: Install non-python dependencies
27+
run: |
28+
sudo apt-get update && sudo apt-get install -y libkrb5-dev
29+
30+
- name: Install Hadolint via Brew
31+
run: |
32+
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
33+
/home/linuxbrew/.linuxbrew/bin/brew install hadolint
34+
sudo ln -s /home/linuxbrew/.linuxbrew/bin/hadolint /usr/bin/
35+
36+
- name: Install Python dependencies
37+
run: |
38+
pdm sync -dG tox
39+
python3 -m pip install ansible-lint
40+
41+
- name: Run Tests
42+
run: |
43+
pdm run -v tox
44+
45+
build:
46+
name: Build and push image
47+
runs-on: ubuntu-latest
48+
49+
steps:
50+
- name: Set variables
51+
id: set-vars
52+
run: |
53+
if [[ $GITHUB_REF_NAME == 'main' ]]; then
54+
echo "tags=latest ${{ github.sha }}" >> $GITHUB_OUTPUT
55+
else
56+
echo "tags=${{ github.sha }}">> $GITHUB_OUTPUT
57+
fi
58+
- uses: actions/checkout@v4
59+
60+
- name: Build Image
61+
id: build-image
62+
uses: redhat-actions/buildah-build@v2
63+
with:
64+
image: operator-pipelines-images
65+
tags: ${{ steps.set-vars.outputs.tags }}
66+
dockerfiles: |
67+
./operator-pipeline-images/Dockerfile
68+
69+
- name: Push To quay.io
70+
id: push-to-quay
71+
uses: redhat-actions/push-to-registry@v2
72+
with:
73+
image: ${{ steps.build-image.outputs.image }}
74+
tags: ${{ steps.build-image.outputs.tags }}
75+
registry: quay.io/redhat-isv
76+
username: ${{ secrets.REGISTRY_USERNAME }}
77+
password: ${{ secrets.REGISTRY_PASSWORD }}
78+
79+
- name: Print image url
80+
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
81+
1682
integration-tests:
83+
needs: [build]
84+
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' || github.event.label.name == 'ready-for-testing'
85+
timeout-minutes: 90
1786
strategy:
1887
matrix:
1988
test_type:
@@ -74,7 +143,7 @@ jobs:
74143
options: |
75144
-e "test_type=${{ matrix.test_type }}"
76145
-e "oc_namespace=int-tests-${{ matrix.test_type }}-${{ github.run_number }}-${{ github.run_attempt }}"
77-
-e "integration_tests_operator_bundle_version=0.1.${{ github.run_number }}-${{ github.run_attempt }}"
146+
-e "integration_tests_operator_bundle_version=0.2.${{ github.run_number }}-${{ github.run_attempt }}"
78147
-e "operator_pipeline_image_tag=${{ github.sha }}"
79148
-e "suffix=${{ steps.prepare.outputs.suffix }}"
80149
--skip-tags=signing-pipeline

.github/workflows/build-image.yml

-44
This file was deleted.

.github/workflows/build-multi-arch-image.yml

-76
This file was deleted.

.github/workflows/deploy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Deployment
44
on: # yamllint disable-line rule:truthy
55
workflow_run:
66
workflows:
7-
- Integration Tests
7+
- Build and test
88
branches:
99
- main
1010
types:

.github/workflows/validation.yml

-41
This file was deleted.

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,20 @@ make build-and-test-isv
219219

220220
# or
221221
make build-and-test-community
222+
# or
223+
make build-and-test-isv-fbc-bundle
224+
# or
225+
make build-and-test-isv-fbc-catalog
222226
```
227+
228+
### Running test in PR workflow
229+
A repository is configured to automatically run all integration tests on pull request.
230+
This makes sure a code change doesn't break existing workflow. Since a tests are
231+
running OCP cluster and requires some resources a tests are execute only when
232+
`ready-for-testing` label is added to a PR. Adding this label executes additional
233+
workflow.
234+
235+
All PRs should pass a tests before merging.
223236
## Additional Documentation
224237

225238
- [OpenShift cluster configuration](docs/cluster-config.md)

ansible/roles/operator-pipeline/templates/openshift/tasks/build-fbc-scratch-catalog.yml

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ spec:
5252
- name: build-fbc-catalog
5353
image: "$(params.pipeline_image)"
5454
workingDir: $(workspaces.source.path)
55+
env:
56+
- name: STORAGE_DRIVER
57+
value: vfs
5558
securityContext:
5659
privileged: true
5760
script: |

ansible/roles/operator-pipeline/templates/openshift/tasks/build-fragment-images.yml

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ spec:
2525
- name: build-fragment-images
2626
image: "$(params.pipeline_image)"
2727
workingDir: $(workspaces.source.path)
28+
env:
29+
- name: STORAGE_DRIVER
30+
value: vfs
2831
securityContext:
2932
privileged: true
3033
script: |

0 commit comments

Comments
 (0)