-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
139 lines (133 loc) · 4.91 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# SPDX-FileCopyrightText: 2023 Antoine Belvire
# SPDX-License-Identifier: GPL-3.0-or-later
variables:
GIT_SUBMODULE_STRATEGY: normal
# Include only Crossword Composer submodule, LibreOffice dictionaries are not required for build
GIT_SUBMODULE_PATHS: croiseur-solver/croiseur-solver-paulgb/crossword-composer
# For Linux builds, use a tailored image derived from a minimal openSUSE Tumbleweed image, built via the openSUSE Build Platform.
# See https://build.opensuse.org/package/show/home:1Antoine1:croiseur:head/croiseur-build-platform.
LINUX_IMAGE: registry.opensuse.org/home/1antoine1/croiseur/head/tumbleweed_containers/opensuse/croiseur-build-platform:27.1
stages:
- build
- publish
- pages
##
# Builds croiseur on a Linux machine.
#
Build on Linux:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes: [ "**/src/**/*", "**/*.gradle.kts", "**/*.versions.toml", "**/Cargo.toml", ".gitlab-ci.yml" ] # Build only if code/build scripts have changed
image: $LINUX_IMAGE
stage: build
coverage: '/Total.*?([0-9]{1,3})%/'
before_script:
# Choose wisely cargo and gradle homes so that they can easily be cached later
- export CARGO_HOME="$(pwd)/.cargo"
- export GRADLE_USER_HOME="$(pwd)/.gradle"
script:
- reuse lint
- gradle spotlessCheck
- gradle assemble -x distZip
- gradle check -x croiseur-gui:croiseur-gui-tests:test
- gradle croiseur-gui:croiseur-gui-tests:test
- gradle croiseur-tests-coverage:testCodeCoverageReport
# For total coverage: Display html report so that Gitlab can parse it (using the coverage regex defined above).
- cat croiseur-tests-coverage/build/reports/jacoco/testCodeCoverageReport/html/index.html
cache:
key: "${CI_COMMIT_REF_NAME}-linux"
fallback_keys: [ master-cache-linux ] # Use master cache for first build on branch
paths:
# Gradle caches
- .gradle
# Cargo caches
- "**/target"
- .cargo
artifacts:
reports:
junit: "**/TEST-*.xml"
coverage_report:
coverage_format: jacoco
path: "croiseur-tests-coverage/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml"
##
# Builds croiseur on a Windows machine.
# Very slow so no automatic trigger, but build can be launched manually.
#
Build on Windows:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes: [ "**/src/**/*", "**/*.gradle.kts", "**/*.versions.toml", "**/Cargo.toml", ".gitlab-ci.yml" ] # Build only if code/build scripts have changed
when: manual
allow_failure: true
stage: build
tags: [ windows ]
before_script:
# To be eventually extracted to build a dedicated image, too many limitations on Gitlab side for now
- choco install -y temurin21 --params="/ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJavaHome"
- choco install -y gradle
- choco install -y rust
- Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
- refreshenv
# Use sparse protocol for faster crate index construction
- $env:CARGO_REGISTRIES_CRATES_IO_PROTOCOL="sparse"
# Choose wisely cargo and gradle homes so that they can easily be cached later
- $env:CARGO_HOME=(Get-Location).Path + "\.cargo"
- $env:GRADLE_USER_HOME=(Get-Location).Path + "\.gradle"
script:
# Disable Gradle daemon: It prevents the script to be considered as terminated on Windows
- gradle --no-daemon assemble -x distZip
- gradle --no-daemon check -x croiseur-gui:croiseur-gui-tests:test
cache:
key: "${CI_COMMIT_REF_NAME}-windows"
paths:
# Gradle caches
- .gradle
# Cargo caches
- "**/target"
- .cargo
artifacts:
reports:
junit: "**/TEST-*.xml"
##
# Publishes a portable Linux distribution of croiseur.
# Slow, only run on master branch.
#
Publish Linux Distribution:
rules: [ if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH ]
stage: publish
image: $LINUX_IMAGE
coverage: '/Total.*?([0-9]{1,3})%/'
before_script:
- export CARGO_HOME="$(pwd)/.cargo"
- export GRADLE_USER_HOME="$(pwd)/.gradle"
script:
- gradle croiseur-tests-coverage:testCodeCoverageReport
- cat croiseur-tests-coverage/build/reports/jacoco/testCodeCoverageReport/html/index.html
- gradle distZip
- gradle publish -Pcroiseur.maven.token.name="Job-Token" -Pcroiseur.maven.token.value="${CI_JOB_TOKEN}"
# Javadoc for consumption by page job, which needs to be separate
- ./doc/scripts/javadoc.sh
cache:
key: master-cache-linux
paths:
# Gradle caches
- .gradle
# Cargo caches
- "**/target"
- .cargo
artifacts:
paths:
- javadoc
- "croiseur-cli/build/distributions/croiseur-cli*.zip"
- "croiseur-gui/croiseur-gui/build/distributions/croiseur-gui*.zip"
##
# Publish Javadoc as Gitlab pages.
#
pages:
rules: [ if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH ]
image: busybox:latest
stage: pages
script:
- mv javadoc public
artifacts:
paths: [ public ]