CI / lint-backend (push) Successful in 1m20s
CI / lint-mobile (push) Successful in 8m21s
CI / test-backend (push) Successful in 1m18s
CI / test-mobile (push) Successful in 8m27s
CI / build-backend (push) Successful in 1m2s
CI / docker (push) Failing after 44s
203 lines
6.7 KiB
YAML
203 lines
6.7 KiB
YAML
# Pipeline Gitea Actions pour Kazier — lint + test + build + image registre.
|
|
#
|
|
# Prérequis act_runner (une seule fois) :
|
|
# - Runner act_runner enregistré contre l'instance Gitea, labels `ubuntu-24.04` dispo.
|
|
# - Executor docker : privilégié (jobs docker:dind + containers) — sinon le
|
|
# job `docker` et le service `dind` échouent.
|
|
# - Gitea app.ini : [actions] ENABLED=true, DEFAULT_ACTIONS_URL=https://github.com
|
|
# - Droits d'écriture du runner sur son répertoire de travail/cache.
|
|
#
|
|
# Secrets (Settings > Actions) :
|
|
# - CONTAINER_REGISTRY_TOKEN PAT scope write:package (registre conteneur)
|
|
# - CONTAINER_REGISTRY_USER utilisateur propriétaire du PAT ci-dessus
|
|
|
|
name: CI
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ["v*"]
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
env:
|
|
GO_VERSION: "1.26"
|
|
ANDROID_IMAGE: cimg/android:2024.01-node
|
|
CGO_ENABLED: "0"
|
|
# Registre conteneur Gitea (ex: cname de l'instance)
|
|
REGISTRY_HOST: gitea.thirdshop.fr
|
|
|
|
jobs:
|
|
lint-backend:
|
|
runs-on: ubuntu-24.04
|
|
container: golang:${{ env.GO_VERSION }}-alpine
|
|
steps:
|
|
# golang:alpine n'a ni node ni git — requis par les actions JS
|
|
# (checkout/cache) exécutées dans le container par act_runner.
|
|
- name: Install node + git (actions JS)
|
|
run: apk add --no-cache nodejs git
|
|
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.GITEA_TOKEN }}
|
|
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
/go/pkg/mod
|
|
~/.cache/go-build
|
|
key: go-${{ runner.os }}-${{ hashFiles('backend/go.sum') }}
|
|
restore-keys: |
|
|
go-${{ runner.os }}-
|
|
|
|
- run: go mod download
|
|
working-directory: backend
|
|
- run: go vet ./...
|
|
working-directory: backend
|
|
- run: go install honnef.co/go/tools/cmd/staticcheck@latest && staticcheck ./...
|
|
working-directory: backend
|
|
|
|
lint-mobile:
|
|
runs-on: ubuntu-24.04
|
|
container: ${{ env.ANDROID_IMAGE }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.GITEA_TOKEN }}
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: gradle-${{ runner.os }}-${{ hashFiles('mobile-kotlin/gradle/libs.versions.toml') }}
|
|
restore-keys: |
|
|
gradle-${{ runner.os }}-
|
|
- run: ./gradlew :app:lint -q
|
|
working-directory: mobile-kotlin
|
|
|
|
test-backend:
|
|
runs-on: ubuntu-24.04
|
|
container: golang:${{ env.GO_VERSION }}-alpine
|
|
services:
|
|
postgres:
|
|
image: postgres:17-alpine
|
|
env:
|
|
POSTGRES_DB: kazier_test
|
|
POSTGRES_USER: kazier
|
|
POSTGRES_PASSWORD: kazier
|
|
steps:
|
|
- name: Install node + git (actions JS)
|
|
run: apk add --no-cache nodejs git
|
|
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.GITEA_TOKEN }}
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
/go/pkg/mod
|
|
~/.cache/go-build
|
|
key: go-${{ runner.os }}-${{ hashFiles('backend/go.sum') }}
|
|
restore-keys: |
|
|
go-${{ runner.os }}-
|
|
- run: go test ./...
|
|
working-directory: backend
|
|
env:
|
|
TEST_DATABASE_URL: postgres://kazier:kazier@postgres:5432/kazier_test?sslmode=disable
|
|
|
|
test-mobile:
|
|
runs-on: ubuntu-24.04
|
|
container: ${{ env.ANDROID_IMAGE }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.GITEA_TOKEN }}
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: gradle-${{ runner.os }}-${{ hashFiles('mobile-kotlin/gradle/libs.versions.toml') }}
|
|
restore-keys: |
|
|
gradle-${{ runner.os }}-
|
|
- run: ./gradlew :app:testDebugUnitTest -q
|
|
working-directory: mobile-kotlin
|
|
|
|
build-backend:
|
|
runs-on: ubuntu-24.04
|
|
container: golang:${{ env.GO_VERSION }}-alpine
|
|
needs: [lint-backend, test-backend]
|
|
steps:
|
|
- name: Install node + git (actions JS)
|
|
run: apk add --no-cache nodejs git
|
|
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.GITEA_TOKEN }}
|
|
- run: |
|
|
export VERSION="$(cat VERSION)"
|
|
CGO_ENABLED=0 GOOS=linux go build \
|
|
-trimpath \
|
|
-ldflags "-s -w -X main.version=${VERSION}" \
|
|
-o bin/kazier-server \
|
|
cmd/server/main.go
|
|
./bin/kazier-server --version
|
|
working-directory: backend
|
|
# v4 demande le service d'artefacts v2 (@actions/artifact v2) non fourni
|
|
# par Gitea (détecté comme GHES → GHESNotSupportedError). v3 reste le
|
|
# protocole legacy supporté par l'API artefacts de Gitea.
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: kazier-server
|
|
path: backend/bin/kazier-server
|
|
if-no-files-found: error
|
|
|
|
docker:
|
|
runs-on: ubuntu-24.04
|
|
needs: [build-backend]
|
|
# Push branches uniquement : pas sur PR (pas de build d'image à la review),
|
|
# pas sur tag (c'est release.yml qui construit, évite une course dans le
|
|
# registre entre le job `docker` et `release-docker`).
|
|
if: github.event_name == 'push' && github.ref_type == 'branch'
|
|
container:
|
|
image: docker:27
|
|
env:
|
|
DOCKER_HOST: tcp://docker:2375
|
|
DOCKER_TLS_CERTDIR: ""
|
|
services:
|
|
docker:
|
|
image: docker:27-dind
|
|
steps:
|
|
- name: Install node + git (actions JS)
|
|
run: apk add --no-cache nodejs git
|
|
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.GITEA_TOKEN }}
|
|
|
|
- name: Login registre Gitea
|
|
env:
|
|
CONTAINER_REGISTRY_TOKEN: ${{ secrets.CONTAINER_REGISTRY_TOKEN }}
|
|
CONTAINER_REGISTRY_USER: ${{ secrets.CONTAINER_REGISTRY_USER }}
|
|
run: |
|
|
: "${CONTAINER_REGISTRY_TOKEN:?CONTAINER_REGISTRY_TOKEN manquant (PAT scope write:package)}"
|
|
: "${CONTAINER_REGISTRY_USER:?CONTAINER_REGISTRY_USER manquant (propriétaire du PAT)}"
|
|
echo "$CONTAINER_REGISTRY_TOKEN" | docker login "$REGISTRY_HOST" -u "$CONTAINER_REGISTRY_USER" --password-stdin
|
|
echo "REGISTRY_IMAGE=${REGISTRY_HOST}/${{ github.repository_owner }}/kasier" >> "$GITHUB_ENV"
|
|
echo "IMAGE_TAG=${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
|
|
|
|
- name: Build + push (registre Gitea)
|
|
run: |
|
|
docker build \
|
|
--build-arg VERSION="$(cat VERSION)" \
|
|
--build-arg BUILD_DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
|
-t "$REGISTRY_IMAGE:$IMAGE_TAG" \
|
|
./backend
|
|
docker push "$REGISTRY_IMAGE:$IMAGE_TAG"
|
|
docker run --rm "$REGISTRY_IMAGE:$IMAGE_TAG" --version |