#4 Test commit
Opened 5 years ago by sgallagh. Modified 5 years ago
sgallagh/fedora-module-defaults-ci CI-test  into  master

file modified
+16 -22
@@ -1,28 +1,22 @@ 

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

+                     additionalBuildArgs "--pull --no-cache"

+                 }

+             }

+             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
+3 -1
@@ -2,8 +2,10 @@ 

  version: 1

  data:

      module: dwm

-     stream: 6.1

+     stream: 6.2

+     modified: 20180110

      profiles:

          6.0: [default]

          6.1: [default]

+         6.2: [default]

          latest: [default]

file modified
+3 -2
@@ -2,6 +2,7 @@ 

  version: 1

  data:

      module: gimp

-     stream: 2.10

+     stream: 2.12

+     modified: 201901151200

      profiles:

-         2.10: [default]

+         2.12: [default] 

\ No newline at end of file

file modified
+24 -12
@@ -1,18 +1,30 @@ 

  #!/bin/bash

  

+ set -e

+ 

  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"

+ 

+     # Save the commit ID of the baseline checkout

+     MODULE_DEFAULTS_TEST_BASELINE=$(git log -1 --pretty=%H)

+     export MODULE_DEFAULTS_TEST_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

  

- 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

@@ -0,0 +1,107 @@ 

+ #!/usr/bin/python3

+ 

+ import gi

+ import git

+ import os

+ import sys

+ 

+ from gi.repository import GLib

+ gi.require_version('Modulemd', '2.0')

+ from gi.repository import Modulemd

+ 

+ def print_failure(failure):

+     print("Error: %s" % failure.get_gerror())

+     print("Offending YAML: \n%s" % failure.get_yaml())

+ 

+ def unusable_baseline():

+     print("Baseline was unusable. Skipping test.")

+     return os.EX_OK

+ 

+ def get_index_and_defaults (repo, filename, commit):

+     try:

+         yaml = repo.git.show('%s:%s' % (commit, filename))

+     except git.exc.GitCommandError as e:

+         # This file didn't exist in the baseline commit, so just return

+         # success. If there's anything wrong with the new file, it will be

+         # caught in common_tests.sh

+         return 0

+ 

+     index = Modulemd.ModuleIndex.new()

+     try:

+         ret, failures = index.update_from_string(yaml, True)

+         if ret != True:

+             for failure in failures:

+                 print_failure (failure)

+             raise IOError("Invalid modulemd-defaults document")

+ 

+     except gi.repository.GLib.Error as e:

+         print ("Error: %s" % e)

+         raise IOError("Invalid YAML document")

+ 

+     module_names = index.get_module_names()

+     if len(module_names) > 1:

+         raise IOError("YAML contained multiple modules")

+     elif len(module_names) < 1:

+         raise IOError("YAML contained no modules")

+ 

+     defaults = index.get_module(index.get_module_names()[0]).get_defaults()

+     if not defaults:

+         raise IOError("YAML contained no defaults")

+ 

+     return index, defaults

+ 

+ def main():

+     os.putenv('G_MESSAGES_DEBUG', 'all')

+     filename = sys.argv[1]

+     baseline_commit = sys.argv[2]

+ 

+     script_dir = os.path.dirname(os.path.realpath(__file__))

+ 

+     repo = git.Repo(script_dir,

+                     search_parent_directories=True)

+ 

+     # First get the defaults from the baseline commit

+     try:

+         baseline_index, baseline_defaults = get_index_and_defaults (

+             repo, filename, baseline_commit)

+     except IOError as e:

+         # This should never happen, since the original files presumably have

+         # been validated previously (unless someone merged without checking

+         # the CI results on a PR). If this occurs, the failures will be in the

+         # logs and we'll assume that this PR is trying to fix it, which will

+         # be mostly handled in common_tests.sh.

+         print(e, file=sys.stderr)

+         return unusable_baseline()

+ 

+     try:

+         updated_commit = 'HEAD'

+         updated_index, updated_defaults = get_index_and_defaults (

+             repo, filename, updated_commit)

+     except IOError as e:

+         # If we hit this, the patch is broken.

+         print(e, file=sys.stderr)

+         return os.EX_DATAERR

+ 

+     if updated_defaults.get_modified() <= baseline_defaults.get_modified():

+         print ("%s has changed but the 'modified' field has not increased." %

+                filename)

+         print ("Baseline modified: %d", baseline_defaults.get_modified())

+         print ("Updated modified: %d", updated_defaults.get_modified())

+         return os.EX_DATAERR

+ 

+     # Confirm that these two sets of defaults merge cleanly

+     merger = Modulemd.ModuleIndexMerger.new()

+     merger.associate_index(baseline_index, 0)

+     merger.associate_index(baseline_index, 0)

+ 

+     try:

+         merger.resolve()

+     except gi.repository.GLib.Error as e:

+         print ("Merge Error: %s" % e, file=sys.stderr)

+         return os.EX_DATAERR

+ 

+     return os.EX_OK

+ 

+ if __name__ == "__main__":

+     sys.exit(main())

+ 

file modified
+4 -2
@@ -2,14 +2,17 @@ 

  

  # 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/compare_defaults.py

  tests/exclusions.txt

+ tests/pr_tests.sh

  tests/validate.py

  

  # Comment out the following when testing the validator
@@ -19,4 +22,3 @@ 

  tests/missingstream.yaml

  tests/module.yaml

  tests/nodejs.yaml

- 

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

+ #!/bin/bash

+ 

+ set -e

+ 

+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

+ 

+ # Tests in this path may read the environment variable

+ # MODULE_DEFAULTS_TEST_BASELINE which specifies the commit ID that this PR has

+ # been applied atop.

+ 

+ # Set the $CWD to the root of this repo

+ GIT_ROOT=$(git rev-parse --show-toplevel)

+ pushd $GIT_ROOT

+ 

+ # Get a list of changed files

+ modified_files=$(git log --name-only \

+                          --pretty=oneline \

+                          --full-index \

+                          $MODULE_DEFAULTS_TEST_BASELINE..HEAD \

+                   | grep -vE '^[0-9a-f]{40} ' | sort -u)

+ 

+ for file in ${modified_files[@]}; do

+     if [[ $file == *".yaml" ]]; then

+         $SCRIPT_DIR/compare_defaults.py $file $MODULE_DEFAULTS_TEST_BASELINE

+     fi

+ done

+ 

+ popd

file modified
+3 -1
@@ -10,6 +10,8 @@ 

  gi.require_version('Modulemd', '1.0')

  from gi.repository import Modulemd

  

+ # Useless comment to test filtering

+ 

  def do_validate(filename):

      # Valid filenames must end in ".yaml" to be properly included by Pungi

      if not filename.endswith(".yaml"):
@@ -137,4 +139,4 @@ 

      return result

  

  if __name__ == "__main__":

-     sys.exit(main()) 

\ No newline at end of file

+     sys.exit(main())

pretty please pagure-ci rebuild

5 years ago

pretty please pagure-ci rebuild

5 years ago

pretty please pagure-ci rebuild

5 years ago

pretty please pagure-ci rebuild

5 years ago

pretty please pagure-ci rebuild

5 years ago

pretty please pagure-ci rebuild

5 years ago

rebased onto ef3d54f

5 years ago

pretty please pagure-ci rebuild

5 years ago

pretty please pagure-ci rebuild

5 years ago

pretty please pagure-ci rebuild

5 years ago

rebased onto 37e4519

5 years ago

pretty please pagure-ci rebuild

5 years ago

rebased onto cef8d36

5 years ago

pretty please pagure-ci rebuild

5 years ago

rebased onto ecc1788

5 years ago

rebased onto 8e64e49

5 years ago

rebased onto b12d531

5 years ago

rebased onto 63e3f15

5 years ago

rebased onto 012d6ca

5 years ago

rebased onto 55c2074

5 years ago

pretty please pagure-ci rebuild

5 years ago

rebased onto 86c02ae

5 years ago

rebased onto 7efeaa7

5 years ago

pretty please pagure-ci rebuild

5 years ago

rebased onto 2737577

5 years ago

rebased onto daf655a

5 years ago
Metadata
Flags
jenkins #94
failure
Build failed (commit: 27375773)
5 years ago
jenkins #92
success (100%)
Build successful (commit: 27375773)
5 years ago
jenkins #87
failure
Build failed (commit: 86c02ae5)
5 years ago
jenkins #85
failure
Build failed (commit: 55c2074b)
5 years ago
jenkins #84
failure
Build failed (commit: 55c2074b)
5 years ago
jenkins #79
failure
Build failed (commit: 63e3f155)
5 years ago
jenkins #75
success (100%)
Build successful (commit: b12d5315)
5 years ago
jenkins #73
success (100%)
Build successful (commit: 8e64e49d)
5 years ago
jenkins #71
failure
Build failed (commit: ecc1788e)
5 years ago
jenkins #69
success (100%)
Build successful (commit: cef8d36e)
5 years ago
jenkins #68
success (100%)
Build successful (commit: cef8d36e)
5 years ago
jenkins #67
failure
Build failed (commit: 75441ba0)
5 years ago
jenkins #66
failure
Build failed (commit: 75441ba0)
5 years ago
jenkins #64
success (100%)
Build successful (commit: 75441ba0)
5 years ago
jenkins #63
success (100%)
Build successful (commit: 75441ba0)
5 years ago
jenkins #62
success (100%)
Build successful (commit: 75441ba0)
5 years ago
jenkins #60
success (100%)
Build successful (commit: 75441ba0)
5 years ago
jenkins #59
success (100%)
Build successful (commit: 75441ba0)
5 years ago
jenkins #57
failure
Build failed (commit: 75441ba0)
5 years ago
jenkins #56
success (100%)
Build successful (commit: 75441ba0)
5 years ago
jenkins #54
success (100%)
Build successful (commit: 75441ba0)
5 years ago
jenkins #53
success (100%)
Build successful (commit: 75441ba0)
5 years ago