default.yml 4.05 KB
Newer Older
1
2
3
4
default:
  image: $IMAGE

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

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

13
# variables that may be overwritten by the trigger
14
variables:
15
16
17
18
19
20
  DUMUX_REPO: "https://git.iws.uni-stuttgart.de/dumux-repositories/dumux.git"
  MR_TARGET_BRANCH_NAME: ""
  DUMUX_MR_SOURCE_BRANCH: ""
  DUMUX_MR_TARGET_BRANCH: ""
  DUMUX_TRIGGER_COMMIT_SHA: ""
  DUMUX_TRIGGER_REF_SHA: ""
21

Dennis Gläser's avatar
Dennis Gläser committed
22
23
select tests:
  stage: configure
24
  before_script:
25
    - |
26
27
28
29
30
31
      if [[ -n "$DUMUX_MR_SOURCE_BRANCH" ]]; then
          echo "Fetching upstream branches related to merge request."
          echo "Source branch: $DUMUX_MR_SOURCE_BRANCH"
          echo "Target branch: $DUMUX_MR_TARGET_BRANCH"

          git clone -b ${DUMUX_MR_TARGET_BRANCH} --depth 1 $DUMUX_REPO
32
          pushd dumux
33
              git fetch --depth=1 origin ${DUMUX_MR_SOURCE_BRANCH}:${DUMUX_MR_SOURCE_BRANCH}
34
          popd
35

36
      else
37
38
39
40
41
42
43
44
45
46
47
48
49
50
          git clone -b master --depth 1 $DUMUX_REPO

          pushd dumux
              if [[ -n "$DUMUX_TRIGGER_COMMIT_SHA" ]]; then
                  echo "Fetching upstream commit $DUMUX_TRIGGER_COMMIT_SHA"
                  git fetch --depth=1 origin ${DUMUX_TRIGGER_COMMIT_SHA}
                  git checkout ${DUMUX_TRIGGER_COMMIT_SHA}
              fi

              if [[ -n "$DUMUX_TRIGGER_REF_SHA" ]]; then
                  echo "Fetching upstream reference commit $DUMUX_TRIGGER_REF_SHA"
                  git fetch --depth=1 origin ${DUMUX_TRIGGER_REF_SHA}
              fi
          popd
51
      fi
52
    - dunecontrol --opts=$DUNE_OPTS_FILE --only=dumux all
53
  script:
54
    - dunecontrol --opts=$DUNE_OPTS_FILE --current all
Dennis Gläser's avatar
Dennis Gläser committed
55
    - |
56
      if [[ -n "$DUMUX_MR_SOURCE_BRANCH" ]]; then
57
          CHECK_FOLDER="dumux"
58
59
          SOURCE_TREE=$DUMUX_MR_SOURCE_BRANCH
          TARGET_TREE=$DUMUX_MR_TARGET_BRANCH
60
61
62
63
64
      elif [[ -n "$DUMUX_TRIGGER_REF_SHA" ]]; then
          CHECK_FOLDER="dumux"
          SOURCE_TREE=$DUMUX_TRIGGER_COMMIT_SHA
          TARGET_TREE=$DUMUX_TRIGGER_REF_SHA
      elif [[ -n "$MR_TARGET_BRANCH_NAME" ]]; then
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
          CHECK_FOLDER="."
          SOURCE_TREE="HEAD"
          TARGET_TREE=origin/$MR_TARGET_BRANCH_NAME
      fi
    - |
      if [[ -n "$SOURCE_TREE" ]]; then
          echo "Detecting tests affected by changes in folder $CHECK_FOLDER,"
          echo "using source/target trees: $SOURCE_TREE / $TARGET_TREE"
          python3 dumux/bin/testing/getchangedfiles.py --folder $CHECK_FOLDER \
                                                       --source-tree $SOURCE_TREE \
                                                       --target-tree $TARGET_TREE \
                                                       --outfile changedfiles.txt
          python3 dumux/bin/testing/findtests.py --outfile affectedtests.json \
                                                 --file-list changedfiles.txt \
                                                 --build-dir build-cmake
Dennis Gläser's avatar
Dennis Gläser committed
80
81
      else
          echo "Skipping test selection, build/test stages will consider all tests!"
82
          touch affectedtests.json
Dennis Gläser's avatar
Dennis Gläser committed
83
84
85
86
87
88
89
90
91
92
93
94
95
96
      fi
  artifacts:
    paths:
      - dumux
      - build-cmake
      - affectedtests.json
    expire_in: 3 hours

build lecture:
  stage: build
  script:
    - |
      pushd build-cmake
        make clean
97
        if [ -s ../affectedtests.json ]; then
Dennis Gläser's avatar
Dennis Gläser committed
98
99
100
101
102
          python3 ../dumux/bin/testing/runselectedtests.py -c ../affectedtests.json -b
        else
          python3 ../dumux/bin/testing/runselectedtests.py --all -b
        fi
      popd
103
104
105
  artifacts:
    paths:
      - build-cmake
106
      - dumux
Dennis Gläser's avatar
Dennis Gläser committed
107
      - affectedtests.json
108
109
110
111
    expire_in: 3 hours

test lecture:
  stage: test
Dennis Gläser's avatar
Dennis Gläser committed
112
113
114
  variables:
    OMPI_ALLOW_RUN_AS_ROOT: 1
    OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1
115
  script:
Dennis Gläser's avatar
Dennis Gläser committed
116
117
    - |
      pushd build-cmake
118
        if [ -s ../affectedtests.json ]; then
Dennis Gläser's avatar
Dennis Gläser committed
119
120
121
122
123
          python3 ../dumux/bin/testing/runselectedtests.py -c ../affectedtests.json -t
        else
          python3 ../dumux/bin/testing/runselectedtests.py --all -t
        fi
      popd
124
125
126
  needs:
    - job: build lecture
      artifacts: true
127
128
129
  artifacts:
    reports:
      junit: junit/dumux-lecture-cmake.xml