-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
127 lines (115 loc) · 4.02 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
include:
- project: "GNOME/citemplates"
file: "flatpak/flatpak_ci_initiative.yml"
variables:
APP_ID: "dev.Cogitri.Health.Devel"
BUNDLE: "dev.Cogitri.Health.Devel.flatpak"
CI_IMAGE: "registry.gitlab.gnome.org/cogitri/health-ci-docker/health-ci:latest"
CONFIG_OPTS: "-Dprofile=development"
FLATPAK_IMAGE: "quay.io/gnome_infrastructure/gnome-runtime-images:gnome-47"
FLATPAK_MODULE: "health"
MANIFEST_PATH: "dev.Cogitri.Health.Devel.json"
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/release-tarballs/${CI_COMMIT_TAG}"
RUNTIME_REPO: "https://nightly.gnome.org/gnome-nightly.flatpakrepo"
TARBALL: "Health-${CI_COMMIT_TAG}.tar.xz"
stages:
- qa
- build
- deploy
- release-tarball
- release-upload
- release-fix-url
- release-publish
.flatpak-run:
image: "$FLATPAK_IMAGE"
interruptible: true
tags:
- flatpak
before_script:
- flatpak-builder --user --disable-rofiles-fuse --force-clean --keep-build-dirs --stop-at=${FLATPAK_MODULE} flatpak_app ${MANIFEST_PATH}
- flatpak build-finish --socket=x11 --share=network flatpak_app
fmt:
image: "rust:slim"
stage: qa
script:
# Create blank versions of our configured files
# so rustfmt does not yell about non-existent files or completely empty files
- echo -e "" >> src/config.rs
- rustup component add rustfmt
- rustc -Vv && cargo -Vv
- cargo fmt --version
- cargo fmt --all -- --color=always --check
gettext_check:
image: "$CI_IMAGE"
stage: qa
script:
- source $HOME/.cargo/env
- meson build
- ninja -C build potfiles-in
- git diff --quiet || (echo "Found new source files! Please run ninja -C build potfiles-in to regenerate POTFILES.in! Diff output $(git diff)" && exit 1)
- ninja -C build dev.Cogitri.Health-update-po
clippy:
extends: ".flatpak-run"
stage: build
script:
- ./.gitlab/ci/run-in-flatpak.sh cargo clippy -- -D warnings
tests:
extends: ".flatpak-run"
stage: build
script:
- ./.gitlab/ci/run-in-flatpak.sh cargo test
flatpak:
extends: ".flatpak"
stage: build
interruptible: true
image: "$FLATPAK_IMAGE"
variables:
# We run tests manually
RUN_TESTS: "0"
nightly:
stage: deploy
extends: ".publish_nightly"
dependencies: ["flatpak"]
needs: ["flatpak"]
pages:
image: "$CI_IMAGE"
stage: deploy
script:
- source $HOME/.cargo/env
- meson build
- cargo makedocs -i "health" -i "gio" -i "glib" -i "tracker-rs"
- rm -rf public
- mv target/doc/ public
artifacts:
paths:
- public
only:
- master
create-dist-tarball:
stage: release-tarball
extends: ".flatpak-run"
rules:
- if: $CI_COMMIT_TAG
tags:
- flatpak
script:
- ./.gitlab/ci/run-in-flatpak.sh meson dist --no-tests
- mv .flatpak-builder/build/${FLATPAK_MODULE}/_flatpak_build/meson-dist tarball
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file tarball/${TARBALL} ${PACKAGE_REGISTRY_URL}/${TARBALL}
# https://gitlab.com/gitlab-org/gitlab/-/issues/271534 The default URL needs authentication right now, which is less than optimal...
# Get the package_files ID instead and use that as download URL in the "release" step.
release:
stage: release-publish
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG
script:
- apk add curl jq
- |
export PACKAGE_ID=$(curl "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages?sort=desc" | jq -c .[0].id) \
&& export PACKAGE_DOWNLOAD_ID=$(curl "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/${PACKAGE_ID}/package_files" | jq -c .[0].id) \
&& export PACKAGE_DOWNLOAD_URL="${CI_PROJECT_URL}/-/package_files/${PACKAGE_DOWNLOAD_ID}/download" \
&& release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
--description "Please use the attached tarball \"${TARBALL}\", which vendors the required Rust dependencies and can be used to build Health without an internet connection." \
--assets-link "{\"name\":\"${TARBALL}\",\"url\":\"${PACKAGE_DOWNLOAD_URL}\"}"