Skip to content

Fix integration test race conditions #2531

Fix integration test race conditions

Fix integration test race conditions #2531

name: Integration tests
on:
push:
branches: [main, hirte-*]
pull_request:
branches: [main, hirte-*]
workflow_dispatch:
jobs:
rpmbuild:
runs-on: ubuntu-latest
container:
image: quay.io/bluechi/build-base:latest
env:
ARTIFACTS_DIR: exported-artifacts
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'true'
# Use githash of a tested commit instead of merge commit
ref: ${{ github.event.pull_request.head.sha }}
- name: Mark source directory as safe
run: |
git config --global --add safe.directory $(pwd)
- name: Perform build
run: |
WITH_COVERAGE=1 ./build-scripts/build-rpm.sh $ARTIFACTS_DIR
- name: Create DNF repository
run: |
createrepo_c $ARTIFACTS_DIR
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: rpm-artifacts
path: ${{ env.ARTIFACTS_DIR}}
test:
needs: rpmbuild
runs-on: ubuntu-latest
steps:
- name: Increase inotify values
# Required to bypass error "Failed to allocate directory watch: Too many open files"
run: |
sudo sysctl -w fs.inotify.max_queued_events=32768
sudo sysctl -w fs.inotify.max_user_instances=2048
sudo sysctl -w fs.inotify.max_user_watches=1048576
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install \
genisoimage \
libkrb5-dev \
libvirt-daemon-system \
libvirt-dev \
pkg-config \
podman \
qemu-kvm \
-y
- name: Install unpackaged python libraries from PyPi
run: |
pip install "tmt[provision]>=1.32.1" "tmt[report-junit]>=1.32.1" podman pytest pyyaml paramiko
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: rpm-artifacts
path: 'tests/bluechi-rpms'
- name: Check integration test IDs
run: |
cd tests
tmt test id --dry | grep "New id" && echo "Found integration tests with missing ID. Please generate Test-IDs." && exit 1
cd ..
- name: Lint tmt tests, plans and stories
run: |
cd tests
tmt lint
cd ..
- name: Run integration tests
run: |
cd tests
tmt run -v \
-eCONTAINER_USED=integration-test-local \
-eWITH_COVERAGE=1 \
-eLOG_LEVEL=DEBUG \
plan --name container
- name: Show tmt log output in case of failure
if: ${{ failure() }}
run: |
cat /var/tmp/tmt/run-001/log.txt
# Extract the collected coverage results if they exist and remove them from
# the tmt directory to avoid duplication in artifacts
- name: Extract coverage results
if: always()
run: |
MERGE_FILE="/var/tmp/tmt/run-001/plans/container/report/default-0/merged.info"
COVERAGE_DIR="/var/tmp/tmt/run-001/plans/container/report/default-0/report/"
if [ -d "$COVERAGE_DIR" ]; then
cp -r $COVERAGE_DIR /var/tmp
cp $MERGE_FILE /var/tmp
rm -rf $COVERAGE_DIR
rm -rf $MERGE_FILE
fi
- name: Upload tmt artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: tmt-artifacts
path: '/var/tmp/tmt'
- name: Upload coverage HTML report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-artifacts-html
path: '/var/tmp/report'
- name: Upload coverage file
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-artifacts-info
path: '/var/tmp/merged.info'
- name: Prepare the coverage report for coveralls
if: always()
run: |
sed 's/\/var\/tmp\/bluechi-coverage\/src/src/' /var/tmp/merged.info > /var/tmp/coveralls.info
- name: Report to Coveralls
if: always()
uses: coverallsapp/github-action@v2.3.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: '/var/tmp/coveralls.info'
format: lcov
# Pin the version of the coverage reporter as suggested in
# https://github.com/coverallsapp/github-action/issues/205#issuecomment-2113945931
# TODO: Remove when the coverage reporter issue is resolved
coverage-reporter-version: v0.6.9