Add GitLab CI pipeline: tests, image builds, Helm OCI push
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4a505c2226
commit
8fa2feaf1f
3 changed files with 100 additions and 4 deletions
88
.gitlab-ci.yml
Normal file
88
.gitlab-ci.yml
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
stages:
|
||||
- test
|
||||
- build
|
||||
- bundle
|
||||
|
||||
BackendUnitTests:
|
||||
image: golang:1.27.3-alpine
|
||||
stage: test
|
||||
needs: []
|
||||
variables:
|
||||
CGO_ENABLED: "0"
|
||||
script:
|
||||
- cd backend
|
||||
- go vet ./...
|
||||
- go test ./...
|
||||
|
||||
FrontendBuild:
|
||||
image: node:24.22-alpine
|
||||
stage: test
|
||||
needs: []
|
||||
script:
|
||||
- cd frontend
|
||||
- npm ci
|
||||
- npm run build # runs tsc, there are no unit tests yet
|
||||
|
||||
.docker:
|
||||
image: jonasled.dev/infra/docker-build:master@sha256:d6f535fcb2817edec221eac33331369863f3409322d5f2d516356e7e7554326b
|
||||
stage: build
|
||||
needs: []
|
||||
# variables NAME and DOCKERFILE are set by the jobs below
|
||||
script:
|
||||
- export IMAGE_NAME=$CI_REGISTRY_IMAGE/$NAME
|
||||
- export BUILDKIT_ADDITIONAL_ARGS="--opt filename=$DOCKERFILE"
|
||||
- build-image
|
||||
- mv image-hash.txt image-hash-$NAME.txt
|
||||
- mv image-scan-report.bom.json $NAME.bom.json
|
||||
artifacts:
|
||||
paths:
|
||||
- image-hash-$NAME.txt
|
||||
- $NAME.bom.json
|
||||
|
||||
BackendDocker:
|
||||
extends: .docker
|
||||
variables: { NAME: backend, DOCKERFILE: Dockerfile.backend }
|
||||
|
||||
FrontendDocker:
|
||||
extends: .docker
|
||||
variables: { NAME: frontend, DOCKERFILE: Dockerfile.frontend }
|
||||
|
||||
SpamassassinDocker:
|
||||
extends: .docker
|
||||
variables: { NAME: spamassassin, DOCKERFILE: Dockerfile.spamassassin }
|
||||
|
||||
HelmChart:
|
||||
# Renders the chart, packages it and pushes it to the project's OCI registry:
|
||||
# helm install mail-tester oci://$CI_REGISTRY/$CI_PROJECT_PATH/charts/mail-tester --version <version>
|
||||
# Image repositories are set to this project's registry; the image tag is the chart appVersion (commit SHA).
|
||||
image:
|
||||
name: alpine/helm:4.3.1
|
||||
entrypoint: [""]
|
||||
stage: bundle
|
||||
needs:
|
||||
- BackendDocker
|
||||
- FrontendDocker
|
||||
- SpamassassinDocker
|
||||
variables:
|
||||
CHART_DIR: helm
|
||||
CHART_REPO: oci://$CI_REGISTRY/$CI_PROJECT_PATH/charts
|
||||
script:
|
||||
- sed -i "s|__CI_REGISTRY_IMAGE__|$CI_REGISTRY_IMAGE|g" "$CHART_DIR/values.yaml"
|
||||
- if grep -q "__CI_REGISTRY_IMAGE__" "$CHART_DIR/values.yaml"; then echo "placeholder left in values.yaml"; exit 1; fi
|
||||
- helm lint "$CHART_DIR" --strict --set jmap.user=ci --set jmap.password=ci
|
||||
# Render every database driver so template failures show up in CI.
|
||||
- helm template ci "$CHART_DIR" --set jmap.user=ci --set jmap.password=ci > /dev/null
|
||||
- helm template ci "$CHART_DIR" --set jmap.user=ci --set jmap.password=ci --set db.driver=mysql --set db.host=db --set db.user=ci --set db.password=ci > /dev/null
|
||||
- helm template ci "$CHART_DIR" --set jmap.useToken=true --set jmap.password=ci --set db.driver=postgres --set db.host=db --set db.user=ci --set db.password=ci --set ingress.enabled=true > /dev/null
|
||||
- |
|
||||
# Versions must only grow: patch number is the pipeline IID, major.minor comes from Chart.yaml.
|
||||
BASE_VERSION=$(sed -n 's/^version: *//p' "$CHART_DIR/Chart.yaml" | cut -d. -f1,2)
|
||||
helm package "$CHART_DIR" --version "${BASE_VERSION}.${CI_PIPELINE_IID}" --app-version "$CI_COMMIT_SHA" --destination dist
|
||||
- helm registry login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
|
||||
- helm push dist/mail-tester-*.tgz "$CHART_REPO"
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||
artifacts:
|
||||
paths:
|
||||
- dist/
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
image:
|
||||
repositoryBackend: jonasled.dev/jonasled/mail-tester/backend
|
||||
repositoryFrontend: jonasled.dev/jonasled/mail-tester/frontend
|
||||
repositorySpamassassin: jonasled.dev/jonasled/mail-tester/spamassassin
|
||||
# CI replaces __CI_REGISTRY_IMAGE__ with the project's registry path; set real repositories when installing from source.
|
||||
repositoryBackend: __CI_REGISTRY_IMAGE__/backend
|
||||
repositoryFrontend: __CI_REGISTRY_IMAGE__/frontend
|
||||
repositorySpamassassin: __CI_REGISTRY_IMAGE__/spamassassin
|
||||
pullPolicy: IfNotPresent
|
||||
# Overrides the image tag whose default is the chart appVersion.
|
||||
# Empty = chart appVersion (CI sets it to the commit SHA).
|
||||
tag: ""
|
||||
|
||||
imagePullSecrets: []
|
||||
|
|
|
|||
7
renovate.json
Normal file
7
renovate.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": ["config:recommended"],
|
||||
"automerge": true,
|
||||
"automergeType": "pr",
|
||||
"platformAutomerge": true
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue