fradrive/.gitlab-ci/dynamic-gitlab--ci.yml

134 lines
3.9 KiB
YAML

# SPDX-FileCopyrightText: 2024 Sarah Vaupel <sarah.vaupel@uniworx.de>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
### IMPORTANT NOTICE ###
# Our pipeline consists of static and dynamic parts.
#
# This file only contains the dynamic parts of our pipeline.
# Static jobs are defined in .gitlab-ci.yml.
#
# The marker "#dyn#" (without quotes) will be replaced by concrete values.
###
variables:
FRONTEND_IMAGE_VERSION: #dyn#
BACKEND_IMAGE_VERSION: #dyn#
stages:
- containers
- compile
- lint
- test
containers:frontend:
stage: containers
image: &buildah quay.io/buildah/stable:latest
script:
# - IMAGE_VERSION=`git log docker/frontend/Dockerfile | grep '^commit' | wc --lines`
- buildah bud -t frontend/${CI_COMMIT_REF_SLUG}:${FRONTEND_IMAGE_VERSION} docker/frontend/Dockerfile
- buildah push --creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" frontend/${CI_COMMIT_REF_SLUG}:${FRONTEND_IMAGE_VERSION} ${CI_REGISTRY_IMAGE}/frontend/${CI_COMMIT_REF_SLUG}:${FRONTEND_IMAGE_VERSION}
rules:
- changes:
- docker/frontend/Dockerfile
interruptible: false
containers:backend:
stage: containers
image: *buildah
script:
# - IMAGE_VERSION=`git log docker/backend/Dockerfile | grep '^commit' | wc --lines`
- buildah bud -t backend/${CI_COMMIT_REF_SLUG}:${BACKEND_IMAGE_VERSION} docker/backend/Dockerfile
- buildah push --creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" backend/${CI_COMMIT_REF_SLUG}:${BACKEND_IMAGE_VERSION} ${CI_REGISTRY_IMAGE}/backend/${CI_COMMIT_REF_SLUG}:${BACKEND_IMAGE_VERSION}
rules:
- changes:
- docker/backend/Dockerfile
interruptible: false
frontend build:
stage: compile
needs:
- job: containers:frontend
optional: true
image: &frontend-image ${CI_REGISTRY_IMAGE}/frontend/${CI_COMMIT_REF_SLUG}:${FRONTEND_IMAGE_VERSION}
script:
- &load-frontend-image zcat docker/frontend/image.tar.gz | podman image load
- make -- --docker-run-frontend-build FRADRIVE_SERVICE=frontend CONTAINER_RUNNER=podman-compose
artifacts:
paths:
- /fradrive/node_modules
- /fradrive/well-known
cache:
- &frontend-cache
key: default-frontend
paths:
- /fradrive/.npm/
- /fradrive/.well-known-cache/
frontend lint:
stage: lint
needs:
- job: containers:frontend
optional: true
image: *frontend-image
script:
- *load-frontend-image
- make -- --docker-run-frontend-lint FRADRIVE_SERVICE=frontend CONTAINER_RUNNER=podman-compose
cache: *frontend-cache
frontend test:
stage: test
needs:
- job: containers:frontend
optional: true
- job: frontend build
artifacts: true
image: *frontend-image
script:
- *load-frontend-image
- make -- --docker-run-frontend-test FRADRIVE_SERVICE=frontend CONTAINER_RUNNER=podman-compose
cache: *frontend-cache
backend build:
stage: compile
needs:
- job: containers:backend
optional: true
- job: frontend build
artifacts: true
image: &backend-image ${CI_REGISTRY_IMAGE}/backend/${CI_COMMIT_REF_SLUG}:${BACKEND_IMAGE_VERSION}
script:
- &load-backend-image zcat docker/backend/image.tar.gz | podman image load
- make -- --docker-run-backend-build FRADRIVE_SERVICE=backend CONTAINER_RUNNER=podman-compose
artifacts:
paths:
- /fradrive/.stack/
- /fradrive/.stack-work/
cache: &backend-cache
backend lint:
stage: lint
needs:
- job: containers:backend
optional: true
image: *backend-image
script:
- *load-backend-image
- make -- --docker-run-backend-lint FRADRIVE_SERVICE=backend CONTAINER_RUNNER=podman-compose
cache: *backend-cache
backend test:
stage: test
needs:
- job: containers:backend
optional: true
- job: backend build
artifacts: true
image: *backend-image
script:
- *load-backend-image
- make -- --docker-run-backend-test FRADRIVE_SERVICE=backend CONTAINER_RUNNER=podman-compose
cache: *backend-cache