From 37e45190d9659f08539e63bee1902de64c023ceb Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Jan 09 2019 20:46:01 +0000 Subject: Run tests under docker. Gain control over what is installed on the test nodes. Also switch to having all tests run under either tests/common_tests.sh or tests/pr_tests.sh, which will handle PRs better that want to change the current tests. Signed-off-by: Stephen Gallagher --- diff --git a/.cico.pipeline b/.cico.pipeline index 60e6dd6..17182cc 100644 --- a/.cico.pipeline +++ b/.cico.pipeline @@ -1,28 +1,19 @@ -node('fedora27') { - - properties([ - parameters([ - string(defaultValue: "", description: "", name: "REPO"), - string(defaultValue: "", description: "", name: "BRANCH"), - ]) - ]) +pipeline { + parameters { + string(defaultValue: "", description: "", name: "REPO") + string(defaultValue: "", description: "", name: "BRANCH") + } - try { - deleteDir() - stage('Clone Test Suite') { - sh "git clone --single-branch --depth 1 https://pagure.io/releng/fedora-module-defaults.git" - } + agent { node { label 'fedora29' } } - stage('Run Test Suite') { - timeout(time: 6, unit: 'HOURS') { - sh 'cd fedora-module-defaults && sh ./run_tests.sh' + stages { + stage('Validate Content') { + agent { + dockerfile { label 'fedora29' } + } + steps { + sh './run_tests.sh' } } - - } catch (e) { - currentBuild.result = "FAILURE" - throw e - } finally { - } } diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f2cd731 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM registry.fedoraproject.org/fedora:rawhide + +LABEL maintainer="Stephen Gallagher " + +RUN dnf -y --setopt=install_weak_deps=False install \ + git-core \ + make \ + python3-libmodulemd \ + python3-libmodulemd1 \ + python3-GitPython \ + && dnf -y clean all diff --git a/Makefile b/Makefile deleted file mode 100644 index 775b12c..0000000 --- a/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -check: - @python3 tests/validate.py diff --git a/run_tests.sh b/run_tests.sh old mode 100644 new mode 100755 index 25c8a97..1b3fd7b --- a/run_tests.sh +++ b/run_tests.sh @@ -1,18 +1,28 @@ #!/bin/bash if [ -n "$REPO" -a -n "$BRANCH" ]; then -git remote rm proposed || true -git gc --auto -git remote add proposed "$REPO" -git fetch proposed -git checkout origin/master -git config --global user.email "noreply@ci.centos.org" -git config --global user.name "CentOS CI" -git merge --no-ff "proposed/$BRANCH" -m "Merge PR" + git config user.email "noreply@ci.centos.org" + git config user.name "CentOS CI" -echo "Running tests for branch $BRANCH of repo $REPO" -echo "Last commits:" -git log -2 + # Copy the original repository for comparisons + rm -Rf __baseline__ + git clone . __baseline__ + + # Merge the PR into the current tree + git remote rm proposed || true + git gc --auto + git remote add proposed "$REPO" + git fetch proposed + git checkout origin/master + git merge --no-ff "proposed/$BRANCH" -m "Merge PR" + + echo "Running tests for branch $BRANCH of repo $REPO" + echo "Last commits:" + git log -2 + + # Run any tests that only apply to PRs + tests/pr_tests.sh fi -make check +# Run any tests that apply to either PRs or commits +tests/common_tests.sh diff --git a/tests/common_tests.sh b/tests/common_tests.sh new file mode 100755 index 0000000..4ebae25 --- /dev/null +++ b/tests/common_tests.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +# Validate that all of the YAML documents are properly-named and have valid +# syntax. +python3 tests/validate.py diff --git a/tests/exclusions.txt b/tests/exclusions.txt index f111e68..9efd765 100644 --- a/tests/exclusions.txt +++ b/tests/exclusions.txt @@ -2,14 +2,16 @@ # Skip the CI integration bits .cico.pipeline +Dockerfile run_tests.sh -Makefile # Skip the README file README.md # Skip the validator files +tests/common_tests.sh tests/exclusions.txt +tests/pr_tests.sh tests/validate.py # Comment out the following when testing the validator @@ -19,4 +21,3 @@ tests/intents.yaml tests/missingstream.yaml tests/module.yaml tests/nodejs.yaml - diff --git a/tests/pr_tests.sh b/tests/pr_tests.sh new file mode 100755 index 0000000..49fbecb --- /dev/null +++ b/tests/pr_tests.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Tests in this file may use the __baseline__ subdirectory in the git root if +# they need to compare the PR to its target branch.