forked from xfbs/diff.rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
75 lines (71 loc) · 2.28 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
# Stages: the build stage is where the code is build, and the publish stage is
# where it is deployed to diff.rs.
stages:
- check
- build
- publish
# Run unit tests
test:
stage: check
image: rust
script:
- cargo test
# Check style by running clippy and rustfmt.
style:
stage: check
image: rust
script:
- rustup component add clippy
- rustup toolchain add nightly
- rustup component add rustfmt --toolchain nightly
- cargo clippy -- --deny warnings
- cargo +nightly fmt --check
# Build stage: builds everything using trunk.
#
# Uses the "rust" docker image as base, just needs to add the wasm32 target and
# download trunk. It downloads a pre-built version of trunk because that is
# faster.
#
# Then performs a trunk release build. Trunk will put everything into the dist/
# folder, so this is set up to export anything from that folder as artifact so
# that the next CI stage has access to it.
build:
stage: build
image: rust
variables:
TRUNK_VERSION: 0.20.3
before_script:
- rustup target add wasm32-unknown-unknown
- wget -qO- https://github.com/thedodd/trunk/releases/download/v${TRUNK_VERSION}/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf- -C /usr/local/bin
script:
- trunk build --release
artifacts:
paths:
- dist
# Pages job: compress files and publish statically. this takes the output from
# the "build" job and produces a folder containing everything that needs to be
# statically hosted.
#
# It compresses everything in the dist/ folder with brotli and gzip, because
# GitLab pages has a feature where it will serve pre-compressed content if you
# compress it like this. that means the page loads faster.
#
# we also have to do is add a redirects file: because this is a single-page
# app, we want every path to resolve to the index.html (otherwise you get a 404
# if you request diff.rs/serde, because there is no actual file or folder named
# "serde").
pages:
stage: publish
image: alpine
before_script:
- apk add brotli gzip
script:
- mv dist public
- find public -not -name '*.gz' -not -name '*.br' -type f -exec gzip -vk {} \;
- find public -not -name '*.gz' -not -name '*.br' -type f -exec brotli -vk {} \;
- echo '/* / 200' >> public/_redirects
artifacts:
paths:
- public
only:
- master