refactor(ci): use ci-full mega-action (identical across all projects)
All 3 projects now share the exact same CI pipeline via nonobis/templates/.forgejo/actions/ci-full. Only params differ.
This commit is contained in:
1 parent
cd7bdea66c
commit
ff65c73724
1 file changed
+17
-267
+17
-267
@@ -1,9 +1,4 @@
|
||||
# Heimdall — CI Pipeline (unifiée + Vault)
|
||||
# Templates : https://forgejo.tordais.cc/nonobis/templates
|
||||
# Bootstrap secret : TEMPLATES_PAT (checkout templates)
|
||||
# Tous les autres secrets viennent de Vault via OIDC (JWT Forgejo)
|
||||
# ⚠️ PAS DE FALLBACK — Vault est la seule source de secrets
|
||||
|
||||
# CI Pipeline (unifiée via nonobis/templates)
|
||||
name: CI
|
||||
|
||||
on:
|
||||
@@ -15,34 +10,9 @@ on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
enable-openid-connect: true
|
||||
|
||||
env:
|
||||
DOTNET_VERSION: "10.0"
|
||||
NODE_VERSION: "20"
|
||||
DOTNET_CLI_TELEMETRY_OPTOUT: 1
|
||||
DOTNET_NOLOGO: 1
|
||||
ASPNETCORE_ENVIRONMENT: Testing
|
||||
|
||||
# Features toggle
|
||||
PG_ENABLED: "true"
|
||||
GITVERSION_ENABLED: "false"
|
||||
NODE_ENABLED: "false"
|
||||
E2E_ENABLED: "false"
|
||||
SONAR_ENABLED: "false"
|
||||
TRIVY_ENABLED: "false"
|
||||
|
||||
# Vault
|
||||
VAULT_URL: "https://vault.tordais.cc"
|
||||
VAULT_ROLE: "heimdall-ci"
|
||||
|
||||
# Project
|
||||
PROJECT_NAME: heimdall
|
||||
SOLUTION: "*.slnx"
|
||||
DOCKERFILE: docker/Dockerfile
|
||||
DOCKER_IMAGE: nonobis/heimdall
|
||||
DOCKER_EXTRA_IMAGES: "nonobis/heimdall-agent"
|
||||
DOCKER_EXTRA_DOCKERFILES: "docker/Dockerfile.agent"
|
||||
|
||||
concurrency:
|
||||
group: ci-${{ forgejo.ref }}
|
||||
@@ -51,250 +21,30 @@ concurrency:
|
||||
jobs:
|
||||
ci:
|
||||
runs-on: debian-12
|
||||
enable-openid-connect: true
|
||||
steps:
|
||||
# ── 1. CHECKOUT ────────────────────────────────────
|
||||
- name: Checkout project
|
||||
uses: https://forgejo.tordais.cc/actions/checkout@v4
|
||||
- uses: https://forgejo.tordais.cc/actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Checkout CI templates
|
||||
uses: https://forgejo.tordais.cc/actions/checkout@v4
|
||||
- uses: https://forgejo.tordais.cc/actions/checkout@v4
|
||||
with:
|
||||
repository: nonobis/templates
|
||||
token: ${{ secrets.TEMPLATES_PAT }}
|
||||
path: .ci
|
||||
ref: main
|
||||
|
||||
# ── 1b. VAULT OIDC (obligatoire si VAULT_URL défini) ──
|
||||
# Vault fournit : DOCKER_USERNAME, DOCKER_PASSWORD, REGISTRY_TOKEN, SONAR_TOKEN
|
||||
- if: env.VAULT_URL != ''
|
||||
uses: ./.ci/.forgejo/actions/vault-auth
|
||||
id: vault-auth
|
||||
- uses: ./.ci/.forgejo/actions/ci-full
|
||||
with:
|
||||
vault-url: ${{ env.VAULT_URL }}
|
||||
role: ${{ env.VAULT_ROLE }}
|
||||
fallback: 'false'
|
||||
|
||||
- if: env.VAULT_URL != ''
|
||||
uses: ./.ci/.forgejo/actions/vault-secrets
|
||||
with:
|
||||
vault-url: ${{ env.VAULT_URL }}
|
||||
vault-token: ${{ steps.vault-auth.outputs.token }}
|
||||
paths: shared,${{ env.PROJECT_NAME }}
|
||||
|
||||
# ── 2. SYSTEM ──────────────────────────────────────
|
||||
- name: Install system dependencies
|
||||
if: env.PG_ENABLED == 'true' || env.E2E_ENABLED == 'true'
|
||||
run: |
|
||||
apt-get -qq update && apt-get install -y -qq --no-install-recommends \
|
||||
ca-certificates curl gnupg wget python3 ffmpeg
|
||||
|
||||
# ── 3. POSTGRESQL ──────────────────────────────────
|
||||
- if: env.PG_ENABLED == 'true'
|
||||
uses: ./.ci/.forgejo/actions/postgres-start
|
||||
with:
|
||||
database: ${{ env.PROJECT_NAME }}_test
|
||||
username: ${{ env.PROJECT_NAME }}
|
||||
password: ${{ env.PROJECT_NAME }}
|
||||
|
||||
# ── 4. .NET + CACHES ──────────────────────────────
|
||||
- name: Setup .NET ${{ env.DOTNET_VERSION }}
|
||||
uses: https://forgejo.tordais.cc/actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: ${{ env.DOTNET_VERSION }}
|
||||
|
||||
- name: Cache NuGet packages
|
||||
uses: https://forgejo.tordais.cc/actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.nuget/packages
|
||||
~/.local/share/NuGet/http-cache
|
||||
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '**/*.slnx', '**/Directory.Build.props') }}
|
||||
restore-keys: |
|
||||
nuget-${{ runner.os }}-
|
||||
|
||||
- name: Cache .NET tools (GitVersion)
|
||||
if: env.GITVERSION_ENABLED == 'true'
|
||||
uses: https://forgejo.tordais.cc/actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.dotnet/tools
|
||||
~/.dotnet/tool-resolver-cache
|
||||
key: dotnet-tools-${{ runner.os }}-6.8.1
|
||||
|
||||
# ── 5. GITVERSION ──────────────────────────────────
|
||||
- if: env.GITVERSION_ENABLED == 'true'
|
||||
uses: ./.ci/.forgejo/actions/setup-gitversion
|
||||
id: version
|
||||
|
||||
# ── 6. NODE.JS (optional) ──────────────────────────
|
||||
- if: env.NODE_ENABLED == 'true'
|
||||
uses: https://forgejo.tordais.cc/actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- if: env.NODE_ENABLED == 'true'
|
||||
uses: https://forgejo.tordais.cc/actions/cache@v4
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: npm-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
npm-${{ runner.os }}-
|
||||
|
||||
- name: npm ci
|
||||
if: env.NODE_ENABLED == 'true'
|
||||
run: npm ci
|
||||
continue-on-error: true
|
||||
|
||||
# ── 7. BUILD ───────────────────────────────────────
|
||||
- name: Restore
|
||||
run: dotnet restore ${{ env.SOLUTION }} --nologo
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
VERSION=""
|
||||
if [ "$GITVERSION_ENABLED" = "true" ] && [ -n "${{ steps.version.outputs.version }}" ]; then
|
||||
VERSION="-p:Version=${{ steps.version.outputs.version }} -p:DisableGitVersionTask=true"
|
||||
fi
|
||||
dotnet build ${{ env.SOLUTION }} --no-restore -c Release --nologo /maxcpucount $VERSION
|
||||
|
||||
- name: Publish (for E2E / Docker)
|
||||
if: env.E2E_ENABLED == 'true' || contains(env.DOCKERFILE, 'Dockerfile')
|
||||
run: |
|
||||
VERSION=""
|
||||
if [ "$GITVERSION_ENABLED" = "true" ]; then
|
||||
VERSION="-p:Version=${{ steps.version.outputs.version }}"
|
||||
fi
|
||||
dotnet build ${{ env.SOLUTION }} --no-restore -c Release --nologo /maxcpucount $VERSION
|
||||
|
||||
# ── 8. TESTS ───────────────────────────────────────
|
||||
- name: Run tests
|
||||
env:
|
||||
DATABASE_URL: ${{ env.PG_ENABLED == 'true' && format('Host=localhost;Port=5432;Database={0}_test;Username={0};Password={0}', env.PROJECT_NAME) || '' }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p /tmp/coverage
|
||||
|
||||
# Find test projects
|
||||
TEST_PROJECTS=$(find . -type f -name '*.csproj' -path '*/tests/*' -not -path '*/node_modules/*' 2>/dev/null || true)
|
||||
if [ -z "$TEST_PROJECTS" ]; then
|
||||
echo "No test projects found"
|
||||
exit 0
|
||||
fi
|
||||
FAIL=0
|
||||
for proj in $TEST_PROJECTS; do
|
||||
NAME=$(basename "$(dirname "$proj")")
|
||||
echo "→ Testing: $NAME"
|
||||
# Note: use Coverlet msbuild properties (not --collect) to avoid quoting issues
|
||||
if dotnet test "$proj" --no-build -c Release --nologo \
|
||||
-p:CoverletOutputFormat=cobertura \
|
||||
-p:CoverletOutput=/tmp/coverage/$NAME/ \
|
||||
-p:CollectCoverage=true; then
|
||||
echo " ✅ $NAME passed"
|
||||
else
|
||||
echo " ❌ $NAME failed"
|
||||
FAIL=1
|
||||
fi
|
||||
done
|
||||
exit $FAIL
|
||||
|
||||
# ── 9. COVERAGE REPORT ─────────────────────────────
|
||||
- if: always()
|
||||
uses: ./.ci/.forgejo/actions/coverage-report
|
||||
|
||||
# ── 10. E2E TESTS ──────────────────────────────────
|
||||
- if: env.E2E_ENABLED == 'true' && (forgejo.ref == 'refs/heads/main' || forgejo.event_name == 'pull_request')
|
||||
uses: ./.ci/.forgejo/actions/e2e-playwright
|
||||
|
||||
# ── 11. SONARQUBE ──────────────────────────────────
|
||||
- if: env.SONAR_ENABLED == 'true' && (forgejo.ref == 'refs/heads/main' || forgejo.event_name == 'pull_request')
|
||||
uses: ./.ci/.forgejo/actions/sonar-dotnet
|
||||
with:
|
||||
sonar-project-key: ${{ env.PROJECT_NAME }}
|
||||
sonar-host-url: ${{ env.SONAR_HOST_URL }}
|
||||
sonar-token: ${{ env.SONAR_TOKEN }}
|
||||
solution-path: ${{ env.SOLUTION }}
|
||||
|
||||
# ── 12. DOCKER BUILD ───────────────────────────────
|
||||
- name: Install Docker CLI
|
||||
if: forgejo.ref == 'refs/heads/main' && env.DOCKERFILE != ''
|
||||
run: |
|
||||
if ! command -v docker &>/dev/null; then
|
||||
apt-get install -y -qq --no-install-recommends docker.io
|
||||
fi
|
||||
|
||||
- name: Build Docker image(s)
|
||||
if: forgejo.ref == 'refs/heads/main' && env.DOCKERFILE != ''
|
||||
env:
|
||||
IMAGE: ${{ env.DOCKER_IMAGE }}
|
||||
EXTRA_IMAGES: ${{ env.DOCKER_EXTRA_IMAGES }}
|
||||
EXTRA_DFS: ${{ env.DOCKER_EXTRA_DOCKERFILES }}
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
run: |
|
||||
build_img() {
|
||||
local df="$1" img="$2"
|
||||
local tags="-t ${img}:latest"
|
||||
[ -n "$VERSION" ] && tags="$tags -t ${img}:${VERSION}"
|
||||
tags="$tags -t ${img}:${{ forgejo.sha }}"
|
||||
docker build -f "$df" $tags .
|
||||
}
|
||||
|
||||
build_img "${{ env.DOCKERFILE }}" "$IMAGE"
|
||||
|
||||
# Extra images (agent, migrator, etc.)
|
||||
if [ -n "$EXTRA_IMAGES" ] && [ -n "$EXTRA_DFS" ]; then
|
||||
IFS=' ' read -ra IMG_LIST <<< "$EXTRA_IMAGES"
|
||||
IFS=' ' read -ra DF_LIST <<< "$EXTRA_DFS"
|
||||
for i in "${!IMG_LIST[@]}"; do
|
||||
[ -n "${IMG_LIST[$i]}" ] && [ -n "${DF_LIST[$i]}" ] && build_img "${DF_LIST[$i]}" "${IMG_LIST[$i]}"
|
||||
done
|
||||
fi
|
||||
|
||||
- name: Push Docker images
|
||||
if: forgejo.ref == 'refs/heads/main' && env.DOCKERFILE != ''
|
||||
env:
|
||||
DOCKER_USER: ${{ env.DOCKER_USERNAME }}
|
||||
DOCKER_PASS: ${{ env.DOCKER_PASSWORD }}
|
||||
run: |
|
||||
if [ -z "$DOCKER_USER" ] || [ -z "$DOCKER_PASS" ]; then
|
||||
echo "Docker credentials not set — skipping push"
|
||||
exit 0
|
||||
fi
|
||||
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
|
||||
|
||||
push_img() {
|
||||
local img="$1"
|
||||
docker push "${img}:latest"
|
||||
[ -n "$VERSION" ] && docker push "${img}:${VERSION}" || true
|
||||
docker push "${img}:${{ forgejo.sha }}"
|
||||
}
|
||||
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
push_img "${{ env.DOCKER_IMAGE }}"
|
||||
|
||||
EXTRA="${{ env.DOCKER_EXTRA_IMAGES }}"
|
||||
if [ -n "$EXTRA" ]; then
|
||||
for img in $EXTRA; do [ -n "$img" ] && push_img "$img"; done
|
||||
fi
|
||||
|
||||
# Forgejo Registry
|
||||
if [ -n "${{ secrets.REGISTRY_TOKEN }}" ] && [ -n "${{ secrets.REGISTRY_URL }}" ]; then
|
||||
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "${{ secrets.REGISTRY_URL }}" \
|
||||
-u "${{ secrets.REGISTRY_USER || 'nonobis' }}" --password-stdin || true
|
||||
REG="${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER || 'nonobis' }}"
|
||||
docker tag "${{ env.DOCKER_IMAGE }}:latest" "$REG/${{ github.repository }}:latest" 2>/dev/null || true
|
||||
[ -n "$VERSION" ] && docker tag "${{ env.DOCKER_IMAGE }}:latest" "$REG/${{ github.repository }}:$VERSION" 2>/dev/null || true
|
||||
docker push "$REG/${{ github.repository }}:latest" 2>/dev/null || true
|
||||
[ -n "$VERSION" ] && docker push "$REG/${{ github.repository }}:$VERSION" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# ── 13. TRIVY SCAN ─────────────────────────────────
|
||||
- if: env.TRIVY_ENABLED == 'true' && forgejo.ref == 'refs/heads/main' && env.DOCKERFILE != ''
|
||||
uses: ./.ci/.forgejo/actions/trivy-scan
|
||||
with:
|
||||
image: ${{ env.DOCKER_IMAGE }}:${{ steps.version.outputs.version }}
|
||||
|
||||
# ── 14. CLEANUP ────────────────────────────────────
|
||||
- if: always()
|
||||
uses: ./.ci/.forgejo/actions/cleanup-safe
|
||||
project: heimdall
|
||||
vault-url: https://vault.tordais.cc
|
||||
pg-enabled: 'true'
|
||||
gitversion-enabled: 'false'
|
||||
node-enabled: 'false'
|
||||
e2e-enabled: 'false'
|
||||
sonar-enabled: 'false'
|
||||
trivy-enabled: 'false'
|
||||
dockerfile: docker/Dockerfile
|
||||
docker-image: nonobis/heimdall
|
||||
docker-extra-images: nonobis/heimdall-agent
|
||||
docker-extra-dockerfiles: docker/Dockerfile.agent
|
||||
Reference in new issue
Block a user