Skip to content

Commit 0e55d87

Browse files
committed
ci: allow forked PRs to build and test with 'safe to test' label
1 parent 66e48c5 commit 0e55d87

File tree

3 files changed

+93
-2
lines changed

3 files changed

+93
-2
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Build
2-
on: [push, pull_request]
2+
on: push
33

44
env:
55
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
@@ -86,7 +86,7 @@ jobs:
8686
name: Dispatch
8787
runs-on: ubuntu-latest
8888
needs: [ test ]
89-
if: github.repository == 'freezy/VisualPinball.Engine' && github.ref == 'refs/heads/master' && github.event_name == 'push'
89+
if: github.repository == 'freezy/VisualPinball.Engine' && github.ref == 'refs/heads/master'
9090
steps:
9191
- uses: peter-evans/repository-dispatch@v1
9292
with:

.github/workflows/license.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: License
22
on:
33
workflow_dispatch: {}
4+
45
jobs:
56
license:
67
runs-on: ubuntu-latest

.github/workflows/pr.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: PR
2+
on:
3+
pull_request_target:
4+
types: [ opened, synchronize, reopened, labeled ]
5+
6+
env:
7+
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
8+
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
jobs:
14+
build:
15+
name: Build ${{ matrix.rid }}
16+
runs-on: ${{ matrix.os }}
17+
if: github.event.pull_request.head.repo.full_name == 'freezy/VisualPinball.Engine' || contains(github.event.pull_request.labels.*.name, 'safe to test')
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- os: windows-latest
23+
rid: win-x64
24+
- os: windows-latest
25+
rid: win-x86
26+
- os: macos-latest
27+
rid: osx
28+
- os: macos-latest
29+
rid: ios-arm64
30+
- os: ubuntu-latest
31+
rid: linux-x64
32+
- os: ubuntu-latest
33+
rid: android-arm64-v8a
34+
steps:
35+
- uses: actions/checkout@v3
36+
with:
37+
ref: ${{ github.event.pull_request.head.sha }}
38+
- uses: actions/setup-dotnet@v1
39+
with:
40+
dotnet-version: '3.1.x'
41+
- name: Build
42+
run: |
43+
cd VisualPinball.Engine.Test
44+
dotnet build VisualPinball.Engine.Test.csproj -c Release -r ${{ matrix.rid }}
45+
- run: |
46+
mkdir tmp
47+
cp -r VisualPinball.Unity/Plugins/${{ matrix.rid }} tmp
48+
- uses: actions/upload-artifact@v3
49+
with:
50+
name: Plugins
51+
path: tmp
52+
53+
test:
54+
name: Unit Test
55+
needs: [ build ]
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v3
59+
with:
60+
ref: ${{ github.event.pull_request.head.sha }}
61+
- uses: actions/download-artifact@v3
62+
with:
63+
name: Plugins
64+
path: VisualPinball.Unity/Plugins
65+
- uses: actions/cache@v3
66+
with:
67+
path: VisualPinball.Unity/VisualPinball.Unity.Test/TestProject~/Library
68+
key: Library-Test-Project
69+
restore-keys: |
70+
Library-Test-Project
71+
Library
72+
- uses: game-ci/unity-test-runner@main
73+
id: test
74+
with:
75+
projectPath: VisualPinball.Unity/VisualPinball.Unity.Test/TestProject~
76+
artifactsPath: VisualPinball.Unity/VisualPinball.Unity.Test/TestProject~/artifacts
77+
testMode: all
78+
customParameters: -debugCodeOptimization -enableCodeCoverage -burst-disable-compilation -coverageOptions enableCyclomaticComplexity;assemblyFilters:+VisualPinball.Engine;pathFilters:-**/VisualPinball.Engine/Math/Triangulator/**,-**/VisualPinball.Engine/Math/Mesh/** -coverageResultsPath artifacts
79+
- run: |
80+
curl -s https://codecov.io/bash | bash -s - -f ${{ steps.test.outputs.artifactsPath }}/TestProject~-opencov/EditMode/TestCoverageResults_0000.xml
81+
- uses: MirrorNG/[email protected]
82+
if: always()
83+
with:
84+
path: ${{ steps.test.outputs.artifactsPath }}/*.xml
85+
access-token: ${{ secrets.GITHUB_TOKEN }}
86+
- uses: actions/upload-artifact@v3
87+
if: always()
88+
with:
89+
name: Test results
90+
path: ${{ steps.test.outputs.artifactsPath }}

0 commit comments

Comments
 (0)