-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
168 lines (151 loc) · 5.87 KB
/
.gitlab-ci.yml
File metadata and controls
168 lines (151 loc) · 5.87 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# Cache registry and compiled Julia files, mainly to avoid recompilating
# everything every time we run the tests and docs. This should be extended
# (using `extends`) by all jobs which want to use the cache.
#
# To allow all branches to use the same cache, one needs to modify the project settings on Gitlab.
# See https://docs.gitlab.com/ee/ci/caching/#use-the-same-cache-for-all-branches.
.julia-cache:
before_script:
# This is needed for caching Julia files (compilation, ...), since caching
# can only be done if the files are in the project directory.
- export JULIA_DEPOT_PATH=.julia
- mkdir -pv $JULIA_DEPOT_PATH
- export JULIA_NUM_THREADS=1 # using more than 1 thread is slower in the CI machines (probably because there are other CI processes running!)
- export JULIA_NUM_PRECOMPILE_TASKS=1
- export JULIA_ENABLE_JET_KA_TESTS=false # disable JET.jl tests involving KernelAbstractions kernels (they generally fail...)
cache:
key: julia-cache
paths:
- .julia/artifacts
- .julia/packages
- .julia/registries
- .julia/compiled
- .julia/scratchspaces
- .julia/logs
.test_template:
stage: test
extends:
- .julia-cache
rules:
# Only run tests if source files were modified, or if we're on the main branch
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
script:
- echo "JULIA_NUM_THREADS = $JULIA_NUM_THREADS"
- echo "JULIA_NUM_PRECOMPILE_TASKS = $JULIA_NUM_PRECOMPILE_TASKS"
- du -shc $JULIA_DEPOT_PATH/* || true # adapted from julia-actions/cache on github
- echo ""
- |
julia --heap-size-hint=800M --project -e '
using Pkg
Pkg.precompile(; timing = true)
Pkg.instantiate()
Pkg.build()
Pkg.test(coverage = true)
'
after_script:
- |
julia --heap-size-hint=800M --project=coverage -e '
using Pkg
Pkg.add("Coverage")
using Coverage
coverage = process_folder("src")
coverage = append!(coverage, process_folder("ext"))
cl, tl = get_summary(coverage)
println(cl/tl*100, "% coverage")
LCOV.writefile("coverage.lcov", coverage)
'
# https://docs.gitlab.com/ee/ci/jobs/index.html#custom-collapsible-sections
- echo -e "\e[0Ksection_start:$(date +%s):apt-get[collapsed=true]\r\e[0KRunning apt-get install python3-pip pipx"
- apt-get update -qq && apt-get install -qq python3-pip pipx
- export PIPX_BIN_DIR=~/.local/bin # make sure that pipx-installed apps are in the path
- export PATH=$PIPX_BIN_DIR:$PATH
- echo -e "\e[0Ksection_end:`date +%s`:apt-get\r\e[0K"
# Install lcov 2.0 and its dependencies
- echo -e "\e[0Ksection_start:$(date +%s):lcov[collapsed=true]\r\e[0KInstalling lcov and dependencies"
- >
apt-get install -qq libcapture-tiny-perl libdatetime-perl libdevel-cover-perl
libdigest-md5-file-perl libfile-spec-native-perl libjson-xs-perl
libmemory-usage-perl libtime-hr-perl
- curl -OL https://github.com/linux-test-project/lcov/releases/download/v2.0/lcov-2.0.tar.gz
- tar xf lcov-2.0.tar.gz
- pushd lcov-2.0 && make install && popd
- lcov --version
- echo -e "\e[0Ksection_end:`date +%s`:lcov\r\e[0K"
# This is needed to convert LCOV coverage files to Cobertura format (used by gitlab)
# We use pipx instead of pip to avoid "externally-managed-environment" error since Debian Bookworm.
- echo -e "\e[0Ksection_start:$(date +%s):pip[collapsed=true]\r\e[0KRunning pipx install lcov_cobertura"
- pipx install lcov_cobertura
- echo -e "\e[0Ksection_end:`date +%s`:pip\r\e[0K"
- lcov_cobertura coverage.lcov -o coverage.xml
# Also write HTML report to lcov/ based on lcov files
- genhtml --no-function-coverage --legend -o lcov_html coverage.lcov # requires lcov package
coverage: '/^\d+.\d+% coverage/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
paths:
- coverage.lcov
- coverage.xml
- lcov_html
expire_in: 1 week
# Name a test and select an appropriate image.
# images comes from Docker hub
test:julia-latest:
image: julia:1.12
extends: .test_template
docs:
image: julia:1.12
stage: test
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # run on master branch
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' # run on merge requests
script:
- echo "JULIA_NUM_THREADS = $JULIA_NUM_THREADS"
- apt-get update -qq
- apt-get install -qq git # needed by Documenter
# This is to be able to render GLMakie figures on the server
# See https://github.com/MakieOrg/Makie.jl/blob/master/.github/workflows/glmakie.yaml
- apt-get install -qq xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev xsettingsd x11-xserver-utils
- |
DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --heap-size-hint=800M --project=docs -e '
using Pkg
Pkg.Registry.update()
Pkg.develop(path = ".")
Pkg.precompile(; timing = true)
Pkg.instantiate()
Pkg.build()
'
- DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --heap-size-hint=800M --project=docs --color=yes docs/make.jl
artifacts:
paths:
- docs/build
expire_in: 1 week
extends:
- .julia-cache
pages:
image: julia:1.12
stage: deploy
dependencies:
- test:julia-latest # use coverage from test:julia-latest (lcov_html)
- docs
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
artifacts:
paths:
- public
expire_in: 1 week
script:
- |
if [[ -d docs/build ]]; then
mv -v docs/build public
if [[ -d lcov_html ]]; then
mv -v lcov_html public/coverage
fi
fi
# deploy:
# stage: deploy
# script: echo "Define your deployment script!"
# environment: production