Files
Heimdall/.gitea/workflows/build.yml
T
Arnaud Dartois 1144b7fb83
Heimdall Gitea / Build and tests (pull_request) Failing after 6m13s
Heimdall Gitea / Publish versioned release (pull_request) Skipped
ci: split affected tests and publish main images to Docker Hub
2026-10-23 22:23:11 +02:00

173 lines
6.9 KiB
YAML

name: Heimdall Gitea
on:
pull_request:
paths:
- 'src/**'
- 'tests/**'
- 'Heimdall.slnx'
- 'global.json'
- 'Directory.Build.*'
- 'GitVersion*.yml'
- '.dockerignore'
- '.env.example'
- '.gitea/workflows/**'
- 'scripts/ci/**'
- 'docker/**'
- 'install/**'
- 'models/**'
- 'Makefile'
push:
branches: [main]
tags: ['v*']
paths:
- 'src/**'
- 'tests/**'
- 'Heimdall.slnx'
- 'global.json'
- 'Directory.Build.*'
- 'GitVersion*.yml'
- '.dockerignore'
- '.env.example'
- '.gitea/workflows/**'
- 'scripts/ci/**'
- 'docker/**'
- 'install/**'
- 'models/**'
- 'Makefile'
permissions:
contents: read
jobs:
verify:
name: Build and tests
runs-on: [ubuntu-latest, build-agent]
container:
image: mcr.microsoft.com/dotnet/sdk:10.0-noble@sha256:0d99ebf1ccad15037b5c98c9fe8979d6b8dbac23812feae2277a0b277b5c5ffa
services:
postgres:
image: postgres:17-alpine@sha256:b0f9560a2de083e2cc7382e75f808c7381a32852a7ec49117deedb300e552b24
env:
POSTGRES_DB: postgres
POSTGRES_USER: heimdall_ci
POSTGRES_PASSWORD: ephemeral-ci-only
options: --health-cmd 'pg_isready -U heimdall_ci -d postgres' --health-interval 5s --health-timeout 5s --health-retries 20
env:
DATABASE_URL: Host=postgres;Port=5432;Database=postgres;Username=heimdall_ci;Password=ephemeral-ci-only
PGHOST: postgres
PGUSER: heimdall_ci
PGPASSWORD: ephemeral-ci-only
PGDATABASE: postgres
DOTNET_CLI_TELEMETRY_OPTOUT: '1'
DOTNET_NOLOGO: '1'
BUILD_REF: ${{ gitea.ref }}
BUILD_REPOSITORY: ${{ gitea.repository }}
BUILD_RUN_ID: ${{ gitea.run_id }}
GITEA_EVENT_NAME: ${{ gitea.event_name }}
steps:
- name: Prepare action runtime before checkout
run: |
apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends curl git ca-certificates xz-utils
test "$(uname -m)" = x86_64
curl --fail --silent --show-error --location https://nodejs.org/dist/v22.23.3/node-v22.23.3-linux-x64.tar.xz -o /tmp/node.tar.xz
echo 'df450af89261115ef9f9e3830c3eeb2cc9213b63c720b1af623cb5dcbe2e02de /tmp/node.tar.xz' | sha256sum --check
tar -xJf /tmp/node.tar.xz -C /usr/local --strip-components=1
ln -sf /usr/local/bin/node /usr/bin/node
rm /tmp/node.tar.xz
node --version
- name: Checkout
uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
fetch-depth: 0
persist-credentials: false
- name: Runner prerequisites
run: bash scripts/ci/bootstrap.sh
- name: CI script contracts
run: python3 -m unittest discover -s scripts/ci -p 'test_*.py'
- name: Validate Compose and build .NET solution
run: |
mkdir -p artifacts/tests artifacts/security
dotnet --info > artifacts/dotnet-info.txt
bash scripts/ci/validate-compose.sh
dotnet restore Heimdall.slnx --locked-mode
dotnet build Heimdall.slnx -c Release --no-restore -m:2
- name: Plan affected test suites
run: python3 scripts/ci/test-plan.py
- name: Agent tests
run: bash scripts/ci/test-suite.sh Heimdall.Agent.Tests
- name: API tests
run: bash scripts/ci/test-suite.sh Heimdall.Api.Tests
- name: Application tests
run: bash scripts/ci/test-suite.sh Heimdall.Application.Tests
- name: Domain tests
run: bash scripts/ci/test-suite.sh Heimdall.Domain.Tests
- name: Infrastructure tests
run: bash scripts/ci/test-suite.sh Heimdall.Infrastructure.Tests
- name: Integration tests
run: bash scripts/ci/test-suite.sh Heimdall.IntegrationTests
- name: Web tests
run: bash scripts/ci/test-suite.sh Heimdall.Web.Tests
- name: Browser tests
run: bash scripts/ci/test-suite.sh Heimdall.E2E.Tests
- name: Publish server PWA and agent archives
run: bash scripts/ci/package.sh
- name: Build server and CPU agent images
run: bash scripts/ci/images.sh
- name: Dependency and image security gates
run: bash scripts/ci/security.sh
- name: Publish server and agent images to Docker Hub
if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/main'
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DOCKERHUB_NAMESPACE: eltruncho
run: bash scripts/ci/push-dockerhub.sh
publish:
name: Publish versioned release
if: startsWith(gitea.ref, 'refs/tags/v')
needs: [verify]
runs-on: [ubuntu-latest, build-agent]
container:
image: mcr.microsoft.com/dotnet/sdk:10.0-noble@sha256:0d99ebf1ccad15037b5c98c9fe8979d6b8dbac23812feae2277a0b277b5c5ffa
permissions:
contents: read
actions: read
steps:
- name: Prepare action runtime before checkout
run: |
apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends curl git ca-certificates xz-utils
test "$(uname -m)" = x86_64
curl --fail --silent --show-error --location https://nodejs.org/dist/v22.23.3/node-v22.23.3-linux-x64.tar.xz -o /tmp/node.tar.xz
echo 'df450af89261115ef9f9e3830c3eeb2cc9213b63c720b1af623cb5dcbe2e02de /tmp/node.tar.xz' | sha256sum --check
tar -xJf /tmp/node.tar.xz -C /usr/local --strip-components=1
ln -sf /usr/local/bin/node /usr/bin/node
rm /tmp/node.tar.xz
node --version
- uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with:
fetch-depth: 0
persist-credentials: false
- run: bash scripts/ci/bootstrap.sh
- name: Require a release from main history
run: git merge-base --is-ancestor HEAD origin/main
- name: Rebuild release archives from verified commit
env:
BUILD_REF: ${{ gitea.ref }}
BUILD_REPOSITORY: ${{ gitea.repository }}
BUILD_RUN_ID: ${{ gitea.run_id }}
run: bash scripts/ci/package.sh
- name: Publish immutable images and draft release
env:
BUILD_REF: ${{ gitea.ref }}
BUILD_REPOSITORY: ${{ gitea.repository }}
BUILD_SERVER_URL: ${{ gitea.server_url }}
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
AGENT_REGISTRY_USER: ${{ secrets.AGENT_REGISTRY_USER }}
AGENT_REGISTRY_TOKEN: ${{ secrets.AGENT_REGISTRY_TOKEN }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
RELEASE_SIGNING_KEY_B64: ${{ secrets.RELEASE_SIGNING_KEY_B64 }}
run: bash scripts/ci/publish.sh