Radarr/.github/workflows/build.yml
Cody Kickertz b413c390fd
fix(ci): make test failures block builds (#105)
- Remove continue-on-error from integration tests
- Set fail-on-error: true on test reporter

Closes #56

Co-authored-by: admin <admin@ardentleatherworks.com>
2025-12-21 13:59:45 -06:00

184 lines
5.7 KiB
YAML

name: CI
permissions:
packages: write
on:
workflow_dispatch:
push:
branches: [develop, main]
paths-ignore:
- ".github/**"
- "src/Radarr.Api.*/openapi.json"
pull_request:
paths-ignore:
- ".github/**"
- "src/NzbDrone.Core/Localization/Core"
- "src/Radarr.Api.*/openapi.json"
env:
DOTNET_VERSION: "8.0.405"
ALETHEIA_VERSION: 5.17.0
OUTPUT_FOLDER: ./_output
ARTIFACTS_FOLDER: ./_artifacts
TESTS_FOLDER: ./_tests
BUILD_SOURCEBRANCHNAME: ${{ github.head_ref || github.ref_name }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1
- uses: jdx/mise-action@v3
- name: Setup Environment Variables
id: variables
shell: bash
run: |
echo "SDK_PATH=${{ env.DOTNET_ROOT }}/sdk/${DOTNET_VERSION}" >> "$GITHUB_ENV"
echo "DATE=$(date --rfc-3339=date)" >> "$GITHUB_ENV"
- name: Cache NuGet packages
uses: actions/cache@v5
with:
path: _cache/nuget
key: nuget-${{ runner.os }}-${{ hashFiles('src/Directory.Packages.props', 'src/**/*.csproj', 'global.json') }}
restore-keys: |
nuget-${{ runner.os }}-
- name: Cache Node modules
uses: actions/cache@v5
with:
path: |
_cache/node
node_modules
key: node-${{ runner.os }}-${{ hashFiles('package.json', 'yarn.lock') }}
restore-keys: |
node-${{ runner.os }}-
- name: Cache MSBuild outputs
uses: actions/cache@v5
with:
path: _cache/msbuild
key: msbuild-${{ runner.os }}-${{ hashFiles('src/**/*.cs', 'src/**/*.csproj', 'src/**/*.targets', 'src/**/*.props') }}
restore-keys: |
msbuild-${{ runner.os }}-${{ hashFiles('src/**/*.cs', 'src/**/*.csproj', 'src/**/*.targets', 'src/**/*.props') }}
msbuild-${{ runner.os }}-
- name: Cache Webpack
uses: actions/cache@v5
with:
path: _cache/webpack
key: webpack-${{ runner.os }}-${{ hashFiles('frontend/src/**/*', 'yarn.lock') }}
restore-keys: |
webpack-${{ runner.os }}-${{ hashFiles('frontend/src/**/*', 'yarn.lock') }}
webpack-${{ runner.os }}-
- name: Build
shell: bash
run: ./build.sh --backend --frontend
env:
RADARRVERSION: ${{ env.ALETHEIA_VERSION }}.${{ github.run_number }}
- name: Prepare tests
run: |
mkdir -p _tests/bin
cp _output/net8.0/linux-x64/publish/Radarr _tests/bin/
chmod +x _tests/bin/Radarr
# Copy test DLLs to where test.sh expects them
cp _tests/net8.0/linux-x64/publish/*.dll _tests/
cp _tests/net8.0/linux-x64/publish/*.json _tests/ 2>/dev/null || true
find _tests -name "Radarr.Test.Dummy" -exec chmod a+x {} \;
- name: Unit tests with coverage
shell: bash
run: ./test.sh Linux Unit Coverage
- name: Integration tests
shell: bash
run: |
mkdir -p bin
cp -r _output/net8.0/linux-x64/publish/* bin/
chmod +x bin/Radarr
./test.sh Linux Integration Test
- name: Report test results
uses: dorny/test-reporter@v2
if: always()
with:
name: Unit Test Results
path: "**/TestResult.xml"
list-tests: "failed"
reporter: dotnet-nunit
fail-on-error: true
fail-on-empty: false
- name: Generate coverage report
uses: danielpalme/ReportGenerator-GitHub-Action@5
if: always()
with:
reports: "**/coverage.cobertura.xml"
targetdir: CoverageReport
reporttypes: "HtmlInline;Cobertura;TextSummary"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
if: always()
continue-on-error: true
with:
files: "**/coverage.cobertura.xml"
fail_ci_if_error: false
- name: Check coverage threshold
if: always()
shell: bash
run: |
if [ -f CoverageReport/Summary.txt ]; then
COVERAGE=$(grep -oP 'Line coverage: \K[\d.]+' CoverageReport/Summary.txt || echo "0")
echo "Line coverage: ${COVERAGE}%"
if (( $(echo "$COVERAGE < 60" | bc -l) )); then
echo "::warning::Coverage is below 60% threshold (${COVERAGE}%)"
fi
else
echo "::warning::Coverage report not found"
fi
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /usr/local/share/boost
sudo docker system prune -af
df -h
- uses: docker/setup-buildx-action@v3
- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=latest
type=raw,value=v${{ env.ALETHEIA_VERSION }}
type=raw,value=v${{ env.ALETHEIA_VERSION }}.${{ github.run_number }}
- uses: docker/login-action@v3
if: ${{ github.event_name == 'push' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile
platforms: "linux/amd64,linux/arm64"
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GIT_BRANCH=${{ env.BUILD_SOURCEBRANCHNAME }}
COMMIT_HASH=${{ github.event.pull_request.head.sha || github.sha }}
BUILD_DATE=${{ env.DATE }}