Skip to content

Commit

Permalink
Run integration tests on PR
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Allda committed Sep 17, 2024
1 parent bc17cea commit b7ce34b
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 169 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,88 @@
---
name: Integration Tests
name: Build and test

on: # yamllint disable-line rule:truthy
workflow_run:
workflows:
- Build
push:
branches:
- main
types:
- completed
pull_request:
types: [opened, synchronize, reopened, labeled]
workflow_dispatch:


jobs:
tox:
name: Run unit tests and linters
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: "3.12"

- name: Install non-python dependencies
run: |
sudo apt-get update && sudo apt-get install -y libkrb5-dev
- name: Install Hadolint via Brew
run: |
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
/home/linuxbrew/.linuxbrew/bin/brew install hadolint
sudo ln -s /home/linuxbrew/.linuxbrew/bin/hadolint /usr/bin/
- name: Install Python dependencies
run: |
pdm sync -dG tox
python3 -m pip install ansible-lint
- name: Run Tests
run: |
pdm run -v tox
build:
name: Build and push image
runs-on: ubuntu-latest

steps:
- name: Set variables
id: set-vars
run: |
if [[ $GITHUB_REF_NAME == 'main' ]]; then
echo "tags=latest ${{ github.sha }}" >> $GITHUB_OUTPUT
else
echo "tags=${{ github.sha }}">> $GITHUB_OUTPUT
fi
- uses: actions/checkout@v4

- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: operator-pipelines-images
tags: ${{ steps.set-vars.outputs.tags }}
dockerfiles: |
./operator-pipeline-images/Dockerfile
- name: Push To quay.io
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: quay.io/redhat-isv
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Print image url
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"

integration-tests:
needs: [build]
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' || github.event.label.name == 'ready-for-testing'
timeout-minutes: 90
strategy:
matrix:
test_type:
Expand Down Expand Up @@ -74,7 +143,7 @@ jobs:
options: |
-e "test_type=${{ matrix.test_type }}"
-e "oc_namespace=int-tests-${{ matrix.test_type }}-${{ github.run_number }}-${{ github.run_attempt }}"
-e "integration_tests_operator_bundle_version=0.1.${{ github.run_number }}-${{ github.run_attempt }}"
-e "integration_tests_operator_bundle_version=0.2.${{ github.run_number }}-${{ github.run_attempt }}"
-e "operator_pipeline_image_tag=${{ github.sha }}"
-e "suffix=${{ steps.prepare.outputs.suffix }}"
--skip-tags=signing-pipeline
Expand Down
44 changes: 0 additions & 44 deletions .github/workflows/build-image.yml

This file was deleted.

76 changes: 0 additions & 76 deletions .github/workflows/build-multi-arch-image.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Deployment
on: # yamllint disable-line rule:truthy
workflow_run:
workflows:
- Integration Tests
- Build and test
branches:
- main
types:
Expand Down
41 changes: 0 additions & 41 deletions .github/workflows/validation.yml

This file was deleted.

13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,20 @@ make build-and-test-isv

# or
make build-and-test-community
# or
make build-and-test-isv-fbc-bundle
# or
make build-and-test-isv-fbc-catalog
```

### Running test in PR workflow
A repository is configured to automatically run all integration tests on pull request.
This makes sure a code change doesn't break existing workflow. Since a tests are
running OCP cluster and requires some resources a tests are execute only when
`ready-for-testing` label is added to a PR. Adding this label executes additional
workflow.

All PRs should pass a tests before merging.
## Additional Documentation

- [OpenShift cluster configuration](docs/cluster-config.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ spec:
- name: build-fbc-catalog
image: "$(params.pipeline_image)"
workingDir: $(workspaces.source.path)
env:
- name: STORAGE_DRIVER
value: vfs
securityContext:
privileged: true
script: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ spec:
- name: build-fragment-images
image: "$(params.pipeline_image)"
workingDir: $(workspaces.source.path)
env:
- name: STORAGE_DRIVER
value: vfs
securityContext:
privileged: true
script: |
Expand Down

0 comments on commit b7ce34b

Please sign in to comment.