Some checks are pending
Dotnet build and test / build (pull_request) Has started running
97 lines
3.3 KiB
YAML
97 lines
3.3 KiB
YAML
# 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/*" ]
|
|
pull_request:
|
|
branches: [ "main", "release/*", "hotfix/*", "fix/*" ]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: docker
|
|
container:
|
|
image: pazof/yavsc-build-env:debian13-dotnet10-android36-jdk21-v5
|
|
steps:
|
|
- name: Clone yavsc
|
|
run: |
|
|
set -e
|
|
cd /src
|
|
echo "🔄 Cloning repository ${FORGEJO_SERVER_URL}/${FORGEJO_REPOSITORY}.git"
|
|
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
|
|
echo "✅ Checked out at $(git rev-parse HEAD) on $(git branch --show-current 2>/dev/null || echo detached HEAD)"
|
|
- name: Secret scan
|
|
run: |
|
|
echo "🔍 Scanning for secrets..."
|
|
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
|
|
- name: Start PostgreSQL
|
|
run: |
|
|
set -e
|
|
echo "🐘 Starting local PostgreSQL..."
|
|
if docker ps -a --format '{{.Names}}' | grep -qx 'yavsc-ci-postgres'; then
|
|
echo "PostgreSQL container already exists; restarting it"
|
|
docker rm -f yavsc-ci-postgres >/dev/null 2>&1 || true
|
|
fi
|
|
docker run -d \
|
|
--name yavsc-ci-postgres \
|
|
-e POSTGRES_USER=postgres \
|
|
-e POSTGRES_PASSWORD=postgres \
|
|
-e POSTGRES_DB=postgres \
|
|
-p 55432:5432 \
|
|
postgres:16
|
|
for i in $(seq 1 40); do
|
|
if pg_isready -h 127.0.0.1 -p 55432 -U postgres >/dev/null 2>&1; then
|
|
echo "✅ PostgreSQL is ready"
|
|
exit 0
|
|
fi
|
|
echo "PostgreSQL not ready yet ($i/40)"
|
|
sleep 2
|
|
done
|
|
echo "❌ PostgreSQL did not become ready in time" >&2
|
|
docker logs yavsc-ci-postgres || true
|
|
exit 1
|
|
- name: Test
|
|
env:
|
|
YAVSC_API_TEST_DB_PROVIDER: npgsql
|
|
YAVSC_API_TEST_NPGSQL_ADMIN_CONNECTION: Host=127.0.0.1;Port=55432;Database=postgres;Username=postgres;Password=postgres;Include Error Detail=true
|
|
run: |
|
|
echo "🚀 Lancement des tests..."
|
|
cd /src/_src && dotnet test \
|
|
--report-xunit \
|
|
--report-xunit-html \
|
|
--report-xunit-html-filename "test-results.html"
|
|
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
|