.gitlab-ci.yml 2.52 KB
Newer Older
1
2
stages:
  - checkRepository
Administrator's avatar
Administrator committed
3
  - checkFormat
4
5
6

RebaseCheck:
  stage: checkRepository
7
  image: alpine
8
  tags:
9
    - docker
10
11
12
13
14
15
16
17
18
19
  only:
    refs:
      - merge_requests
    variables:
      - $CI_MERGE_REQUEST_PROJECT_PATH == "CbmSoft/cbmroot_parameter" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"
  script:
    # Get the upstream repository manually. I did not find any other way to have it for
    # comparison
    # Check if a rebase is needed
    # If a rebase is needed stop immediately
20
    - apk update && apk add git bash
Pierre-Alain Loizeau's avatar
Pierre-Alain Loizeau committed
21
    - ci_scripts/connect_upstream_repo.sh $CI_MERGE_REQUEST_PROJECT_URL
22
23
    - git fetch upstream
    - hash1=$(git show-ref upstream/master | cut -f1 -d' ')
24
    - hash2=$(git merge-base upstream/master HEAD)
25
26
27
28
29
30
31
32
33
34
35
36
37
    - echo "${hash1}"
    - echo "${hash2}"
    - if [ "${hash1}" = "${hash2}" ]; then
    -   echo "No rebase required"
    -   exit 0
    - else
    -   echo "The Merge Request is not up-to-date"
    -   echo "Rebase is required"
    -   exit 1
    - fi

LinearHistCheck:
  stage: checkRepository
38
  image: alpine
39
  tags:
40
    - docker
41
42
43
44
45
46
47
48
49
50
  only:
    refs:
      - merge_requests
    variables:
      - $CI_MERGE_REQUEST_PROJECT_PATH == "CbmSoft/cbmroot_parameter" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"
  script:
    # Get the upstream repository manually. I did not find any other way to have it for
    # comparison
    # Check if the history introduced by the MR is linear (no branch loop in fork)
    # If not linear stop immediately
51
    - apk update && apk add git bash
Pierre-Alain Loizeau's avatar
Pierre-Alain Loizeau committed
52
    - ci_scripts/connect_upstream_repo.sh $CI_MERGE_REQUEST_PROJECT_URL
53
54
55
56
57
58
59
60
61
62
63
    - git fetch upstream
    - count=$(git rev-list --min-parents=2 --count upstream/master..HEAD)
    - echo "${count}"
    - if [ 0 = "${count}" ]; then
    -   echo "History introduced in fork is linear"
    -   exit 0
    - else
    -   echo "History introduced in fork is not linear"
    -   echo "${count} merge commits must be removed or the other new commits have to be replayed in a new branch"
    -   exit 1
    - fi
Administrator's avatar
Administrator committed
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

FileFormatCheck:
  stage: checkFormat
  image: alpine
  tags:
    - docker
  only:
    refs:
      - merge_requests
    variables:
      - $CI_MERGE_REQUEST_PROJECT_PATH == "CbmSoft/cbmroot_parameter" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"
  script:
    # Get the upstream repository manually. I did not find any other way to have it for
    # comparison
    - apk update && apk add git bash file
    - ci_scripts/connect_upstream_repo.sh $CI_MERGE_REQUEST_PROJECT_URL
    - git fetch upstream
    - ci_scripts/check-file-format.sh upstream