Skip to content

Commit

Permalink
Issue 6583 - Fix CI on older branches
Browse files Browse the repository at this point in the history
Bug Description:
Test execution on older branches (1.4.x, some 2.x) fails. We use the
same Fedora base image across all branches, but it contains newer
toolchain and doesn't have some build dependencies.

Fix Description:
Use appropriate images: EL8 for 1.4.x, EL9 for 2.x, EL10/Fedora for 3.x.

Fixes: #6583
  • Loading branch information
vashirov committed Feb 5, 2025
1 parent ac4915b commit fe68ba4
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 38 deletions.
39 changes: 30 additions & 9 deletions .github/scripts/generate_matrix.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
import os
import sys
import glob
import json

suites = next(os.walk('dirsrvtests/tests/suites/'))[1]
# If we have arguments passed to the script, use them as the test names to run
if len(sys.argv) > 1:
suites = sys.argv[1:]
valid_suites = []
# Validate if the path is a valid file or directory with files
for suite in suites:
test_path = os.path.join("dirsrvtests/tests/suites/", suite)
if os.path.exists(test_path) and not os.path.islink(test_path):
if os.path.isfile(test_path) and test_path.endswith(".py"):
valid_suites.append(suite)
elif os.path.isdir(test_path):
valid_suites.append(suite)
suites = valid_suites

# Filter out snmp as it is an empty directory:
suites.remove('snmp')
else:
# Use tests from the source
suites = next(os.walk('dirsrvtests/tests/suites/'))[1]

# Run each replication test module separately to speed things up
suites.remove('replication')
repl_tests = glob.glob('dirsrvtests/tests/suites/replication/*_test.py')
suites += [repl_test.replace('dirsrvtests/tests/suites/', '') for repl_test in repl_tests]
suites.sort()
# Filter out snmp as it is an empty directory:
suites.remove('snmp')

# Filter out webui because of broken tests
suites.remove('webui')

# Run each replication test module separately to speed things up
suites.remove('replication')
repl_tests = glob.glob('dirsrvtests/tests/suites/replication/*_test.py')
suites += [repl_test.replace('dirsrvtests/tests/suites/', '') for repl_test in repl_tests]
suites.sort()

suites_list = [{ "suite": suite} for suite in suites]
matrix = {"include": suites_list}

print(json.dumps(matrix))
print(json.dumps(matrix))

37 changes: 22 additions & 15 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,53 @@ on:
- pull_request
- push

permissions:
actions: read
packages: read
contents: read

jobs:
compile:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
name:
- Fedora 33 GCC
- Fedora 33 GCC Strict
- Fedora 33 GCC Static Analyzer
- Fedora 33 Clang
- Fedora 33 Clang -Weverything
- GCC
- GCC Strict
- GCC Static Analyzer
- Clang
- Clang -Weverything

include:
- name: Fedora 33 GCC
image: quay.io/389ds/ci-images:fedora
- name: GCC
image: quay.io/389ds/ci-images:el9test
compiler: gcc
cpp-compiler: g++
cflags: "-O2 -g"

- name: Fedora 33 GCC strict
image: quay.io/389ds/ci-images:fedora
- name: GCC strict
image: quay.io/389ds/ci-images:el9test
compiler: gcc
cpp-compiler: g++
cflags: "-O2 -g -Wall -Wextra -Wundef -Wpointer-arith -Wfloat-equal \
-Wstrict-prototypes -Wstrict-overflow=5 -Wwrite-strings -Winit-self \
-Wuninitialized -Wno-sign-compare -Wshadow -Wformat-security"

- name: Fedora 33 GCC Static Analyzer
image: quay.io/389ds/ci-images:fedora
- name: GCC Static Analyzer
image: quay.io/389ds/ci-images:el9test
compiler: gcc
cpp-compiler: g++
cflags: "-O2 -g -fanalyzer"

- name: Fedora 33 Clang
image: quay.io/389ds/ci-images:fedora
- name: Clang
image: quay.io/389ds/ci-images:el9test
compiler: clang
cpp-compiler: clang++
cflags: "-O2 -g -Qunused-arguments"

- name: Fedora 33 Clang -Weverything
image: quay.io/389ds/ci-images:fedora
- name: Clang -Weverything
image: quay.io/389ds/ci-images:el9test
compiler: clang
cpp-compiler: clang++
cflags: "-O2 -g -Weverything -Qunused-arguments"
Expand All @@ -54,6 +59,8 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Checkout and configure
run: autoreconf -fvi && ./configure
env:
CC: ${{ matrix.compiler }}
CXX: ${{ matrix.cpp-compiler }}
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: npm-audit-ci

on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'

permissions:
actions: read
packages: read
contents: read

jobs:
npm-audit-ci:
name: npm-audit-ci
runs-on: ubuntu-latest
container:
image: quay.io/389ds/ci-images:el9test
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run NPM Audit CI
run: cd $GITHUB_WORKSPACE/src/cockpit/389-console && npx --yes audit-ci --config audit-ci.json
28 changes: 20 additions & 8 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ permissions:
jobs:
build:
name: Build
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
container:
image: quay.io/389ds/ci-images:test
image: quay.io/389ds/ci-images:el9test
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
Expand All @@ -38,10 +38,10 @@ jobs:

- name: Get a list of all test suites
id: set-matrix
run: echo "::set-output name=matrix::$(python3 .github/scripts/generate_matrix.py)"
run: echo "matrix=$(python3 .github/scripts/generate_matrix.py ${{ github.event.inputs.pytest_tests }})" >>$GITHUB_OUTPUT

- name: Build RPMs
run: cd $GITHUB_WORKSPACE && SKIP_AUDIT_CI=1 make -f rpm.mk dist-bz2 rpms
run: SKIP_AUDIT_CI=1 make -f rpm.mk dist-bz2 rpms

- name: Tar build artifacts
run: tar -cvf dist.tar dist/
Expand All @@ -54,7 +54,7 @@ jobs:

test:
name: Test
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: build
strategy:
fail-fast: false
Expand All @@ -77,8 +77,9 @@ jobs:
sudo cp .github/daemon.json /etc/docker/daemon.json
sudo systemctl unmask docker
sudo systemctl start docker
- name: Download RPMs
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: rpms

Expand All @@ -88,9 +89,20 @@ jobs:
- name: Run pytest in a container
run: |
set -x
CID=$(sudo docker run -d -h server.example.com --privileged --rm --shm-size=4gb -v /sys/fs/cgroup:/sys/fs/cgroup:rw,rslave -v ${PWD}:/workspace quay.io/389ds/ci-images:test)
CID=$(sudo docker run -d -h server.example.com --ulimit core=-1 --cap-add=SYS_PTRACE --privileged --rm --shm-size=4gb -v ${PWD}:/workspace quay.io/389ds/ci-images:el9test)
until sudo docker exec $CID sh -c "systemctl is-system-running"
do
echo "Waiting for container to be ready..."
done
sudo docker exec $CID sh -c "dnf install -y -v dist/rpms/*rpm"
sudo docker exec $CID py.test --suppress-no-test-exit-code -m "not flaky" --junit-xml=pytest.xml --html=pytest.html -v dirsrvtests/tests/suites/${{ matrix.suite }}
export PASSWD=$(openssl rand -base64 32)
sudo docker exec $CID sh -c "echo \"${PASSWD}\" | passwd --stdin root"
sudo docker exec $CID sh -c "systemctl start dbus.service"
sudo docker exec $CID sh -c "systemctl enable --now cockpit.socket"
sudo docker exec $CID sh -c "mkdir -p /workspace/assets/cores && chmod 777 /workspace{,/assets{,/cores}}"
sudo docker exec $CID sh -c "echo '/workspace/assets/cores/core.%e.%P' > /proc/sys/kernel/core_pattern"
sudo docker exec -e WEBUI=1 -e DEBUG=pw:api -e PASSWD="${PASSWD}" $CID py.test --suppress-no-test-exit-code -m "not flaky" --junit-xml=pytest.xml --html=pytest.html --browser=firefox --browser=chromium -v dirsrvtests/tests/suites/${{ matrix.suite }}
- name: Make the results file readable by all
if: always()
run: |
Expand Down
38 changes: 32 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,34 @@ on:
push:
tags:
- "389-ds-base-*"
workflow_dispatch:
inputs:
version:
description: Specify tag to generate a tarball
required: true
skip-audit-ci:
description: Skip npx --yes audit-ci
type: boolean
default: false

permissions:
actions: read
packages: read
contents: write

jobs:
build:
runs-on: ubuntu-latest
container:
image: quay.io/389ds/ci-images:test
image: quay.io/389ds/ci-images:el9test
steps:
- name: Get the version
id: get_version
run: |
echo "version=${VERSION}" >> $GITHUB_OUTPUT
env:
VERSION: ${{ github.event.inputs.version || github.ref_name }}

- name: Checkout
uses: actions/checkout@v4
with:
Expand All @@ -31,17 +52,22 @@ jobs:
fi
- name: Create tarball
run: TAG=${{ github.ref_name}} make -f rpm.mk dist-bz2
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
if [ "${{ github.event.inputs.skip-audit-ci }}" = "true" ]; then
export SKIP_AUDIT_CI=1
fi
TAG=${{ steps.get_version.outputs.version }} make -f rpm.mk dist-bz2
- name: Upload tarball
uses: actions/upload-artifact@v4
with:
name: ${{ github.ref_name}}.tar.bz2
path: ${{ github.ref_name}}.tar.bz2
name: ${{ steps.get_version.outputs.version }}.tar.bz2
path: ${{ steps.get_version.outputs.version }}.tar.bz2

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
tag_name: ${{ steps.get_version.outputs.version }}
files: |
${{ github.ref_name}}.tar.bz2
${{ steps.get_version.outputs.version }}.tar.bz2
27 changes: 27 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Validate tests

on:
push:
pull_request:

permissions:
actions: read
packages: read
contents: read

jobs:
validate:
runs-on: ubuntu-latest
container:
image: quay.io/389ds/ci-images:el9test
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run testimony
if: always()
run: testimony validate -c dirsrvtests/testimony.yaml dirsrvtests/tests/suites

- name: Check for duplicate IDs
if: always()
run: python3 dirsrvtests/check_for_duplicate_ids.py dirsrvtests/tests/suites

0 comments on commit fe68ba4

Please sign in to comment.