stages:
- lint
- build
- test
- release
variables:
CARGO_INCREMENTAL: 0
lint_job:
image: rust:latest
stage: lint
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- rustup component add rustfmt clippy
- cargo fmt --check
- cargo clippy --all-targets --all-features -- -D warnings
build_job:
image: rust:latest
stage: build
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- cargo build --release
- cargo install --path .
artifacts:
paths:
- target/release/simpleci
expire_in: 1 day
feature_test_job:
image: rust:latest
stage: test
needs:
- build_job
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
before_script:
- cargo install --path .
script:
- simpleci exec -f pipelines/script.yml
- simpleci exec -f pipelines/script-variables.yml
- simpleci exec -f pipelines/jobs.yml
- simpleci exec -f pipelines/jobs-variables.yml
- simpleci exec -f pipelines/stages.yml
- simpleci exec -f pipelines/stages-variables.yml
- simpleci exec -f pipelines/script-artifacts.yml
- simpleci exec -f pipelines/jobs-artifacts.yml
- simpleci exec -f pipelines/stages-artifacts.yml
- simpleci exec -f pipelines/script-inside_docker.yml
- simpleci exec -f pipelines/jobs-inside_docker.yml
- simpleci exec -f pipelines/stages-inside_docker.yml
- simpleci exec -f pipelines/jobs-cache.yml
- simpleci exec -f pipelines/stages-cache.yml
- simpleci exec -f pipelines/jobs-docker-cache.yml
- simpleci exec -f pipelines/stages-docker-cache.yml
- simpleci exec -f pipelines/jobs-docker-artifacts.yml
- simpleci exec -f pipelines/stages-docker-artifacts.yml
- simpleci exec -f pipelines/jobs-artifacts-cache.yml
- simpleci exec -f pipelines/stages-artifacts-cache.yml
- simpleci exec -f pipelines/config.yml
- simpleci exec -f pipelines/shell-bash.yml
- simpleci exec -f pipelines/shell-fish.yml
- simpleci exec -f pipelines/shell-sh.yml
- simpleci exec -f pipelines/shell-config.yml
- simpleci exec -f pipelines/jobs-shell.yml
- simpleci exec -f pipelines/stages-shell.yml
unit_test_job:
image: rust:latest
stage: test
needs:
- build_job
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- cargo test --all-features
upload_to_crates:
stage: release
image: rust
rules:
- if: $CI_COMMIT_TAG
script:
- sed -i -e "3s/[0-9]*\.[0-9]*\.[0-9]*/$CI_COMMIT_TAG/" Cargo.toml
- cargo login $CRATES_TOKEN
- cargo publish --allow-dirty
release_job_manual:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG
script:
- name="\"name\":\"Simpleci release $CI_COMMIT_TAG!\""
- url="\"url\":\"https://crates.io/crates/simpleci\""
- link_type="\"link_type\":\"other\""
- version="$CI_COMMIT_TAG"
- echo "Running a release_job"
- echo "Name of the release=$name"
- echo "Url of the release=$url"
- echo "Link of the release=$link_type"
- echo "Version of the release=$version"
- echo "CI_COMMIT_TAG=$CI_COMMIT_TAG"
- echo "LATEST_TAG=$LATEST_TAG"
- |
if [ "$(release-cli get --tag-name "$CI_COMMIT_TAG")" ]
then
echo "A release already exists"
else
release-cli create \
--name "Release $version" \
--tag-name $version \
--assets-link "{$name,$url,$link_type}"
fi