.gitlab-ci.yml

  1---
  2
  3stages:
  4  - lint
  5  - test
  6  - bot
  7
  8variables:
  9  DOCS_BASEURL: "https://docs.xmpp.rs"
 10  FEATURES: ""
 11  RUST_BACKTRACE: "full"
 12  RUSTFLAGS: " -D warnings"
 13  RUSTDOCFLAGS: " -D warnings"
 14  CARGO_TERM_COLOR: "always"
 15
 16.show-version:
 17  before_script:
 18    - apt-get update; apt-get install -y --no-install-recommends pkg-config libssl-dev
 19    - rustc --version
 20    - cargo --version
 21
 22.stable:
 23  image: rust:slim
 24  extends:
 25    - .show-version
 26
 27.nightly:
 28  image: rustlang/rust:nightly-slim
 29  extends:
 30    - .show-version
 31
 32.test:
 33  stage: test
 34  script:
 35    - cargo test --verbose
 36    - cargo test --verbose --no-default-features
 37  rules:
 38    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
 39    - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_REF_NAME == 'main'
 40
 41.docs:
 42  stage: test
 43  script:
 44    - echo "Building docs to CI_DOC_TARGET=$CI_DOC_TARGET"
 45    - RUSTDOCFLAGS="--cfg docsrs -D warnings" RUSTFLAGS="--cfg xmpprs_doc_build" cargo +nightly doc --no-deps -Zrustdoc-map --all-features
 46    - apt install -y rsync openssh-client
 47    - mkdir -p $HOME/.ssh
 48    - echo -e "Host docs\n\tHostname ssh.docsxmpprs-2025.sotecware.net\n\tPort 1312\n\tUser docs\n\tStrictHostKeyChecking no" > $HOME/.ssh/config
 49    - echo "$SECRET_DOCS_SSH_PRIVATE" > $HOME/.ssh/id_ed25519
 50    - chmod 400 $HOME/.ssh/id_ed25519
 51    - rsync -av --rsh=ssh target/doc/ docs::www/$CI_DOC_TARGET
 52  rules:
 53    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
 54      variables:
 55        CI_DOC_TARGET: "$CI_MERGE_REQUEST_IID"
 56    - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_REF_NAME == 'main'
 57      variables:
 58        CI_DOC_TARGET: "main"
 59  extends:
 60    - .show-version
 61
 62rustfmt:
 63  stage: lint
 64  script:
 65    - rustup component add rustfmt
 66    - cargo fmt --version
 67    - cargo fmt --check
 68  extends:
 69    - .stable
 70  rules:
 71    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
 72    - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_REF_NAME == 'main'
 73
 74typos:
 75  stage: lint
 76  script:
 77    - cargo install typos-cli
 78    - typos
 79  extends:
 80    - .stable
 81  rules:
 82    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
 83    - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_REF_NAME == 'main'
 84
 85changelog-update:
 86  stage: lint
 87  image: alpine:latest
 88  # Check in the commit message for "skip.?changelog", if not present
 89  # then check for changes in changelogs.
 90  # XXX: It looks like $CI_COMMIT_MESSAGE mangles newlines so it's not
 91  # possible to require the "skip.?changelog" string to be on its own line,
 92  # that means it would also trigger within a wall of text. Not so obvious.
 93  # TODO: Check the whole MR for updates in changelogs, not just the last
 94  # commit.
 95  script:
 96    - apk add --no-cache python3 git
 97    - python3 --version
 98    - git version
 99    - git fetch --depth 16 origin main
100    - |
101      if ! git log --oneline "${CI_MERGE_REQUEST_DIFF_BASE_SHA}.." --; then
102        echo "Failed to find revision ${CI_MERGE_REQUEST_DIFF_BASE_SHA}.." >&2
103        echo "This likely means that you need to rebase your branch." >&2
104        exit 1
105      fi
106    - python3 .forgejo/workflows/check-changelog.py
107  rules:
108    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
109    - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_REF_NAME == 'main'
110
111stable-test:
112  extends:
113    - .test
114    - .stable
115
116nightly-test:
117  # It's not often, but it happens nightly breaks, surprisingly.
118  allow_failure: true
119  extends:
120    - .test
121    - .nightly
122
123docs:
124  extends:
125    - .docs
126    - .nightly
127
128#bot-comment:
129#  stage: bot
130#  image: alpine:latest
131#  script:
132#    - apk add --no-cache glab
133#    - 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/)."
134#  rules:
135#    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
136#      variables:
137#        GITLAB_TOKEN: $MR_AUTOMATION_TOKEN