From 1807360fcebc5aa764b50c42ccd5df5cd42094c9 Mon Sep 17 00:00:00 2001 From: Iker Pedrosa Date: Thu, 21 Nov 2024 16:19:18 +0100 Subject: [PATCH] CI: run system tests Run the newly created system tests in CI and collect artifacts. Signed-off-by: Iker Pedrosa --- .github/workflows/runner.yml | 6 +++++ share/ansible/playbook.yml | 5 ++++ share/ansible/roles/ci_run/tasks/alpine.yml | 7 ++++++ share/ansible/roles/ci_run/tasks/debian.yml | 6 +++++ share/ansible/roles/ci_run/tasks/fedora.yml | 6 +++++ .../ansible/roles/run_system_tests/README.md | 23 +++++++++++++++++++ .../roles/run_system_tests/tasks/main.yml | 14 +++++++++++ 7 files changed, 67 insertions(+) create mode 100644 share/ansible/roles/run_system_tests/README.md create mode 100644 share/ansible/roles/run_system_tests/tasks/main.yml diff --git a/.github/workflows/runner.yml b/.github/workflows/runner.yml index f0fb5e25c..ac6440d22 100644 --- a/.github/workflows/runner.yml +++ b/.github/workflows/runner.yml @@ -74,6 +74,10 @@ jobs: os: [alpine, debian, fedora] steps: + - uses: actions/setup-python@v5 + with: + python-version: 3.11 + - name: Checkout repository uses: actions/checkout@v3 @@ -98,4 +102,6 @@ jobs: ./share/ansible/build-out/config.h ./share/ansible/build-out/build.log ./share/ansible/build-out/test-suite.log + ./tests/system/pytest.log + ./tests/system/artifacts if-no-files-found: ignore diff --git a/share/ansible/playbook.yml b/share/ansible/playbook.yml index 6e69e2e19..06fb6e48f 100644 --- a/share/ansible/playbook.yml +++ b/share/ansible/playbook.yml @@ -15,3 +15,8 @@ gather_facts: false roles: - role: ci_run + +- name: Run system tests + hosts: localhost + roles: + - role: run_system_tests diff --git a/share/ansible/roles/ci_run/tasks/alpine.yml b/share/ansible/roles/ci_run/tasks/alpine.yml index 7c5a53b10..892c5b143 100644 --- a/share/ansible/roles/ci_run/tasks/alpine.yml +++ b/share/ansible/roles/ci_run/tasks/alpine.yml @@ -12,6 +12,7 @@ - build-base - byacc - cmocka-dev + - coreutils - expect - gettext-dev - git @@ -64,3 +65,9 @@ - "/usr/local/src/shadow/config.h" - "/usr/local/src/shadow/build.log" - "/usr/local/src/shadow/tests/unit/test-suite.log" + +- name: Copy configuration file for testing + ansible.builtin.copy: + src: /usr/local/src/shadow/etc/login.defs + dest: /etc/login.defs + remote_src: yes diff --git a/share/ansible/roles/ci_run/tasks/debian.yml b/share/ansible/roles/ci_run/tasks/debian.yml index b715e3df2..a46bdab5e 100644 --- a/share/ansible/roles/ci_run/tasks/debian.yml +++ b/share/ansible/roles/ci_run/tasks/debian.yml @@ -71,3 +71,9 @@ - "/usr/local/src/shadow/config.h" - "/usr/local/src/shadow/build.log" - "/usr/local/src/shadow/tests/unit/test-suite.log" + +- name: Copy configuration file for testing + ansible.builtin.copy: + src: /usr/local/src/shadow/etc/login.defs + dest: /etc/login.defs + remote_src: yes diff --git a/share/ansible/roles/ci_run/tasks/fedora.yml b/share/ansible/roles/ci_run/tasks/fedora.yml index 9a7e0ea4e..fcd606db7 100644 --- a/share/ansible/roles/ci_run/tasks/fedora.yml +++ b/share/ansible/roles/ci_run/tasks/fedora.yml @@ -72,3 +72,9 @@ - "/usr/local/src/shadow/config.h" - "/usr/local/src/shadow/build.log" - "/usr/local/src/shadow/tests/unit/test-suite.log" + +- name: Copy configuration file for testing + ansible.builtin.copy: + src: /usr/local/src/shadow/etc/login.defs + dest: /etc/login.defs + remote_src: yes diff --git a/share/ansible/roles/run_system_tests/README.md b/share/ansible/roles/run_system_tests/README.md new file mode 100644 index 000000000..604389807 --- /dev/null +++ b/share/ansible/roles/run_system_tests/README.md @@ -0,0 +1,23 @@ +Role Name +========= + +Run system tests. + +Example Playbook +---------------- + +Usage example: + + - hosts: localhost + roles: + - role: run_system_tests + +License +------- + +BSD + +Author Information +------------------ + +Iker Pedrosa diff --git a/share/ansible/roles/run_system_tests/tasks/main.yml b/share/ansible/roles/run_system_tests/tasks/main.yml new file mode 100644 index 000000000..1b447564f --- /dev/null +++ b/share/ansible/roles/run_system_tests/tasks/main.yml @@ -0,0 +1,14 @@ +--- +# tasks file for run_system_tests +- name: Prepare environment and run system tests + ansible.builtin.shell: | + set -ex + pushd ../../tests/system/ + python3 -m venv .venv + source .venv/bin/activate + pip3 install -r ./requirements.txt + exec 3>&1 1> >(tee pytest.log) 2>&1 + pytest --mh-config=mhc.yaml --mh-lazy-ssh -vvv + popd + args: + executable: /bin/bash -- 2.47.3