Change on-push workflow to run unit tests

This changes workflows to run unit tests for every new commit (including
PRs). A new release will only be published if all tests pass on the
master branch.
This commit is contained in:
peelz
2022-08-06 01:30:05 -04:00
parent 508f8d3dcd
commit 3de2d8e550
6 changed files with 164 additions and 81 deletions

View File

@@ -1,81 +0,0 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: .NET Pre-Release
on:
push:
branches: [ master ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
include-prerelease: true
dotnet-version: |
6.0.x
5.0.x
- name: Restore dependencies
run: dotnet restore LinuxSolution.sln
- name: Build
run: dotnet build LinuxSolution.sln --no-restore
- name: Test
run: dotnet test LinuxSolution.sln --no-build --verbosity normal
- name: Publish WindowsServer
run: dotnet publish Barotrauma/BarotraumaServer/WindowsServer.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r win-x64 \/p:Platform="x64"
- name: Publish WindowsClient
run: dotnet publish Barotrauma/BarotraumaClient/WindowsClient.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r win-x64 \/p:Platform="x64"
- name: Publish LinuxServer
run: dotnet publish Barotrauma/BarotraumaServer/LinuxServer.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r linux-x64 \/p:Platform="x64"
- name: Publish LinuxClient
run: dotnet publish Barotrauma/BarotraumaClient/LinuxClient.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r linux-x64 \/p:Platform="x64"
- name: Publish MacServer
run: dotnet publish Barotrauma/BarotraumaServer/MacServer.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r osx-x64 \/p:Platform="x64"
- name: Publish MacClient
run: dotnet publish Barotrauma/BarotraumaClient/MacClient.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r osx-x64 \/p:Platform="x64"
- name: Archive Windows Release
uses: thedoctor0/zip-release@main
with:
type: zip
filename: barotrauma_lua_windows.zip
directory: Barotrauma/bin/ReleaseWindows/netcoreapp3.1/win-x64/publish
- name: Archive Linux Release
uses: thedoctor0/zip-release@main
with:
type: zip
filename: barotrauma_lua_linux.zip
directory: Barotrauma/bin/ReleaseLinux/netcoreapp3.1/linux-x64/publish
- name: Archive Mac Release
uses: thedoctor0/zip-release@main
with:
type: zip
filename: barotrauma_lua_mac.zip
directory: Barotrauma/bin/ReleaseMac/netcoreapp3.1/osx-x64/publish
- name: Automatic Release
uses: marvinpinto/action-automatic-releases@v1.2.1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: latest
prerelease: false
title: Automatic Build
files: |
Barotrauma/bin/ReleaseWindows/netcoreapp3.1/win-x64/publish/barotrauma_lua_windows.zip
Barotrauma/bin/ReleaseLinux/netcoreapp3.1/linux-x64/publish/barotrauma_lua_linux.zip
Barotrauma/bin/ReleaseMac/netcoreapp3.1/osx-x64/publish/barotrauma_lua_mac.zip

17
.github/workflows/on-push-master.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: On push to master branch
on:
push:
branches: [master]
jobs:
run-tests:
uses: ./.github/workflows/run-tests.yml
with:
ref: ${{ github.event.ref }}
publish-release:
needs: [run-tests]
uses: ./.github/workflows/publish-release.yml

View File

@@ -0,0 +1,13 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: On push to a secondary branch
on:
push:
branches-ignore: [master]
jobs:
run-tests:
uses: ./.github/workflows/run-tests.yml
with:
ref: ${{ github.event.ref }}

12
.github/workflows/on-push-pr.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: On push to a PR
on:
pull_request:
jobs:
run-tests-for-pr:
uses: ./.github/workflows/run-tests.yml
with:
ref: ${{ github.event.pull_request.head.sha }}

72
.github/workflows/publish-release.yml vendored Normal file
View File

@@ -0,0 +1,72 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Publish release
on:
workflow_dispatch:
workflow_call:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: |
3.1.x
6.0.x
- name: "Build: WindowsServer"
run: dotnet publish Barotrauma/BarotraumaServer/WindowsServer.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r win-x64 \/p:Platform="x64"
- name: "Build: WindowsClient"
run: dotnet publish Barotrauma/BarotraumaClient/WindowsClient.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r win-x64 \/p:Platform="x64"
- name: "Build: LinuxServer"
run: dotnet publish Barotrauma/BarotraumaServer/LinuxServer.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r linux-x64 \/p:Platform="x64"
- name: "Build: LinuxClient"
run: dotnet publish Barotrauma/BarotraumaClient/LinuxClient.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r linux-x64 \/p:Platform="x64"
- name: "Build: MacServer"
run: dotnet publish Barotrauma/BarotraumaServer/MacServer.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r osx-x64 \/p:Platform="x64"
- name: "Build: MacClient"
run: dotnet publish Barotrauma/BarotraumaClient/MacClient.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r osx-x64 \/p:Platform="x64"
- name: "Create zip file: windows"
uses: thedoctor0/zip-release@main
with:
type: zip
filename: barotrauma_lua_windows.zip
directory: Barotrauma/bin/ReleaseWindows/netcoreapp3.1/win-x64/publish
- name: "Create zip file: linux"
uses: thedoctor0/zip-release@main
with:
type: zip
filename: barotrauma_lua_linux.zip
directory: Barotrauma/bin/ReleaseLinux/netcoreapp3.1/linux-x64/publish
- name: "Create zip file: mac"
uses: thedoctor0/zip-release@main
with:
type: zip
filename: barotrauma_lua_mac.zip
directory: Barotrauma/bin/ReleaseMac/netcoreapp3.1/osx-x64/publish
- name: Publish release
uses: marvinpinto/action-automatic-releases@v1.2.1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: latest
prerelease: false
title: Automatic Build
files: |
Barotrauma/bin/ReleaseWindows/netcoreapp3.1/win-x64/publish/barotrauma_lua_windows.zip
Barotrauma/bin/ReleaseLinux/netcoreapp3.1/linux-x64/publish/barotrauma_lua_linux.zip
Barotrauma/bin/ReleaseMac/netcoreapp3.1/osx-x64/publish/barotrauma_lua_mac.zip

50
.github/workflows/run-tests.yml vendored Normal file
View File

@@ -0,0 +1,50 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Run tests
on:
workflow_call:
inputs:
ref:
required: true
type: string
jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v3
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: |
3.1.x
6.0.x
- name: Initialize environment
run: |
mkdir -p ~/".local/share/Daedalic Entertainment GmbH/Barotrauma"
- name: Run tests
continue-on-error: true
run: dotnet test LinuxSolution.sln -clp:"ErrorsOnly;Summary" --logger "trx;LogFileName=$PWD/test-results.trx"
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: test-results
path: test-results.trx
- name: Report test results
uses: dorny/test-reporter@v1
with:
name: Test results
path: test-results.trx
fail-on-error: true
reporter: dotnet-trx