-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
110 lines (99 loc) · 3.03 KB
/
.gitlab-ci.yml
File metadata and controls
110 lines (99 loc) · 3.03 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
stages:
- lint
- test
- package
variables:
GIT_DEPTH: 1
CARGO_TERM_COLOR: always
NIX_CONFIG: "experimental-features = nix-command flakes"
CARGO_HOME: ${CI_PROJECT_DIR}/.cargo
RUSTC_WRAPPER: sccache
SCCACHE_DIR: ${CI_PROJECT_DIR}/.cache/sccache
.nix_rust_template: &nix_rust_template
image: nixos/nix:2.24.11
before_script:
- nix --version
- nix flake metadata
- nix develop --accept-flake-config -c treefmt --version
cache:
key:
files:
- Cargo.lock
prefix: cargo-shared
paths:
- .cargo/registry/cache
- .cargo/registry/index
- .cargo/git/db
- .cache/sccache
- target/
policy: pull-push
.rules_first_party:
rules: &rules_first_party
- changes:
- src/**/*
- crates/**/*
- tests/**/*
- docs/**/*
- utils/docs/**/*
- Cargo.toml
- Cargo.lock
- flake.nix
- flake.lock
- nix/**/*
- .pre-commit-config.yaml
- .gitlab-ci.yml
- when: never
# ── lint stage (fmt + clippy run in parallel) ──────────────────────────
fmt:rust:
<<: *nix_rust_template
stage: lint
rules: *rules_first_party
before_script:
- nix --version
cache: {} # fmt only needs rustfmt from nix, no cargo artifacts
script:
- nix develop --accept-flake-config -c cargo fmt --all --check
# clippy is a strict superset of `cargo check`, so a separate check job
# is redundant. --all-targets already covers lib, bins, tests, examples.
lint:clippy:
<<: *nix_rust_template
stage: lint
rules: *rules_first_party
script:
- nix develop --accept-flake-config -c cargo clippy --all-targets --no-deps
# validates mdx links and builds docs data.json - runs on MRs to catch broken links
docs:validate:
<<: *nix_rust_template
stage: lint
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
changes:
- docs/**/*
- utils/docs/**/*
- when: never
before_script: []
cache: {} # no cargo cache needed
script:
- nix develop --accept-flake-config -c python utils/docs/validate.py
# ── test stage (runs in parallel with nothing blocking it after lint) ──
test:all-targets:
<<: *nix_rust_template
stage: test
rules: *rules_first_party
script:
- nix develop --accept-flake-config -c cargo test --all-targets
# ── package stage ──────────────────────────────────────────────────────
package:nix:
<<: *nix_rust_template
stage: package
rules: *rules_first_party
script:
- |
if [ -n "${CACHIX_CACHE:-}" ]; then
nix shell nixpkgs#cachix -c cachix use "$CACHIX_CACHE"
fi
- nix build --accept-flake-config --print-build-logs .#default
- |
if [ -n "${CACHIX_CACHE:-}" ] && [ -n "${CACHIX_AUTH_TOKEN:-}" ]; then
nix shell nixpkgs#cachix -c sh -lc 'cachix push "$CACHIX_CACHE" $(nix path-info --accept-flake-config .#default)'
fi