forked from nolan/titlebot-ng-ng
Create .gitlab-ci.yml
This commit is contained in:
+108
@@ -0,0 +1,108 @@
|
||||
stages:
|
||||
- check
|
||||
- test
|
||||
- lint
|
||||
- release
|
||||
|
||||
workflow:
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE != 'push' || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG
|
||||
when: always
|
||||
- when: never
|
||||
# use latest rust image
|
||||
image: rust:latest
|
||||
|
||||
variables:
|
||||
# treat compiler warnings as errors (in clippy, when running tests, etc.)
|
||||
RUSTFLAGS: -Dwarnings
|
||||
|
||||
LIN_BIN: $CI_PROJECT_NAME-$CI_COMMIT_TAG
|
||||
WIN_BIN: $CI_PROJECT_NAME-$CI_COMMIT_TAG.exe
|
||||
|
||||
# default applies to all jobs
|
||||
default:
|
||||
# cancel the job if a newer pipeline starts for the same MR or branch
|
||||
interruptible: true
|
||||
|
||||
tags:
|
||||
- rust
|
||||
|
||||
cargo:check:
|
||||
stage: check
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG == null
|
||||
script:
|
||||
- cargo check --all-targets
|
||||
|
||||
# a format check is run in parallel with clippy job
|
||||
cargo:fmt:
|
||||
stage: lint
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
script:
|
||||
- cargo fmt --check
|
||||
allow_failure: true
|
||||
|
||||
# run linter
|
||||
cargo:clippy:
|
||||
stage: lint
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
script:
|
||||
- cargo clippy --all-targets
|
||||
|
||||
cargo:test:
|
||||
stage: test
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
needs:
|
||||
- cargo:check
|
||||
script:
|
||||
# install nextest (I swear this is the recommended way)
|
||||
- mkdir -p $CARGO_HOME/bin && curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C $CARGO_HOME/bin
|
||||
# run nextest with the "ci" profile, which produces a junit XML test report
|
||||
- cargo nextest run --profile ci -j1
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
# point GitLab to the junit test report: it will automatically display it in a dashboard
|
||||
junit: $CI_PROJECT_DIR/target/nextest/ci/junit.xml
|
||||
paths:
|
||||
- logs
|
||||
|
||||
release:build:
|
||||
stage: release
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
needs:
|
||||
- cargo:clippy
|
||||
artifacts:
|
||||
untracked: false
|
||||
when: on_success
|
||||
access: all
|
||||
expire_in: "30 days"
|
||||
paths:
|
||||
- bin
|
||||
script:
|
||||
- apt-get update
|
||||
- apt-get install mingw-w64 -y
|
||||
- cargo build --release --target x86_64-unknown-linux-gnu
|
||||
- cargo build --release --target x86_64-pc-windows-gnu
|
||||
- mkdir bin
|
||||
- echo $LIN_BIN $WIN_BIN
|
||||
- mv target/x86_64-unknown-linux-gnu/release/${CI_PROJECT_NAME} bin/$LIN_BIN
|
||||
- mv target/x86_64-pc-windows-gnu/release/${CI_PROJECT_NAME}.exe bin/$WIN_BIN
|
||||
- ls bin
|
||||
|
||||
release:publish:
|
||||
stage: release
|
||||
image: registry.gitlab.com/gitlab-org/cli:latest
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
needs:
|
||||
- release:build
|
||||
script:
|
||||
- glab auth login --hostname $CI_SERVER_HOST --job-token $CI_JOB_TOKEN
|
||||
- ls bin
|
||||
- echo $LIN_BIN $WIN_BIN
|
||||
- glab release create $CI_COMMIT_TAG bin/$LIN_BIN bin/$WIN_BIN --package-name $CI_COMMIT_TAG --use-package-registry
|
||||
Reference in New Issue
Block a user