Fix GitLab CI
This commit is contained in:
parent
b2cff6d4c0
commit
fe3b667df3
1 changed files with 40 additions and 27 deletions
|
@ -1,33 +1,46 @@
|
|||
image: "rust:latest"
|
||||
image: "rust:slim"
|
||||
|
||||
test:cargo:
|
||||
variables:
|
||||
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
||||
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- release
|
||||
|
||||
cargo-build:
|
||||
stage: build
|
||||
script:
|
||||
- rustc --version && cargo --version # Print version info for debugging
|
||||
- cargo build
|
||||
|
||||
cargo-test:
|
||||
stage: test
|
||||
script:
|
||||
- rustc --version && cargo --version
|
||||
- cargo test --workspace --verbose
|
||||
|
||||
docker-build:
|
||||
# Use the official docker image.
|
||||
image: docker:latest
|
||||
stage: build
|
||||
services:
|
||||
- docker:dind
|
||||
clippy-lint:
|
||||
stage: test
|
||||
before_script:
|
||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
# Default branch leaves tag empty (= latest tag)
|
||||
# All other branches are tagged with the escaped branch name (commit ref slug)
|
||||
- rustup component add clippy
|
||||
script:
|
||||
- |
|
||||
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
|
||||
tag=""
|
||||
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
|
||||
else
|
||||
tag=":$CI_COMMIT_REF_SLUG"
|
||||
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
|
||||
fi
|
||||
- docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" .
|
||||
- docker push "$CI_REGISTRY_IMAGE${tag}"
|
||||
# Run this job in a branch where a Dockerfile exists
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH
|
||||
exists:
|
||||
- Dockerfile
|
||||
- cargo clippy
|
||||
|
||||
|
||||
release-artifacts:
|
||||
stage: release
|
||||
script:
|
||||
- cargo build --release
|
||||
artifacts:
|
||||
paths:
|
||||
- target/release/bannana-pho
|
||||
expire_in: 1 week
|
||||
|
||||
release-container:
|
||||
image: quay.io/podman/stable
|
||||
stage: release
|
||||
before_script:
|
||||
- podman login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
script:
|
||||
- podman build -t $IMAGE_TAG
|
||||
- podman push $IMAGE_TAG
|
||||
|
|
Loading…
Add table
Reference in a new issue