default.yml 3.87 KB
Newer Older
Dennis Gläser's avatar
Dennis Gläser committed
1
2
3
4
default:
  image: $IMAGE

stages:
5
  - configure
Dennis Gläser's avatar
Dennis Gläser committed
6
7
8
9
10
11
12
  - build
  - test

workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE=="parent_pipeline"

13
# variables that should be overwritten by the trigger
14
variables:
15
  TRIGGER_SOURCE: "undefined"
16
  COMMIT_BRANCH: "undefined"
17
  MR_TARGET_BRANCH_NAME: "undefined"
18
19
20
21

select tests:
  stage: configure
  script:
22
    - dunecontrol --opts=$DUNE_OPTS_FILE --current all
23
24
    - |
      if [[ "$TRIGGER_SOURCE" == "merge_request_event" ]]; then
25
          echo "Detecting changes w.r.t to target branch '$MR_TARGET_BRANCH_NAME'"
26
27
28
29
30
31
32
33
34
35
36
          python3 bin/testing/getchangedfiles.py --outfile changedfiles.txt \
                                                 --target.tree origin/$MR_TARGET_BRANCH_NAME
          python3 bin/testing/findtests.py --outfile affectedtests.json \
                                           --file-list changedfiles.txt \
                                           --build-dir build-cmake

      elif [[ "$TRIGGER_SOURCE" == "schedule" ]]; then
          echo "Starting scheduled pipeline"
          echo "Skipping test selection, build/test stages will consider all tests!"
          touch affectedtests.json

37
38
      elif [ -n $TEST_AGAINST_LAST_SUCCESSFUL ]; then
          echo "Determining sha of the last successful pipeline to test against"
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
          curl --header --form "token=$CI_JOB_TOKEN" \
                        "https://git.iws.uni-stuttgart.de/api/v4/projects/31/pipelines/?status=success" \
                        > pipeline_status.json

          if ! python3 .gitlab-ci/getpipelineinfo.py --status-file pipeline_status.json \
                                                     --look-for latest \
                                                     --print-format commit-sha; then
              echo "Could not find a successful pipeline, will build/run all tests"
              touch affectedtests.json
          else
              export COMMIT_SHA=$(python3 .gitlab-ci/getpipelineinfo.py --status-file pipeline_status.json \
                                                                        --look-for latest \
                                                                        --print-format commit-sha)
              echo "Comparing against sha $COMMIT_SHA"
              python3 bin/testing/getchangedfiles.py --outfile changedfiles.txt \
                                                     --source-tree HEAD \
                                                     --target-tree $COMMIT_SHA
              python3 bin/testing/findtests.py --outfile affectedtests.json \
                                               --file-list changedfiles.txt \
                                               --build-dir build-cmake
          fi

61
      else
62
          echo "Unknown pipeline trigger event"
63
          echo "Skipping test selection, build/test stages will consider all tests!"
64
          touch affectedtests.json
65
66
67
      fi
  artifacts:
    paths:
68
      - build-cmake
69
70
71
      - affectedtests.json
    expire_in: 3 hours

Dennis Gläser's avatar
Dennis Gläser committed
72
73
74
build dumux:
  stage: build
  script:
75
76
    - |
      pushd build-cmake
77
78
        make clean && make all
        if [ -s ../affectedtests.json ]; then
79
80
81
82
83
          python3 ../bin/testing/runselectedtests.py -c ../affectedtests.json -b
        else
          python3 ../bin/testing/runselectedtests.py --all -b
        fi
      popd
Dennis Gläser's avatar
Dennis Gläser committed
84
85
86
  artifacts:
    paths:
      - build-cmake
87
      - affectedtests.json
Dennis Gläser's avatar
Dennis Gläser committed
88
    expire_in: 3 hours
89
90
91
  needs:
    - job: select tests
      artifacts: true
Dennis Gläser's avatar
Dennis Gläser committed
92
93
94

test dumux:
  stage: test
95
96
97
  variables:
    OMPI_ALLOW_RUN_AS_ROOT: 1
    OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1
Dennis Gläser's avatar
Dennis Gläser committed
98
  script:
99
100
    - |
      pushd build-cmake
101
        if [ -s ../affectedtests.json ]; then
102
103
104
105
106
          python3 ../bin/testing/runselectedtests.py -c ../affectedtests.json -t
        else
          python3 ../bin/testing/runselectedtests.py --all -t
        fi
      popd
Dennis Gläser's avatar
Dennis Gläser committed
107
108
109
110
111
112
  needs:
    - job: build dumux
      artifacts: true
  artifacts:
    reports:
      junit: junit/dumux-cmake.xml