.gitlab-ci.yml 5.23 KB
Newer Older
1
stages:
2
3
4
  - verify
  - visualize
  - deploy
Guilhem Bonnefille's avatar
Guilhem Bonnefille committed
5
  - release
6

7
8
default:
  # Default image
9
  image: registry.orekit.org/orekit/ci-utils/maven:3.6.2-jdk-8-slim
10
11
12
13
14
  # Cache downloaded dependencies and plugins between builds.
  # To keep cache across branches add 'key: "$CI_JOB_REF_NAME"'
  cache:
    paths:
      - .m2/repository
15
16

variables:
17
  # This will suppress any download for dependencies and plugins or upload
18
19
20
  # messages which would clutter the console log. `showDateTime` will show the
  # passed time in milliseconds. You need to specify `--batch-mode` to make
  # this work.
21
  MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
22
23
24
25
26
  # As of Maven 3.3.0 instead of this you may define these options in
  # `.mvn/maven.config` so the same config is used when running from the
  # command line.
  # `installAtEnd` and `deployAtEnd` are only effective with recent version of
  # the corresponding plugins.
Guilhem Bonnefille's avatar
Guilhem Bonnefille committed
27
  MAVEN_CLI_OPTS: "-s .CI/maven-settings.xml --batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
28
29
  SONAR_PROJECT_KEY: "${CI_PROJECT_NAMESPACE}:${CI_PROJECT_NAME}"
  SONAR_PROJECT_NAME: "${CI_PROJECT_TITLE} (${CI_PROJECT_NAMESPACE}:${CI_PROJECT_NAME})"
30
31
32
33

verify:
  stage: verify
  script:
Evan Ward's avatar
Evan Ward committed
34
    - mvn $MAVEN_CLI_OPTS checkstyle:check verify site
35
    - test -z "$SONAR_TOKEN" || mvn $MAVEN_CLI_OPTS sonar:sonar
36
37
38
39
          -Dsonar.login=${SONAR_TOKEN}
          -Dsonar.branch.name=${CI_COMMIT_REF_NAME}
          -Dsonar.projectKey="$SONAR_PROJECT_KEY"
          -Dsonar.projectName="$SONAR_PROJECT_NAME"
40
41
42
  artifacts:
    paths:
      - target/*.jar
43
      - target/site
44
45
46
47
    reports:
      junit:
        - target/surefire-reports/*.xml

48
49
50
verify:warning:
  stage: verify
  script:
Sébastien Dinot's avatar
Sébastien Dinot committed
51
52
    - echo "Please, configure SonarQube by following steps described in the contribution guide:"
    - echo "https://www.orekit.org/site-orekit-development/contributing.html"
53
54
55
56
57
    - exit 1
  allow_failure: true
  rules:
    - if: $SONAR_TOKEN == null

58
59
60
61
62
# Convert and import in GitLab coverage data.
# The information is then available directly in merge-request view.
# Cf. https://docs.gitlab.com/ee/user/project/merge_requests/test_coverage_visualization.html
coverage-import:
  stage: visualize
63
  image: haynes/jacoco2cobertura:1.0.8
64
  script:
65
66
    # Display total coverage
    - "grep -o '<tfoot.*tfoot>' target/site/jacoco/index.html | sed 's:<[^>]*>: :g'"
67
    # Convert report from jacoco to cobertura
68
    - 'python /opt/cover2cover.py target/site/jacoco/jacoco.xml src/main/java > target/site/cobertura.xml'
69
    # Read the <source></source> tag and prepend the path to every filename
70
    # attribute
71
72
73
74
75
76
77
    - 'python /opt/source2filename.py target/site/cobertura.xml'
  needs:
    - verify
  dependencies:
    - verify
  artifacts:
    reports:
78
79
80
      coverage_report:
        coverage_format: cobertura
        path: target/site/cobertura.xml
81
  coverage: '/Total.*?([0-9]{1,3})%/'
82

83
84
85
86
87
88
89
90
91
92
93
changelog:
  stage: verify
  image: alpine:latest
  before_script:
    - apk add libxslt
  script:
    - xsltproc .CI/changes2release.xsl src/changes/changes.xml > CHANGELOG.md
  artifacts:
    paths:
      - CHANGELOG.md

94
95
# On main branches (develop, release-*, master) the produced artifacts are
# deployed on the Nexus of the project (https://packages.orekit.org/)
96
deploy:artifacts:
Guilhem Bonnefille's avatar
Guilhem Bonnefille committed
97
  stage: deploy
98
  script:
99
    - mvn $MAVEN_CLI_OPTS javadoc:jar source:jar deploy -DskipTests=true -Pci-deploy
Guilhem Bonnefille's avatar
Guilhem Bonnefille committed
100
101
  artifacts:
    paths:
Guilhem Bonnefille's avatar
Guilhem Bonnefille committed
102
      - target/*.jar
103
  only:
104
105
106
    - develop@orekit/orekit
    - /^release-[.0-9]+$/@orekit/orekit
    - master@orekit/orekit
107
108
109
110

deploy:site:
  stage: deploy
  before_script:
111
112
113
114
    # Create the SSH directory and give it the right permissions
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - echo "$SSH_SECRET_KEY" > ~/.ssh/id_website
115
    - chmod 600 ~/.ssh/id_website
116

117
118
    # Add known hosts
    - cp $SSH_KNOWN_HOSTS ~/.ssh/known_hosts
119
  script:
120
    - mvn $MAVEN_CLI_OPTS site:deploy
121
  only:
122
123
124
    - master@orekit/orekit
    - /^release-[.0-9]+$/@orekit/orekit
    - develop@orekit/orekit
125
126
127
128
129

# trigger performance tests after artifacts are deployed to Nexus
# similar to Jenkins' "build after a snapshot dependency is built"
performance:
  stage: deploy
130
131
  # don't fail the build if this doesn't work
  allow_failure: true
132
133
134
135
136
137
  needs:
    - job: deploy:artifacts
      artifacts: false
  trigger: evanward1/orekit-performance
  only:
    - develop@orekit/orekit
138
139
140
141

release:
  stage: release
  image: registry.gitlab.com/gitlab-org/release-cli:latest
142
143
  script:
    - cat CHANGELOG.md
144
145
146
147
148
149
150
151
152
153
154
  release:
    tag_name: $CI_COMMIT_TAG
    description: './CHANGELOG.md'
    assets:
      links:
        - name: orekit-${CI_COMMIT_TAG}.jar
          url: https://packages.orekit.org/repository/maven-releases/org/orekit/orekit/${CI_COMMIT_TAG}/orekit-${CI_COMMIT_TAG}.jar
        - name: orekit-${CI_COMMIT_TAG}-javadoc.jar
          url: https://packages.orekit.org/repository/maven-releases/org/orekit/orekit/${CI_COMMIT_TAG}/orekit-${CI_COMMIT_TAG}-javadoc.jar
        - name: orekit-${CI_COMMIT_TAG}-sources.jar
          url: https://packages.orekit.org/repository/maven-releases/org/orekit/orekit/${CI_COMMIT_TAG}/orekit-${CI_COMMIT_TAG}-sources.jar
155
156
  rules:
    - if: '$CI_COMMIT_TAG =~ /^[.0-9]+$/'