mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-04-19 19:14:51 +00:00
81 lines
No EOL
2.9 KiB
YAML
81 lines
No EOL
2.9 KiB
YAML
on: [ push, pull_request ]
|
|
name: Continuous Integration
|
|
|
|
# Inspired by osu! lazer's CI
|
|
# https://github.com/ppy/osu/blob/e12249f1270a22cf5811a8bb7a9ee44f2c0250db/.github/workflows/ci.yml
|
|
|
|
jobs:
|
|
test:
|
|
name: Build & Test
|
|
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
|
runs-on: ${{matrix.os.fullName}}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os:
|
|
- { prettyName: Linux, fullName: ubuntu-latest, database: true, webTest: true }
|
|
timeout-minutes: 5
|
|
env:
|
|
DB_DATABASE: lighthouse
|
|
DB_USER: root
|
|
DB_PASSWORD: lighthouse
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Start MySQL
|
|
if: ${{ matrix.os.database }}
|
|
uses: shogo82148/actions-setup-mysql@v1
|
|
with:
|
|
mysql-version: '8.0'
|
|
root-password: ${{ env.DB_PASSWORD }}
|
|
|
|
- name: Create Lighthouse Database
|
|
if: ${{ matrix.os.database }}
|
|
run: mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} -h 127.0.0.1 -e "CREATE DATABASE ${{ env.DB_DATABASE }};";
|
|
|
|
- name: Install .NET 6.0
|
|
uses: actions/setup-dotnet@v1
|
|
with:
|
|
dotnet-version: "6.0.x"
|
|
|
|
- name: Compile
|
|
run: dotnet build -c Debug
|
|
|
|
- name: Run tests on ProjectLighthouse.Tests
|
|
continue-on-error: true
|
|
run: dotnet test --no-build --logger "trx;LogFileName=${{github.workspace}}/TestResults-${{matrix.os.prettyName}}-Tests.trx" ProjectLighthouse.Tests
|
|
|
|
- name: Run tests on ProjectLighthouse.Tests.GameApiTests
|
|
continue-on-error: true
|
|
run: dotnet test --no-build --logger "trx;LogFileName=${{github.workspace}}/TestResults-${{matrix.os.prettyName}}-GameApiTests.trx" ProjectLighthouse.Tests.GameApiTests
|
|
|
|
- name: Run tests on ProjectLighthouse.Tests.WebsiteTests
|
|
if: ${{ matrix.os.webTest }}
|
|
continue-on-error: true
|
|
run: dotnet test --no-build --logger "trx;LogFileName=${{github.workspace}}/TestResults-${{matrix.os.prettyName}}-WebsiteTests.trx" ProjectLighthouse.Tests.WebsiteTests
|
|
|
|
# Attempt to upload results even if test fails.
|
|
# https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#always
|
|
- name: Upload Test Results
|
|
uses: actions/upload-artifact@v2
|
|
if: ${{ always() }}
|
|
with:
|
|
name: lighthouse-test-results-${{matrix.os.prettyName}}
|
|
path: ${{github.workspace}}/TestResults-${{matrix.os.prettyName}}-*.trx
|
|
|
|
- name: Process Test Results
|
|
id: process-trx
|
|
if: ${{ always() }}
|
|
uses: im-open/process-dotnet-test-results@v2.0.2
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
create-status-check: false
|
|
create-pr-comment: false
|
|
update-comment-if-one-exists: false
|
|
|
|
- name: Check Test Results
|
|
if: steps.process-trx.outputs.test-outcome == 'Failed'
|
|
run: |
|
|
echo "There were test failures."
|
|
exit 1 |