-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
92 lines (82 loc) · 2.5 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
stages:
- test
- publish
variables:
DEBIAN_FRONTEND: noninteractive
CARGO_HOME: $CI_PROJECT_DIR/.cargo
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/${CARGO_HOME}/bin"
USER: "root"
test:
stage: test
image: debian:sid
environment:
cache:
key: build-cache
paths:
- ".cargo/"
- target/
script:
# Debian/Ubuntu docker images contain some docker-specific configs that mess with rust-apt tests, so remove them here first.
# https://github.com/GoogleContainerTools/base-images-docker/blob/master/debian/reproducible/overlay/etc/apt/apt.conf.d/docker-gzip-indexes
- rm -f /etc/apt/apt.conf.d/docker*
# Needed for testing source records
- echo "deb-src http://deb.debian.org/debian/ sid main" >> /etc/apt/sources.list
# Install needed packages
- apt-get update
- apt-get install eatmydata -y
- eatmydata apt-get install -y
build-essential
curl
sudo
apt-utils
libapt-pkg-dev
clang-format
codespell
- curl https://sh.rustup.rs -sSf | sh -- /dev/stdin -y
- rustup toolchain install nightly
- rustup toolchain install stable
# Run tests
- cargo install just
- eatmydata just check
# Docker has 0777 for everything. Deb packages need to be 0755
- chmod 0755 -R tests/files/cache
# Create the test .debs then run the tests
- eatmydata just create-test-debs
- eatmydata cargo test --no-fail-fast -- --test-threads 1
publish:
stage: publish
only:
- main
except:
- tags
image: debian:sid
environment:
cache:
key: build-cache
paths:
- ".cargo/"
- target/
script:
# Install rustup and other needed dependencies
- apt-get update
- apt-get install -y
build-essential
curl
git
jq
libapt-pkg-dev
- curl https://sh.rustup.rs -sSf | sh -- /dev/stdin -y
- rustup default stable
# Create the Git tag and publish.
- |
git fetch --tags
current_version="$(cargo metadata --no-deps --format-version=1 | jq -r '.packages[0].version')"
if ! git tag | grep "^v${current_version}$"; then
project_url="$(echo "${CI_PROJECT_URL}" | sed "s|https://|https://oauth2:${WRITE_REPOSITORY}@|")"
git tag "v${current_version}"
git push -o ci.skip "${project_url}" "v${current_version}"
# And now publish to crates.io
CARGO_REGISTRY_TOKEN="${CARGO_KEY}" cargo publish
else
echo "DEBUG: Git tag 'v${current_version}' already exists."
fi