default.yml 4.23 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"
Dennis Gläser's avatar
Dennis Gläser committed
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
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"

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

37
      else
38
39
          git clone -b master --depth 1 $DUMUX_REPO $DUMUX_FOLDER

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

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

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