default.yml 4.19 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
  DUMUX_REPO: "https://git.iws.uni-stuttgart.de/dumux-repositories/dumux.git"
16
  DUMUX_FOLDER: "dumux"
17
18
19
20
21
  MR_TARGET_BRANCH_NAME: ""
  DUMUX_MR_SOURCE_BRANCH: ""
  DUMUX_MR_TARGET_BRANCH: ""
  DUMUX_TRIGGER_COMMIT_SHA: ""
  DUMUX_TRIGGER_REF_SHA: ""
22

Dennis Gläser's avatar
Dennis Gläser committed
23
24
select tests:
  stage: configure
25
  before_script:
26
    - |
27
28
29
30
      if [ ! -d $DUMUX_FOLDER ]; then
          git clone -b master --depth 1 $DUMUX_REPO $DUMUX_FOLDER
      fi

31
32
33
34
35
      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"

36
          pushd $DUMUX_FOLDER
37
              git fetch --depth=1 origin ${DUMUX_MR_TARGET_BRANCH}:${DUMUX_MR_TARGET_BRANCH}
38
          popd
39

40
      else
41
          pushd $DUMUX_FOLDER
42
43
44
45
46
47
48
49
50
51
52
              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
53
      fi
54
    - dunecontrol --opts=$DUNE_OPTS_FILE --only=dumux all
55
  script:
56
    - dunecontrol --opts=$DUNE_OPTS_FILE --current all
Dennis Gläser's avatar
Dennis Gläser committed
57
    - |
58
      if [[ -n "$DUMUX_MR_SOURCE_BRANCH" ]]; then
59
          CHECK_FOLDER=$DUMUX_FOLDER
60
61
          SOURCE_TREE=$DUMUX_MR_SOURCE_BRANCH
          TARGET_TREE=$DUMUX_MR_TARGET_BRANCH
62
      elif [[ -n "$DUMUX_TRIGGER_REF_SHA" ]]; then
63
          CHECK_FOLDER=$DUMUX_FOLDER
64
65
66
          SOURCE_TREE=$DUMUX_TRIGGER_COMMIT_SHA
          TARGET_TREE=$DUMUX_TRIGGER_REF_SHA
      elif [[ -n "$MR_TARGET_BRANCH_NAME" ]]; then
67
68
69
70
71
72
73
74
          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"
75
76
77
78
79
80
81
          python3 $DUMUX_FOLDER/bin/testing/getchangedfiles.py --folder $CHECK_FOLDER \
                                                               --source-tree $SOURCE_TREE \
                                                               --target-tree $TARGET_TREE \
                                                               --outfile changedfiles.txt
          python3 $DUMUX_FOLDER/bin/testing/findtests.py --outfile affectedtests.json \
                                                         --file-list changedfiles.txt \
                                                         --build-dir build-cmake
Dennis Gläser's avatar
Dennis Gläser committed
82
83
      else
          echo "Skipping test selection, build/test stages will consider all tests!"
84
          touch affectedtests.json
Dennis Gläser's avatar
Dennis Gläser committed
85
86
87
      fi
  artifacts:
    paths:
88
      - $DUMUX_FOLDER
Dennis Gläser's avatar
Dennis Gläser committed
89
90
91
92
93
94
95
96
97
98
      - build-cmake
      - affectedtests.json
    expire_in: 3 hours

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

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