2022-09-16 20:00:55 +02:00
---
2018-12-20 16:56:15 +01:00
stages :
2019-10-23 01:32:41 +02:00
- lint
2018-12-20 17:11:16 +01:00
- test
2024-01-22 17:01:37 +01:00
- bot
2018-12-20 16:56:15 +01:00
2018-12-30 00:49:57 +01:00
variables :
2024-01-26 10:36:19 +01:00
DOCS_BASEURL : "https://docs.xmpp.rs"
2018-12-30 00:49:57 +01:00
FEATURES : ""
2019-09-13 03:33:08 +02:00
RUST_BACKTRACE : "full"
2024-01-27 18:19:39 +01:00
RUSTFLAGS : " -D warnings"
RUSTDOCFLAGS : " -D warnings"
2018-12-30 00:49:57 +01:00
2021-12-27 01:22:53 +01:00
.show-version :
before_script :
2024-01-24 18:47:07 +01:00
- apt-get update; apt-get install -y --no-install-recommends pkg-config libssl-dev
2021-12-27 01:22:53 +01:00
- rustc --version
- cargo --version
2019-09-13 03:33:08 +02:00
.stable :
2023-06-01 17:21:56 +02:00
image : rust:slim
2021-12-27 01:22:53 +01:00
extends :
- .show-version
2018-12-20 16:56:15 +01:00
2019-09-13 03:33:08 +02:00
.nightly :
2023-06-01 17:21:56 +02:00
image : rustlang/rust:nightly-slim
2021-12-27 01:22:53 +01:00
extends :
- .show-version
2019-09-13 03:33:08 +02:00
.test :
2018-12-20 17:11:16 +01:00
stage : test
script :
2023-08-17 22:29:04 +02:00
- cargo test --verbose --release -- --include-ignored
- cargo test --verbose --no-default-features
2024-01-22 17:01:37 +01:00
rules :
- if : $CI_PIPELINE_SOURCE == 'merge_request_event'
- if : $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_REF_NAME == 'main'
.docs :
2024-01-24 18:47:07 +01:00
stage : test
2024-01-22 17:01:37 +01:00
script :
- echo "Building docs to CI_DOC_TARGET=$CI_DOC_TARGET"
2024-01-24 18:47:07 +01:00
- cargo +nightly doc --no-deps -Zrustdoc-map
2024-04-17 17:17:32 +02:00
- |
if [ -n "${SECRET_DOCS_SSH_PRIVATE:-}" ]; then
set -e
apt install -y rsync openssh-client
mkdir -p $HOME/.ssh
echo -e "Host docs\n\tHostname docs.xmpp.rs\n\tPort 1312\n\tUser xmpp-rs\n\tStrictHostKeyChecking no" > $HOME/.ssh/config
echo "$SECRET_DOCS_SSH_PRIVATE" > $HOME/.ssh/id_ed25519
chmod 400 $HOME/.ssh/id_ed25519
rsync -av target/doc/ docs:$CI_DOC_TARGET
# save artifact space
rm -rf -- target/doc/*
printf '<!DOCTYPE html><body><a href="%s">See here</a>' "$DOCS_BASEURL/$CI_MERGE_REQUEST_IID/" > target/doc/index.html
else
echo "$CI_JOB_ID" > target/doc/job_id.txt
fi
- mv target/doc/ public
artifacts :
expose_as : "Rendered Docs"
expire_in : "7 days"
# The trailing slash is required for exposure to work!
paths :
- public/
2024-01-22 17:01:37 +01:00
rules :
- if : $CI_PIPELINE_SOURCE == 'merge_request_event'
variables :
2024-01-24 18:47:07 +01:00
CI_DOC_TARGET : "$CI_MERGE_REQUEST_IID"
2024-01-22 17:01:37 +01:00
- if : $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_REF_NAME == 'main'
variables :
2024-01-24 18:47:07 +01:00
CI_DOC_TARGET : "main"
2018-12-20 17:11:16 +01:00
2019-10-23 01:32:41 +02:00
rustfmt :
stage : lint
script :
2020-03-26 18:09:59 +01:00
- rustup component add rustfmt
2022-09-16 20:01:21 +02:00
- cargo fmt --check
2020-03-26 18:09:59 +01:00
extends :
- .stable
2024-01-22 17:01:37 +01:00
rules :
- if : $CI_PIPELINE_SOURCE == 'merge_request_event'
- if : $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_REF_NAME == 'main'
2019-10-23 01:32:41 +02:00
2020-04-05 03:41:19 +02:00
stable-test :
2019-09-13 03:33:08 +02:00
extends :
- .test
- .stable
2020-04-05 03:41:19 +02:00
nightly-test :
2024-01-27 18:19:39 +01:00
# It's not often, but it happens nightly breaks, surprisingly.
allow_failure : true
2019-09-13 03:33:08 +02:00
extends :
- .test
- .nightly
2024-01-22 17:01:37 +01:00
2024-01-24 18:47:07 +01:00
docs :
2024-01-22 17:01:37 +01:00
extends :
- .docs
2024-01-24 18:47:07 +01:00
- .nightly
2024-01-22 17:01:37 +01:00
bot-comment :
stage : bot
image : alpine:latest
2024-04-17 17:17:32 +02:00
dependencies :
- docs
2024-01-22 17:01:37 +01:00
script :
- apk add --no-cache glab
2024-04-17 17:17:32 +02:00
- |
if [ -e "public/job_id.txt" ]; then
# CI build could not upload to docs.xmpp.rs, so we have to link to the job artifacts instead.
job_id="$(cat public/job_id.txt)"
docs_url="https://xmpp-rs.gitlab.io/-/xmpp-rs/-/jobs/$job_id/artifacts/public/xmpp/index.html"
else
docs_url="$DOCS_BASEURL/$CI_MERGE_REQUEST_IID/"
fi
- glab mr --repo "$CI_MERGE_REQUEST_PROJECT_PATH" comment $CI_MERGE_REQUEST_IID --unique --message "Thanks for your MR! You can preview the docs [here]($docs_url)."
2024-01-22 17:01:37 +01:00
rules :
- if : $CI_PIPELINE_SOURCE == 'merge_request_event'
variables :
GITLAB_TOKEN : $MR_AUTOMATION_TOKEN