Files
allstarr/.github/workflows/ci.yml
T

221 lines
7.1 KiB
YAML

name: CI
on:
push:
branches: [main, master, dev, beta]
pull_request:
types: [opened, synchronize, reopened]
branches: [main, master, dev, beta]
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DOTNET_VERSION: "10.0.301"
NODE_VERSION: "22.23.1"
ALLSTARR_TEST_POSTGRES: "Host=127.0.0.1;Port=5432;Database=allstarr_test;Username=allstarr;Password=ci-postgres-password;SSL Mode=Disable"
jobs:
build-and-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:18.4-alpine3.23@sha256:996d0920e4ff9df1fc19dacb904492f3c1ec0ec1cc338f0ad7123be7731c5f5e
env:
POSTGRES_DB: allstarr_test
POSTGRES_USER: allstarr
POSTGRES_PASSWORD: ci-postgres-password
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U allstarr -d allstarr_test"
--health-interval 5s
--health-timeout 5s
--health-retries 20
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Setup .NET
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install PostgreSQL 18 client
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends ca-certificates curl
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl --fail --silent --show-error \
--output /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc \
https://www.postgresql.org/media/keys/ACCC4CF8.asc
. /etc/os-release
printf '%s\n' \
'Types: deb' \
'URIs: https://apt.postgresql.org/pub/repos/apt' \
"Suites: ${VERSION_CODENAME}-pgdg" \
"Architectures: $(dpkg --print-architecture)" \
'Components: main' \
'Signed-By: /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc' \
| sudo tee /etc/apt/sources.list.d/pgdg.sources >/dev/null
sudo apt-get update
sudo apt-get install -y --no-install-recommends postgresql-client-18
echo "/usr/lib/postgresql/18/bin" >> "$GITHUB_PATH"
export PATH="/usr/lib/postgresql/18/bin:$PATH"
pg_dump --version
pg_restore --version
- name: Restore dependencies
run: dotnet restore -p:NuGetAudit=true
- name: Build
run: dotnet build --configuration Release --no-restore -p:TreatWarningsAsErrors=true
- name: Test
run: >-
dotnet test --configuration Release --no-build
--filter "FullyQualifiedName!~allstarr.Tests.DurableStateTransferServiceTests"
--verbosity minimal
state-transfer-tests:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:18.4-alpine3.23@sha256:996d0920e4ff9df1fc19dacb904492f3c1ec0ec1cc338f0ad7123be7731c5f5e
env:
POSTGRES_DB: allstarr_test
POSTGRES_USER: allstarr
POSTGRES_PASSWORD: ci-postgres-password
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U allstarr -d allstarr_test"
--health-interval 5s
--health-timeout 5s
--health-retries 20
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Setup .NET
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: dotnet restore -p:NuGetAudit=true
- name: Build
run: dotnet build --configuration Release --no-restore -p:TreatWarningsAsErrors=true
- name: Test state transfer
run: >-
dotnet test --configuration Release --no-build
--filter "FullyQualifiedName~allstarr.Tests.DurableStateTransferServiceTests"
--verbosity minimal
csharp-format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Setup .NET
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: dotnet restore -p:NuGetAudit=true
- name: Verify C# formatting and analyzers
run: dotnet format allstarr.sln --no-restore --verify-no-changes --verbosity minimal
webui:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Setup Node
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: webui/package-lock.json
- name: Restore Svelte WebUI
working-directory: webui
run: |
npm ci
npx playwright install --with-deps chromium
- name: Verify Svelte WebUI
working-directory: webui
run: |
npm run check
npm test
npm run build
npm run check:budgets
npm run test:e2e
release-manifest:
needs:
- build-and-test
- state-transfer-tests
- csharp-format
- webui
- apple-contracts
- compose-contracts
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Create release manifest
run: bash tools/create-release-manifest.sh > allstarr-release-manifest.json
- name: Upload release manifest
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: release-manifest-${{ github.sha }}
path: allstarr-release-manifest.json
if-no-files-found: error
retention-days: 30
apple-contracts:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Setup Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: "3.10"
- name: Test Apple gateway contracts
working-directory: sidecars/apple-gateway
run: |
python -m pip install uv==0.11.29
UV_CACHE_DIR=/tmp/allstarr-uv-cache uv sync --frozen --extra test
UV_CACHE_DIR=/tmp/allstarr-uv-cache uv run --frozen --extra test pytest
compose-contracts:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Validate Compose contracts
env:
SPOTIFY_API_SESSION_COOKIE: ci-placeholder
run: |
docker compose -f docker-compose.yml config --quiet
docker compose -f docker-compose.yml --profile spotify-lyrics config --quiet
docker compose -f docker-compose.yml --profile apple config --quiet