-
Notifications
You must be signed in to change notification settings - Fork 75
/
.gitlab-ci.yml
136 lines (126 loc) · 4.64 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
# Skip CI if the commit message contains "WIP:", "[nobuild]", or "[noci]".
# Disable CI on main for the moment, but allow in MRs: we're running out of minutes.
workflow:
rules:
- if: $CI_COMMIT_MESSAGE =~ /(WIP:|\[nobuild\]|\[noci\])/
when: never
- if: $CI_MERGE_REQUEST_TITLE =~ /(WIP:|\[nobuild\]|\[noci\])/
when: never
- when: always
stages:
- build
- check
- deploy
###########################################################
# Build-stage jobs.
###########################################################
# Creates and publishes a Docker image of the latest version of the checker.
#
# This image can be used in "run-checker" jobs in MRs. Building only happens on main.
build-checker-image:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- >-
/kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile.checker"
--destination "${CI_REGISTRY}/openpowerlifting/opl-data/opl-checker:latest"
rules:
# Only build a new checker on the main branch. This means that changes to
# Rust code may result in CI failures for yet-to-merge branches.
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes:
paths:
- "Dockerfile.checker"
- "**/*.rs"
- "**/Cargo.toml"
- "Cargo.*"
- "scripts/oplcsv.py" # Support library for check-lifter-data.
- "tests/check-lifter-data" # This code should eventually be rewritten into the checker.
###########################################################
# Check-stage jobs.
###########################################################
# Checks that data passes the checker.
#
# Note: if this commit is doing both Rust and data changes, it will use the main branch's checker.
# Using a pre-built checker avoids having to rebuild Rust code, which is expensive.
run-checker:
stage: check
image: ${CI_REGISTRY}/openpowerlifting/opl-data/opl-checker:latest
before_script:
- cd ${CI_PROJECT_DIR}
script:
- checker --project-root ${CI_PROJECT_DIR} --timing
- tests/check-lifter-data
rules:
# Build on any branch off main. This explicitly allows for checks to run prior to MR creation.
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
changes:
paths: # Note that this doesn't run if the checker itself changes.
- "meet-data/**/*.csv" # Run the checker if CSV meet data changed (not just scripts).
- "**/CONFIG.toml" # Run the checker if federation configurations changed.
- "lifter-data/**/*" # Run the checker if any lifter data changed.
# Checks that Python scripts have an enforced style.
python-style:
stage: check
image:
name: alpine/flake8
entrypoint: [""]
script:
- tests/check-python-style
rules:
# Build on any branch off main. This explicitly allows for checks to run prior to MR creation.
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
changes:
paths:
- "**/*.py" # All Python scripts in meet-data/ must end with ".py".
- "scripts/*" # These are mostly python scripts, so safe to check.
- "tests/*" # Also mostly python scripts.
# Build the data file and run server tests with the current data.
# Disabled in CI as of 2022-11-01: trying to cut down on minutes.
#server:
# cache:
# paths:
# - target
# - server/client/node_modules
# before_script:
# - apt-get update -qq && apt-get install -y curl
# - curl -sL https://deb.nodesource.com/setup_14.x | bash -
# - apt-get install -y nodejs python3-pip
# - pip3 install toml
# script:
# - make csv
# - make -C server checkprerequisites
# - cargo test --workspace --locked
###########################################################
# Deploy-stage jobs.
###########################################################
# On success, publish the latest version of the Book to GitLab Pages.
# Published at https://openpowerlifting.gitlab.io/opl-data/
pages:
stage: deploy
image: rust:latest
variables:
CARGO_HOME: $CI_PROJECT_DIR/cargo
cache:
key: mdbook-cache-key
paths:
- $CARGO_HOME/bin
before_script:
- export PATH="$PATH:$CARGO_HOME/bin"
- mdbook --version || cargo install mdbook
script:
- mdbook build --dest-dir ../public book # Build book/ into public/.
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes:
paths:
- book/**/*