Skip to content

Commit

Permalink
ci: allow forked PRs to build and test with 'safe to test' label
Browse files Browse the repository at this point in the history
  • Loading branch information
jsm174 committed Aug 15, 2022
1 parent 66e48c5 commit 0e55d87
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Build
on: [push, pull_request]
on: push

env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
name: Dispatch
runs-on: ubuntu-latest
needs: [ test ]
if: github.repository == 'freezy/VisualPinball.Engine' && github.ref == 'refs/heads/master' && github.event_name == 'push'
if: github.repository == 'freezy/VisualPinball.Engine' && github.ref == 'refs/heads/master'
steps:
- uses: peter-evans/repository-dispatch@v1
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/license.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: License
on:
workflow_dispatch: {}

jobs:
license:
runs-on: ubuntu-latest
Expand Down
90 changes: 90 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: PR
on:
pull_request_target:
types: [ opened, synchronize, reopened, labeled ]

env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}

defaults:
run:
shell: bash

jobs:
build:
name: Build ${{ matrix.rid }}
runs-on: ${{ matrix.os }}
if: github.event.pull_request.head.repo.full_name == 'freezy/VisualPinball.Engine' || contains(github.event.pull_request.labels.*.name, 'safe to test')
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
rid: win-x64
- os: windows-latest
rid: win-x86
- os: macos-latest
rid: osx
- os: macos-latest
rid: ios-arm64
- os: ubuntu-latest
rid: linux-x64
- os: ubuntu-latest
rid: android-arm64-v8a
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
- name: Build
run: |
cd VisualPinball.Engine.Test
dotnet build VisualPinball.Engine.Test.csproj -c Release -r ${{ matrix.rid }}
- run: |
mkdir tmp
cp -r VisualPinball.Unity/Plugins/${{ matrix.rid }} tmp
- uses: actions/upload-artifact@v3
with:
name: Plugins
path: tmp

test:
name: Unit Test
needs: [ build ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/download-artifact@v3
with:
name: Plugins
path: VisualPinball.Unity/Plugins
- uses: actions/cache@v3
with:
path: VisualPinball.Unity/VisualPinball.Unity.Test/TestProject~/Library
key: Library-Test-Project
restore-keys: |
Library-Test-Project
Library
- uses: game-ci/unity-test-runner@main
id: test
with:
projectPath: VisualPinball.Unity/VisualPinball.Unity.Test/TestProject~
artifactsPath: VisualPinball.Unity/VisualPinball.Unity.Test/TestProject~/artifacts
testMode: all
customParameters: -debugCodeOptimization -enableCodeCoverage -burst-disable-compilation -coverageOptions enableCyclomaticComplexity;assemblyFilters:+VisualPinball.Engine;pathFilters:-**/VisualPinball.Engine/Math/Triangulator/**,-**/VisualPinball.Engine/Math/Mesh/** -coverageResultsPath artifacts
- run: |
curl -s https://codecov.io/bash | bash -s - -f ${{ steps.test.outputs.artifactsPath }}/TestProject~-opencov/EditMode/TestCoverageResults_0000.xml
- uses: MirrorNG/[email protected]
if: always()
with:
path: ${{ steps.test.outputs.artifactsPath }}/*.xml
access-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v3
if: always()
with:
name: Test results
path: ${{ steps.test.outputs.artifactsPath }}

0 comments on commit 0e55d87

Please sign in to comment.