2022-09-16 18:00:55 +00:00
---
2018-12-20 15:56:15 +00:00
stages :
2019-10-22 23:32:41 +00:00
- lint
2018-12-20 16:11:16 +00:00
- test
2024-01-22 16:01:37 +00:00
- bot
2018-12-20 15:56:15 +00:00
2018-12-29 23:49:57 +00:00
variables :
2024-01-26 09:36:19 +00:00
DOCS_BASEURL : "https://docs.xmpp.rs"
2018-12-29 23:49:57 +00:00
FEATURES : ""
2019-09-13 01:33:08 +00:00
RUST_BACKTRACE : "full"
2024-01-27 17:19:39 +00:00
RUSTFLAGS : " -D warnings"
RUSTDOCFLAGS : " -D warnings"
2018-12-29 23:49:57 +00:00
2021-12-27 00:22:53 +00:00
.show-version :
before_script :
2024-01-24 17:47:07 +00:00
- apt-get update; apt-get install -y --no-install-recommends pkg-config libssl-dev
2021-12-27 00:22:53 +00:00
- rustc --version
- cargo --version
2019-09-13 01:33:08 +00:00
.stable :
2023-06-01 15:21:56 +00:00
image : rust:slim
2021-12-27 00:22:53 +00:00
extends :
- .show-version
2018-12-20 15:56:15 +00:00
2019-09-13 01:33:08 +00:00
.nightly :
2023-06-01 15:21:56 +00:00
image : rustlang/rust:nightly-slim
2021-12-27 00:22:53 +00:00
extends :
- .show-version
2019-09-13 01:33:08 +00:00
.test :
2018-12-20 16:11:16 +00:00
stage : test
script :
2024-06-24 08:58:45 +00:00
- cargo test --verbose
2023-08-17 20:29:04 +00:00
- cargo test --verbose --no-default-features
2024-01-22 16:01:37 +00:00
rules :
- if : $CI_PIPELINE_SOURCE == 'merge_request_event'
- if : $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_REF_NAME == 'main'
.docs :
2024-01-24 17:47:07 +00:00
stage : test
2024-01-22 16:01:37 +00:00
script :
- echo "Building docs to CI_DOC_TARGET=$CI_DOC_TARGET"
2024-08-11 16:36:53 +00:00
- RUSTDOCFLAGS="--cfg docsrs -D warnings" RUSTFLAGS="--cfg xmpprs_doc_build" cargo +nightly doc --no-deps -Zrustdoc-map --all-features
2024-01-24 17:47:07 +00:00
- 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
2024-01-22 16:01:37 +00:00
rules :
- if : $CI_PIPELINE_SOURCE == 'merge_request_event'
variables :
2024-01-24 17:47:07 +00:00
CI_DOC_TARGET : "$CI_MERGE_REQUEST_IID"
2024-01-22 16:01:37 +00:00
- if : $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_REF_NAME == 'main'
variables :
2024-01-24 17:47:07 +00:00
CI_DOC_TARGET : "main"
2018-12-20 16:11:16 +00:00
2019-10-22 23:32:41 +00:00
rustfmt :
stage : lint
script :
2020-03-26 17:09:59 +00:00
- rustup component add rustfmt
2024-06-18 18:38:42 +00:00
- cargo fmt --version
2022-09-16 18:01:21 +00:00
- cargo fmt --check
2020-03-26 17:09:59 +00:00
extends :
- .stable
2024-01-22 16:01:37 +00:00
rules :
- if : $CI_PIPELINE_SOURCE == 'merge_request_event'
- if : $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_REF_NAME == 'main'
2019-10-22 23:32:41 +00:00
2024-12-16 16:04:44 +00:00
changelog-update :
stage : lint
image : alpine:latest
# Check in the commit message for "skip.?changelog", if not present
# then check for changes in changelogs.
# XXX: It looks like $CI_COMMIT_MESSAGE mangles newlines so it's not
# possible to require the "skip.?changelog" string to be on its own line,
# that means it would also trigger within a wall of text. Not so obvious.
# TODO: Check the whole MR for updates in changelogs, not just the last
# commit.
script :
- apk add --no-cache git python3
- echo $CI_COMMIT_MESSAGE
- |
/usr/bin/env python3 -c "
import os, re, subprocess, sys
# Skip this check if instructed
if re.search(r'skip.?changelog', os.environ['CI_COMMIT_MESSAGE'], flags=re.I) is not None :
print('Changelog skipped.')
sys.exit(0)
subprocess.run(['ls', '-l'])
subprocess.run(['git', '--version'])
subprocess.run(['git', 'log', '-1', '--oneline'])
treeish = 'main..'
if os.environ['CI_PIPELINE_SOURCE'] == 'merge_request_event' :
treeish = '{}..'.format(os.environ['CI_MERGE_REQUEST_DIFF_BASE_SHA'])
diff=subprocess.run(
[ 'git' , 'diff-tree' , '--no-commit-id' , '-r' , treeish],
capture_output=True,
)
print(f'FOO : {diff.stdout}\n\n{diff.stderr}')
# Verify if at least a single changelog file has been added or edited
if re.search(b'[AM]\\s+\\S*changelog', diff.stdout, flags=re.I) is None :
print('Please update the Changelog. Use \"skip-changelog\" in the commit message to skip this check.')
sys.exit(1)
print('Changelog has been updated as expected.')"
rules :
- if : $CI_PIPELINE_SOURCE == 'merge_request_event'
- if : $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_REF_NAME == 'main'
2020-04-05 01:41:19 +00:00
stable-test :
2019-09-13 01:33:08 +00:00
extends :
- .test
- .stable
2020-04-05 01:41:19 +00:00
nightly-test :
2024-01-27 17:19:39 +00:00
# It's not often, but it happens nightly breaks, surprisingly.
allow_failure : true
2019-09-13 01:33:08 +00:00
extends :
- .test
- .nightly
2024-01-22 16:01:37 +00:00
2024-01-24 17:47:07 +00:00
docs :
2024-01-22 16:01:37 +00:00
extends :
- .docs
2024-01-24 17:47:07 +00:00
- .nightly
2024-01-22 16:01:37 +00:00
bot-comment :
stage : bot
image : alpine:latest
script :
- apk add --no-cache glab
2024-01-24 22:18:05 +00:00
- 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_BASEURL/$CI_MERGE_REQUEST_IID/)."
2024-01-22 16:01:37 +00:00
rules :
- if : $CI_PIPELINE_SOURCE == 'merge_request_event'
variables :
GITLAB_TOKEN : $MR_AUTOMATION_TOKEN