yavsc/.forgejo/workflows/buildAndTest.yml

83 lines
2.6 KiB
YAML
Raw Normal View History

2026-02-02 00:39:06 +00:00
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: Dotnet build and test
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
tags:
description: 'Test scenario tags'
required: false
type: boolean
push:
branches: [ "main", "release/*", "hotfix/*", "fix/*" ]
2026-02-02 00:39:06 +00:00
pull_request:
branches: [ "main", "release/*", "hotfix/*", "fix/*" ]
2026-02-02 00:39:06 +00:00
jobs:
build:
2026-08-16 13:03:17 +01:00
runs-on: docker
2026-11-10 14:59:40 +00:00
services:
postgres:
2026-11-10 16:20:48 +00:00
image: postgres:17
2026-11-10 14:59:40 +00:00
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 55432:5432
options: >-
--health-cmd="pg_isready -U postgres -d postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
2026-02-02 00:39:06 +00:00
steps:
- name: Clone yavsc
run: |
2026-09-13 03:25:09 +01:00
set -e
cd /src
2026-11-10 14:18:52 +00:00
echo "🔄 Cloning repository ${FORGEJO_SERVER_URL}/${FORGEJO_REPOSITORY}.git"
2026-09-19 18:00:09 +01:00
git clone "${FORGEJO_SERVER_URL}/${FORGEJO_REPOSITORY}.git" _src
cd _src
if [ -n "${GITHUB_REF:-}" ]; then
git fetch origin "$GITHUB_REF"
git checkout FETCH_HEAD
fi
git submodule update --init --recursive
2026-08-26 01:42:59 +01:00
echo "✅ Checked out at $(git rev-parse HEAD) on $(git branch --show-current 2>/dev/null || echo detached HEAD)"
2026-09-07 11:54:48 +01:00
- name: Secret scan
2026-09-07 12:08:57 +01:00
run: |
echo "🔍 Scanning for secrets..."
2026-11-09 15:32:01 +00:00
cd /src/_src && dotnet tool restore || true
dotnet picket git --verbose --redact --exit-code 1 --log-opts main..HEAD
- name: Build
run: |
echo "🏗️ Building the solution..."
cd /src/_src && dotnet build --verbosity normal
2026-02-02 00:39:06 +00:00
- name: Test
2026-11-09 21:20:26 +00:00
env:
YAVSC_API_TEST_DB_PROVIDER: npgsql
2026-11-09 22:02:53 +00:00
YAVSC_API_TEST_NPGSQL_ADMIN_CONNECTION: Host=127.0.0.1;Port=55432;Database=postgres;Username=postgres;Password=postgres;Include Error Detail=true
2026-08-25 23:06:25 +01:00
run: |
2026-08-26 05:44:46 +01:00
echo "🚀 Lancement des tests..."
cd /src/_src && dotnet test \
--report-xunit \
--report-xunit-html \
--report-xunit-html-filename "test-results.html"
2026-09-25 23:05:16 +01:00
TEST_EXIT_CODE=$?
echo "Test exit code: $TEST_EXIT_CODE"
if [ $TEST_EXIT_CODE -ne 0 ]; then
echo "❌ Tests failed with exit code $TEST_EXIT_CODE"
exit $TEST_EXIT_CODE
else
echo "✅ All tests passed successfully."
fi