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:
|
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
|
- cargo test --workspace --verbose
|
||||||
|
|
||||||
docker-build:
|
clippy-lint:
|
||||||
# Use the official docker image.
|
stage: test
|
||||||
image: docker:latest
|
|
||||||
stage: build
|
|
||||||
services:
|
|
||||||
- docker:dind
|
|
||||||
before_script:
|
before_script:
|
||||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
- rustup component add clippy
|
||||||
# Default branch leaves tag empty (= latest tag)
|
|
||||||
# All other branches are tagged with the escaped branch name (commit ref slug)
|
|
||||||
script:
|
script:
|
||||||
- |
|
- cargo clippy
|
||||||
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
|
|
||||||
tag=""
|
|
||||||
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
|
release-artifacts:
|
||||||
else
|
stage: release
|
||||||
tag=":$CI_COMMIT_REF_SLUG"
|
script:
|
||||||
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
|
- cargo build --release
|
||||||
fi
|
artifacts:
|
||||||
- docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" .
|
paths:
|
||||||
- docker push "$CI_REGISTRY_IMAGE${tag}"
|
- target/release/bannana-pho
|
||||||
# Run this job in a branch where a Dockerfile exists
|
expire_in: 1 week
|
||||||
rules:
|
|
||||||
- if: $CI_COMMIT_BRANCH
|
release-container:
|
||||||
exists:
|
image: quay.io/podman/stable
|
||||||
- Dockerfile
|
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