Skip to content

Commit d34e3fb

Browse files
committed
add ok-to-test
1 parent 056fe17 commit d34e3fb

File tree

2 files changed

+70
-2
lines changed

2 files changed

+70
-2
lines changed

.github/workflows/ci.yml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ on:
88
branches: [ main, dev ]
99
pull_request:
1010
branches: [ main, dev ]
11+
repository_dispatch:
12+
types: [ok-to-test-command]
1113

1214
jobs:
13-
test_android_jvm_linux:
15+
test_android_jvm_linux_trusted:
1416
runs-on: ubuntu-latest
1517
environment: testing
1618
env:
@@ -37,4 +39,37 @@ jobs:
3739
with:
3840
name: code-coverage-report
3941
path: build/reports
40-
if: always()
42+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
43+
test_android_jvm_linux_untrusted:
44+
runs-on: ubuntu-latest
45+
environment: testing
46+
env:
47+
SPOTIFY_CLIENT_ID: ${{ secrets.SPOTIFY_CLIENT_ID }}
48+
SPOTIFY_CLIENT_SECRET: ${{ secrets.SPOTIFY_CLIENT_SECRET }}
49+
steps:
50+
- name: Fork based /ok-to-test checkout
51+
uses: actions/checkout@v2
52+
with:
53+
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
54+
- name: Install java 11
55+
uses: actions/setup-java@v2
56+
with:
57+
distribution: 'adopt'
58+
java-version: '11'
59+
- name: Install curl
60+
run: sudo apt-get install -y curl libcurl4-openssl-dev
61+
- name: Test secret
62+
run: echo "client id secret is $SPOTIFY_CLIENT_ID"
63+
- name: Test android
64+
run: ./gradlew testDebugUnitTest
65+
- name: Test jvm
66+
run: ./gradlew jvmTest
67+
- name: Archive test results
68+
uses: actions/upload-artifact@v2
69+
with:
70+
name: code-coverage-report
71+
path: build/reports
72+
if:
73+
github.event_name == 'repository_dispatch' &&
74+
github.event.client_payload.slash_command.sha != '' &&
75+
contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.sha)

.github/workflows/ok-to-test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# If someone with write access comments "/ok-to-test" on a pull request, emit a repository_dispatch event
2+
name: Ok To Test
3+
4+
on:
5+
issue_comment:
6+
types: [created]
7+
8+
jobs:
9+
ok-to-test:
10+
runs-on: ubuntu-latest
11+
environment: testing
12+
# Only run for PRs, not issue comments
13+
if: ${{ github.event.issue.pull_request }}
14+
steps:
15+
- name: Generate token
16+
id: generate_token
17+
uses: tibdex/github-app-token@v1
18+
with:
19+
app_id: ${{ secrets.APP_ID }}
20+
private_key: ${{ secrets.PRIVATE_KEY }}
21+
22+
- name: Slash Command Dispatch
23+
uses: peter-evans/slash-command-dispatch@v1
24+
env:
25+
TOKEN: ${{ steps.generate_token.outputs.token }}
26+
with:
27+
token: ${{ env.TOKEN }} # GitHub App installation access token
28+
# token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} # PAT or OAuth token will also work
29+
reaction-token: ${{ secrets.GITHUB_TOKEN }}
30+
issue-type: pull-request
31+
commands: ok-to-test
32+
named-args: true
33+
permission: write

0 commit comments

Comments
 (0)