#42 Run tests under docker.
Closed 6 years ago by sgallagh. Opened 6 years ago by sgallagh.
releng/ sgallagh/fedora-module-defaults f29-CI  into  master

file modified
+13 -22
@@ -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 {

- 

      }

  }

file added
+11
@@ -0,0 +1,11 @@ 

+ FROM registry.fedoraproject.org/fedora:rawhide

+ 

+ LABEL maintainer="Stephen Gallagher <sgallagh@redhat.com>"

+ 

+ RUN dnf -y --setopt=install_weak_deps=False install \

+         git-core \

+         make \

+         python3-libmodulemd \

+         python3-libmodulemd1 \

+         python3-GitPython \

+     && dnf -y clean all

file removed
-2
@@ -1,2 +0,0 @@ 

- check:

- 	@python3 tests/validate.py

file modified
+22 -12
@@ -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

@@ -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

file modified
+3 -2
@@ -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/missingstream.yaml

  tests/module.yaml

  tests/nodejs.yaml

- 

file added
+4
@@ -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.

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 sgallagh@redhat.com

Note: this will probably fail the existing CI, since I dropped the Makefile in favor of the two new test hooks. It's an unfortunate side-effect of the way Pagure's integration with Jenkins works; it won't recognize changes to the pipeline file from a PR.

Hopefully, going forward this new design should mean that is only an issue when we Branch a new Fedora, as updating the node label won't be reflected in the tests, but since we now run the ACTUAL tests under a docker image, it shouldn't matter that the node is still running on an older host OS.

Don't merge this just yet. I realized I want to make one additional change to handling PRs. Specifically that we want to ensure that we save the commit ID of the branch point so we can do comparisons, such as for the upcoming patch I'm working on to ensure that patches that change defaults update the modified value to avoid producing merge conflicts.

Pull-Request has been closed by sgallagh

6 years ago