Skip to content

Commit 58d2f92

Browse files
committed
Try out ok-to-test
1 parent e181f9e commit 58d2f92

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
permissions:
12+
pull-requests: write
13+
# Only run for PRs, not issue comments
14+
if: ${{ github.event.issue.pull_request }}
15+
steps:
16+
- name: Slash Command Dispatch
17+
uses: peter-evans/slash-command-dispatch@v3
18+
with:
19+
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
20+
reaction-token: ${{ secrets.GITHUB_TOKEN }}
21+
issue-type: pull-request
22+
commands: ok-to-test
23+
permission: write

.github/workflows/validate.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,63 @@ jobs:
4646
pip install ruff
4747
ruff --output-format=github --exclude=src/onepassword/lib/ .
4848
continue-on-error: true
49+
50+
# Repo owner has commented /ok-to-test on a (fork-based) pull request
51+
integration-fork:
52+
runs-on: ubuntu-latest
53+
permissions:
54+
pull-requests: write
55+
checks: write
56+
if: |
57+
github.event_name == 'repository_dispatch' &&
58+
github.event.client_payload.slash_command.args.named.sha != '' &&
59+
contains(
60+
github.event.client_payload.pull_request.head.sha,
61+
github.event.client_payload.slash_command.args.named.sha
62+
)
63+
steps:
64+
65+
# Check out merge commit
66+
- name: Fork based /ok-to-test checkout
67+
uses: actions/checkout@v3
68+
with:
69+
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
70+
71+
# <insert integration tests needing secrets>
72+
73+
- run: |
74+
echo "Integration tests... success! ;-)"
75+
76+
# Update check run called "integration-fork"
77+
- uses: actions/github-script@v6
78+
id: update-check-run
79+
if: ${{ always() }}
80+
env:
81+
number: ${{ github.event.client_payload.pull_request.number }}
82+
job: ${{ github.job }}
83+
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
84+
conclusion: ${{ job.status }}
85+
with:
86+
github-token: ${{ secrets.GITHUB_TOKEN }}
87+
script: |
88+
const { data: pull } = await github.rest.pulls.get({
89+
...context.repo,
90+
pull_number: process.env.number
91+
});
92+
const ref = pull.head.sha;
93+
94+
const { data: checks } = await github.rest.checks.listForRef({
95+
...context.repo,
96+
ref
97+
});
98+
99+
const check = checks.check_runs.filter(c => c.name === process.env.job);
100+
101+
const { data: result } = await github.rest.checks.update({
102+
...context.repo,
103+
check_run_id: check[0].id,
104+
status: 'completed',
105+
conclusion: process.env.conclusion
106+
});
107+
108+
return result;

0 commit comments

Comments
 (0)