From af6077eaa4be4ae8f2f874be8e3968f4a2b01862 Mon Sep 17 00:00:00 2001 From: ngqile Date: Mon, 30 Nov 2026 10:15:29 +0800 Subject: [PATCH] ci: build, test and publish the nine images from main Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM --- .gitea/workflows/ci.yml | 77 +++++++++++++++++++ .../changes/add-release-ci-packaging/tasks.md | 2 +- 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/ci.yml diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..9e9c9f9 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,77 @@ +name: CI + +# Builds and tests every module, then publishes nine images to gitea.containerverse.dev/solvway/co-lite-, +# tagged with the commit SHA and latest (openspec spec release-packaging). Nothing is pushed unless every build, +# test and image check passes. Deployment is done outside this workflow. +on: + push: + branches: + - main + +# Two quick pushes to main must not interleave their image pushes or latest tags. +concurrency: + group: co-lite-main + cancel-in-progress: false + +jobs: + build-and-publish: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + container: + image: gitea.containerverse.dev/solvway/maven-custom-21:latest + credentials: + username: ${{ secrets.PACKAGE_USER }} + password: ${{ secrets.PACKAGE_RW_KEY }} + volumes: + - /cache/m2:/root/.m2 + env: + REGISTRY: gitea.containerverse.dev + IMAGE_PREFIX: gitea.containerverse.dev/solvway/co-lite- + DOCKER_HOST: tcp://docker:2375 + DOCKER_TLS_VERIFY: "" + # image name : module folder + IMAGES: >- + api-gateway:solvway-api-gateway + mobile-api:solvway-mobile-api + service-auth:solvway-services-auth + service-system:solvway-services-system + service-counter:solvway-services-counter + service-member:solvway-services-member + service-log:solvway-services-log + service-email:solvway-services-email + admin-portal:solvway-admin-portal + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build and test the services + run: | + mvn -T 1C -B -Dmaven.repo.local=/root/.m2/repository-co-lite verify \ + -pl solvway-api-gateway,solvway-mobile-api,solvway-services-auth,solvway-services-system,solvway-services-counter,solvway-services-member,solvway-services-log,solvway-services-email -am + + - name: Registry login + env: + REGISTRY_USER: ${{ secrets.PACKAGE_USER }} + REGISTRY_KEY: ${{ secrets.PACKAGE_RW_KEY }} + run: printf '%s' "$REGISTRY_KEY" | docker login "$REGISTRY" -u "$REGISTRY_USER" --password-stdin + + - name: Build and check every image + # The admin portal's Dockerfile runs its own tests and lint; a red suite fails its build. + run: | + # image-check.sh needs unzip and refuses to run without it. + command -v unzip >/dev/null || { apt-get update -qq && apt-get install -y -qq unzip; } + for pair in $IMAGES; do + name=${pair%%:*}; dir=${pair#*:} + docker build -t "$IMAGE_PREFIX$name:$GITHUB_SHA" -t "$IMAGE_PREFIX$name:latest" "$dir" + sh local/image-check.sh "$IMAGE_PREFIX$name:$GITHUB_SHA" + done + + - name: Push every image + run: | + for pair in $IMAGES; do + name=${pair%%:*} + docker push "$IMAGE_PREFIX$name:$GITHUB_SHA" + docker push "$IMAGE_PREFIX$name:latest" + done diff --git a/openspec/changes/add-release-ci-packaging/tasks.md b/openspec/changes/add-release-ci-packaging/tasks.md index 1572bb2..2f771ca 100644 --- a/openspec/changes/add-release-ci-packaging/tasks.md +++ b/openspec/changes/add-release-ci-packaging/tasks.md @@ -26,7 +26,7 @@ Design: `design.md`. All tasks run serially: each touches a build file, CI or SQ ## 2. CI -- [ ] 2.1 Add `.gitea/workflows/ci.yml` (design decisions 1 to 3 and 5). +- [x] 2.1 Add `.gitea/workflows/ci.yml` (design decisions 1 to 3 and 5). - The workflow runs on push to `main` only. - It runs Maven `verify` with `-T 1C`, then builds all nine images, runs `local/image-check.sh` on each, and pushes after every image has built, tagged with the SHA and `latest`. - It logs in to the registry with `PACKAGE_USER` and `PACKAGE_RW_KEY`.