Look to the CI system
The .gitlab-ci.yml
file contains information on how the system is built, tested, and deployed. It is an excellent starting point to see what step fails and why. It also gives a hint of what the expected environment for the build is and what commands should work.
When this documentation was built it looked like this:
include:
- remote: https://gitlab.com/arbetsformedlingen/devops/gitlab-cicd/jobtech-ci/-/raw/v2.1.1/jobtech-ci.yml
- remote: https://gitlab.com/arbetsformedlingen/devops/gitlab-cicd/jobtech-ci/-/raw/v2.1.1/deploy.yml
variables:
TEST_DISABLED: 1
DEPLOYS_DISABLED: 1
SCHEMATHESIS_IMAGE: schemathesis/schemathesis:3.28.1
CLOJURE_BUILD_IMAGE: clojure:temurin-22-tools-deps-1.11.3.1456-jammy
RUNTIME_BASE_IMAGE: eclipse-temurin:22.0.1_8-jre-alpine
AUTO_DEVOPS_BUILD_IMAGE_EXTRA_ARGS: "--build-arg BUILDER_BASE_IMAGE=$CLOJURE_BUILD_IMAGE --build-arg RUNTIME_BASE_IMAGE=$RUNTIME_BASE_IMAGE"
TAXONOMY_DEVELOP_SWAGGER_URL: http://jobtech-taxonomy-api-develop.apps.testing.services.jtech.se/v1/taxonomy/swagger.json
# This will store the libraries from deps.edn in a cache that will
# be restored in the next job that uses the same cache key
.cache-template: &cache-template
- key:
files:
- deps.edn
paths:
- .m2/repository
# Prepare and download the libraries in deps.edn.
# The result is cached between jobs and pipelines
# if there are no changes in deps.edn.
prepare_taxonomy_api_libraries:
stage: build
image: $CLOJURE_BUILD_IMAGE
cache: *cache-template
script:
- clojure -A:dev:prof:kaocha:prod:build:test:clj-kondo:eastwood:cljfmt:nsorg:outdated -P
- clojure -T:build update-build
artifacts:
paths:
- target
# This job is defined in Auto DevOps template.
# Here we tell it to use cached dependencies and
# start after the documentation is build.
build:
needs: [prepare_taxonomy_api_libraries]
cache: *cache-template
schemathesis_get_graphql_tests:
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
allow_failure: true
stage: test
image:
name: $SCHEMATHESIS_IMAGE
entrypoint: [""]
script:
- st run --junit-xml=schemathesis-get-graphql-junit.xml --hypothesis-deadline=None --show-trace --method GET --endpoint "^/v1/taxonomy/graphql" $TAXONOMY_DEVELOP_SWAGGER_URL
artifacts:
paths:
- schemathesis-get-graphql-junit.xml
reports:
junit: schemathesis-get-graphql-junit.xml
schemathesis_exclude_graphql_tests:
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
allow_failure: true
stage: test
image:
name: $SCHEMATHESIS_IMAGE
entrypoint: [""]
script:
- st run --junit-xml=schemathesis-exclude-graphql-junit.xml --hypothesis-deadline=None --show-trace --endpoint "^/v1/taxonomy/(?!graphql).+" $TAXONOMY_DEVELOP_SWAGGER_URL
artifacts:
paths:
- schemathesis-exclude-graphql-junit.xml
reports:
junit: schemathesis-exclude-graphql-junit.xml
datomic_kaocha_tests:
stage: test
needs: [prepare_taxonomy_api_libraries]
image: $CLOJURE_BUILD_IMAGE
cache: *cache-template
script:
- apt-get update && apt-get install -y python3-pip graphviz && pip3 install lcov_cobertura
- DATABASE_BACKEND=:datomic-v.kaocha clj -M:test:kaocha --profile :ci
- lcov_cobertura target/coverage/lcov.info -o coverage.xml
coverage: /^\|\s+ALL FILES\s\|\s+(\d+\.\d+)\s\|\s+\d+\.\d+\s\|\s*$/
artifacts:
paths:
- target/coverage/lcov.info
- cobertura.xml
reports:
junit: target/junit.xml
coverage_report:
coverage_format: cobertura
path: coverage.xml
server_api_tests:
stage: test
needs: [prepare_taxonomy_api_libraries]
image: $CLOJURE_BUILD_IMAGE
cache: *cache-template
script:
- apt-get update && apt-get install -y graphviz
- ./test/gitlab-ci/api-tests.sh
artifacts:
paths:
- target/junit-api-test-report.xml
reports:
junit: target/junit-api-test-report.xml
autodeploy_testing_read:
stage: test
image: docker:25.0.0-beta.2
services:
- docker:25.0.0-beta.2-dind
resource_group: write-infra
variables:
OVERLAY: "jobtech-taxonomy-api-testing-read"
rules:
- if: $CI_COMMIT_REF_SLUG == $CI_DEFAULT_BRANCH
needs:
- code_quality
- container_scanning
- datomic_kaocha_tests
- dockerfile-lint
- secret_detection
- semgrep-sast
- server_api_tests
- schemathesis_get_graphql_tests
- schemathesis_exclude_graphql_tests
script:
- !reference [.deploy, script]