Heimdall Gitea / Detect CI scope (push) Successful in 7s
Heimdall Gitea / Build and tests (push) Successful in 14m48s
Heimdall Gitea / Publish versioned release (push) Skipped
Heimdall Gitea / Build and scan server image (push) Successful in 4m27s
Heimdall Gitea / Build and scan agent image (push) Successful in 15m42s
Heimdall Gitea / Publish Docker Hub latest tags (push) Successful in 1m27s
Heimdall Gitea / CI policy (push) Successful in 2s
Co-authored-by: Arnaud Dartois <admin@tordais.cc>
370 lines
16 KiB
YAML
370 lines
16 KiB
YAML
name: Heimdall Gitea
|
|
on:
|
|
pull_request:
|
|
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
|
|
env:
|
|
BUILD_SERVER_URL: ${{ gitea.server_url }}
|
|
BUILD_REPOSITORY: ${{ gitea.repository }}
|
|
jobs:
|
|
changes:
|
|
name: Detect CI scope
|
|
runs-on: [ubuntu-latest, build-agent]
|
|
outputs:
|
|
run_validation: ${{ steps.filter.outputs.run_validation }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
with:
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
- name: Detect changes that need validation
|
|
id: filter
|
|
env:
|
|
PR_BASE_SHA: ${{ gitea.event.pull_request.base.sha }}
|
|
PUSH_BEFORE_SHA: ${{ gitea.event.before }}
|
|
CURRENT_SHA: ${{ gitea.sha }}
|
|
EVENT_NAME: ${{ gitea.event_name }}
|
|
IS_RELEASE_TAG: ${{ startsWith(gitea.ref, 'refs/tags/v') }}
|
|
run: |
|
|
set -eu
|
|
|
|
if [ "$EVENT_NAME" = pull_request ]; then
|
|
changed_files="$(git diff --name-only "$PR_BASE_SHA...HEAD")"
|
|
elif [ "$IS_RELEASE_TAG" = true ]; then
|
|
echo 'run_validation=true' >> "$GITEA_OUTPUT"
|
|
exit 0
|
|
elif [ -n "$PUSH_BEFORE_SHA" ] && [ "$PUSH_BEFORE_SHA" != 0000000000000000000000000000000000000000 ]; then
|
|
changed_files="$(git diff --name-only "$PUSH_BEFORE_SHA" "$CURRENT_SHA")"
|
|
else
|
|
echo 'run_validation=true' >> "$GITEA_OUTPUT"
|
|
exit 0
|
|
fi
|
|
|
|
run_validation=false
|
|
while IFS= read -r path; do
|
|
case "$path" in
|
|
src/*|tests/*|Heimdall.slnx|global.json|Directory.Build.*|GitVersion*.yml|.dockerignore|.env.example|.gitea/workflows/*|scripts/ci/*|docker/*|install/*|models/*|Makefile)
|
|
run_validation=true
|
|
break
|
|
;;
|
|
esac
|
|
done <<EOF
|
|
$changed_files
|
|
EOF
|
|
|
|
echo "run_validation=$run_validation" >> "$GITEA_OUTPUT"
|
|
policy:
|
|
name: CI policy
|
|
if: always()
|
|
needs: [changes, verify, server_image, agent_image, dockerhub_latest, publish]
|
|
runs-on: [ubuntu-latest, build-agent]
|
|
steps:
|
|
- name: Require all applicable validation jobs to pass
|
|
env:
|
|
CHANGE_RESULT: ${{ needs.changes.result }}
|
|
RUN_VALIDATION: ${{ needs.changes.outputs.run_validation }}
|
|
VERIFY_RESULT: ${{ needs.verify.result }}
|
|
SERVER_IMAGE_RESULT: ${{ needs.server_image.result }}
|
|
AGENT_IMAGE_RESULT: ${{ needs.agent_image.result }}
|
|
DOCKERHUB_RESULT: ${{ needs.dockerhub_latest.result }}
|
|
RELEASE_RESULT: ${{ needs.publish.result }}
|
|
EVENT_NAME: ${{ gitea.event_name }}
|
|
REF: ${{ gitea.ref }}
|
|
run: |
|
|
set -eu
|
|
test "$CHANGE_RESULT" = success
|
|
|
|
if [ "$RUN_VALIDATION" != true ]; then
|
|
echo 'No source, test, build, or deployment inputs changed.'
|
|
exit 0
|
|
fi
|
|
|
|
test "$VERIFY_RESULT" = success
|
|
case "$EVENT_NAME:$REF" in
|
|
pull_request:*)
|
|
test "$SERVER_IMAGE_RESULT" = success
|
|
test "$AGENT_IMAGE_RESULT" = success
|
|
;;
|
|
push:refs/heads/main)
|
|
test "$SERVER_IMAGE_RESULT" = success
|
|
test "$AGENT_IMAGE_RESULT" = success
|
|
test "$DOCKERHUB_RESULT" = success
|
|
;;
|
|
push:refs/tags/v*)
|
|
test "$RELEASE_RESULT" = success
|
|
;;
|
|
esac
|
|
verify:
|
|
name: Build and tests
|
|
if: needs.changes.outputs.run_validation == 'true'
|
|
needs: [changes]
|
|
runs-on: [ubuntu-latest, build-agent]
|
|
container:
|
|
image: mcr.microsoft.com/dotnet/sdk:10.0-noble@sha256:de4fe90a98845d75910b9769662465c84de1a934665c431279d1382b2bddc02b
|
|
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: Reclaim old Heimdall build storage
|
|
run: bash scripts/ci/cleanup-docker.sh before
|
|
- name: CI script contracts
|
|
run: |
|
|
python3 -m unittest discover -s scripts/ci -p 'test_*.py'
|
|
python3 scripts/ci/check-efcore-usage.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: Camera access coverage gate
|
|
run: python3 scripts/ci/check-camera-access-coverage.py artifacts/tests artifacts/tests/plan.json
|
|
- 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: NuGet dependency security gate
|
|
run: bash scripts/ci/security.sh dependencies --no-restore
|
|
- name: Reclaim build storage after job
|
|
if: always()
|
|
run: |
|
|
if test -f scripts/ci/cleanup-docker.sh && command -v docker >/dev/null 2>&1; then
|
|
bash scripts/ci/cleanup-docker.sh after
|
|
fi
|
|
server_image:
|
|
name: Build and scan server image
|
|
if: needs.changes.outputs.run_validation == 'true' && (gitea.event_name == 'pull_request' || gitea.ref == 'refs/heads/main')
|
|
needs: [changes, verify]
|
|
runs-on: [ubuntu-latest, build-agent]
|
|
container:
|
|
image: mcr.microsoft.com/dotnet/sdk:10.0-noble@sha256:de4fe90a98845d75910b9769662465c84de1a934665c431279d1382b2bddc02b
|
|
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
|
|
- name: Checkout
|
|
uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
with:
|
|
persist-credentials: false
|
|
- name: Runner prerequisites
|
|
run: bash scripts/ci/bootstrap.sh
|
|
- name: Reclaim old build storage
|
|
run: bash scripts/ci/cleanup-docker.sh before
|
|
- name: Build server image
|
|
run: bash scripts/ci/images.sh server
|
|
- name: Scan server image
|
|
run: bash scripts/ci/security.sh server
|
|
- name: Push immutable server image to Docker Hub
|
|
if: gitea.ref == 'refs/heads/main'
|
|
env:
|
|
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
run: bash scripts/ci/push-images.sh server
|
|
- name: Reclaim build storage after job
|
|
if: always()
|
|
run: |
|
|
if test -f scripts/ci/cleanup-docker.sh && command -v docker >/dev/null 2>&1; then
|
|
bash scripts/ci/cleanup-docker.sh after
|
|
fi
|
|
agent_image:
|
|
name: Build and scan agent image
|
|
if: needs.changes.outputs.run_validation == 'true' && (gitea.event_name == 'pull_request' || gitea.ref == 'refs/heads/main')
|
|
needs: [changes, verify]
|
|
runs-on: [ubuntu-latest, build-agent]
|
|
container:
|
|
image: mcr.microsoft.com/dotnet/sdk:10.0-noble@sha256:de4fe90a98845d75910b9769662465c84de1a934665c431279d1382b2bddc02b
|
|
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
|
|
- name: Checkout
|
|
uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
with:
|
|
persist-credentials: false
|
|
- name: Runner prerequisites
|
|
run: bash scripts/ci/bootstrap.sh
|
|
- name: Reclaim old build storage
|
|
run: bash scripts/ci/cleanup-docker.sh before
|
|
- name: Build agent image
|
|
run: bash scripts/ci/images.sh agent
|
|
- name: Scan agent image
|
|
run: bash scripts/ci/security.sh agent
|
|
- name: Push immutable agent image to Docker Hub
|
|
if: gitea.ref == 'refs/heads/main'
|
|
env:
|
|
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
run: bash scripts/ci/push-images.sh agent
|
|
- name: Reclaim build storage after job
|
|
if: always()
|
|
run: |
|
|
if test -f scripts/ci/cleanup-docker.sh && command -v docker >/dev/null 2>&1; then
|
|
bash scripts/ci/cleanup-docker.sh after
|
|
fi
|
|
dockerhub_latest:
|
|
name: Publish Docker Hub latest tags
|
|
if: needs.changes.outputs.run_validation == 'true' && gitea.ref == 'refs/heads/main'
|
|
needs: [changes, server_image, agent_image]
|
|
runs-on: [ubuntu-latest, build-agent]
|
|
container:
|
|
image: mcr.microsoft.com/dotnet/sdk:10.0-noble@sha256:de4fe90a98845d75910b9769662465c84de1a934665c431279d1382b2bddc02b
|
|
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
|
|
- name: Checkout
|
|
uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
with:
|
|
persist-credentials: false
|
|
- name: Docker prerequisites
|
|
run: bash scripts/ci/bootstrap.sh
|
|
- name: Move latest tags after both image scans pass
|
|
env:
|
|
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
run: bash scripts/ci/push-images.sh latest
|
|
- name: Reclaim build storage after job
|
|
if: always()
|
|
run: |
|
|
if test -f scripts/ci/cleanup-docker.sh && command -v docker >/dev/null 2>&1; then
|
|
bash scripts/ci/cleanup-docker.sh after
|
|
fi
|
|
publish:
|
|
name: Publish versioned release
|
|
if: needs.changes.outputs.run_validation == 'true' && startsWith(gitea.ref, 'refs/tags/v')
|
|
needs: [changes, verify]
|
|
runs-on: [ubuntu-latest, build-agent]
|
|
container:
|
|
image: mcr.microsoft.com/dotnet/sdk:10.0-noble@sha256:de4fe90a98845d75910b9769662465c84de1a934665c431279d1382b2bddc02b
|
|
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 }}
|
|
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
RELEASE_SIGNING_KEY_B64: ${{ secrets.RELEASE_SIGNING_KEY_B64 }}
|
|
EXPECTED_BUILD_SERVER_URL: ${{ vars.RELEASE_SERVER_URL }}
|
|
run: bash scripts/ci/publish.sh
|