LibreTunes-Nix-Test/.gitlab-ci.yml

81 lines
2.1 KiB
YAML

# Build the project
build:
needs: []
image: $CI_REGISTRY/libretunes/ops/docker-leptos:latest
script:
- cargo-leptos build
# Build the docker image and push it to the registry
docker-build:
needs: ["build"]
image: docker:latest
services:
- docker:dind
tags:
- docker
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA .
# If running on the default branch, tag as latest
- if [ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]; then docker tag
$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
$CI_REGISTRY_IMAGE:latest; fi
- docker push $CI_REGISTRY_IMAGE --all-tags
# Run leptos tests
leptos-tests:
needs: ["build"]
image: $CI_REGISTRY/libretunes/ops/docker-leptos:latest
script:
- cargo-leptos test
# Run all tests
tests:
needs: ["build"]
image: $CI_REGISTRY/libretunes/ops/docker-leptos:latest
script:
- cargo test --all-targets --all-features
# Generate docs
cargo-doc:
needs: []
image: rust:slim
script:
- cargo doc --no-deps
artifacts:
paths:
- target/doc
.argocd:
image: argoproj/argocd:v2.6.15
before_script:
- argocd login ${ARGOCD_SERVER} --username ${ARGOCD_USERNAME} --password ${ARGOCD_PASSWORD} --grpc-web
# Start the review environment
start-review:
extends: .argocd
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual
script:
- argocd app sync argocd/libretunes-review-${CI_COMMIT_SHORT_SHA}
- argocd app wait argocd/libretunes-review-${CI_COMMIT_SHORT_SHA}
environment:
name: review/$CI_COMMIT_SHORT_SHA
url: https://review-$CI_COMMIT_SHORT_SHA.libretunes.mregirouard.com
on_stop: stop-review
# Stop the review environment
stop-review:
needs: ["start-review"]
extends: .argocd
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual
allow_failure: true
script:
- argocd app delete argocd/libretunes-review-${CI_COMMIT_SHORT_SHA} --cascade
environment:
name: review/$CI_COMMIT_SHORT_SHA
action: stop