Skip to content

Commit f83137d

Browse files
authored
Split Resyntax integration into two workflows (#1257)
See the comment in `resyntax-analyze.yml` for why.
1 parent f534722 commit f83137d

File tree

3 files changed

+83
-41
lines changed

3 files changed

+83
-41
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Resyntax Analysis
2+
3+
# The Resyntax integration is split into two phases: a workflow that analyzes the code and uploads
4+
# the analysis as an artifact, and a workflow that downloads the analysis artifact and creates a
5+
# review of the pull request. This split is for permissions reasons; the analysis workflow checks out
6+
# the pull request branch and compiles it, executing arbitrary code as it does so. For that reason,
7+
# the first workflow has read-only permissions in the github repository. The second workflow only
8+
# downloads the pull request review artifact and submits it, and it executes with read-write permissions
9+
# without executing any code in the repository. This division of responsibilities allows Resyntax to
10+
# safely analyze pull requests from forks. This strategy is outlined in the following article:
11+
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
12+
13+
on:
14+
pull_request:
15+
types:
16+
- opened
17+
- edited
18+
- reopened
19+
- synchronize
20+
- ready_for_review
21+
22+
jobs:
23+
analyze:
24+
runs-on: ubuntu-latest
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
28+
steps:
29+
- uses: actions/[email protected]
30+
# See https://github.com/actions/checkout/issues/118.
31+
with:
32+
fetch-depth: 0
33+
- uses: Bogdanp/[email protected]
34+
with:
35+
version: current
36+
packages: resyntax
37+
local_catalogs: $GITHUB_WORKSPACE
38+
dest: '"${HOME}/racketdist-current-CS"'
39+
sudo: never
40+
- name: Register local packages
41+
run: |
42+
raco pkg install -i --auto --no-setup --skip-installed typed-racket-test
43+
raco pkg update --auto --no-setup source-syntax typed-racket-lib typed-racket-more typed-racket-compatibility typed-racket-doc typed-racket typed-racket-test
44+
- name: Install local packages
45+
- run: raco setup typed typed-racket typed-racket-test typed-scheme
46+
- name: Analyze changed files
47+
- run: xvfb-run racket -l- resyntax/cli analyze --local-git-repository . "origin/${GITHUB_BASE_REF}" --output-as-github-review >> ./resyntax-review.json
48+
- name: Upload analysis artifact
49+
- uses: actions/[email protected]
50+
with:
51+
name: resyntax-review
52+
path: resyntax-review.json
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Resyntax Review Submission
2+
3+
# The Resyntax integration is split into two workflows. See ./resyntax-analyze.yml for details about
4+
# why it works this way.
5+
6+
on:
7+
workflow_run:
8+
workflows: ["Resyntax Analysis"]
9+
types:
10+
- completed
11+
12+
jobs:
13+
review:
14+
runs-on: ubuntu-latest
15+
if: >
16+
${{ github.event.workflow_run.event == 'pull_request' &&
17+
github.event.workflow_run.conclusion == 'success' }}
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
21+
steps:
22+
- uses: actions/[email protected]
23+
- uses: actions/[email protected]
24+
with:
25+
name: resyntax-review
26+
- uses: actions/[email protected]
27+
with:
28+
github-token: ${{ secrets.GITHUB_TOKEN }}
29+
script: |
30+
var create_review_request = require('./resyntax-review.json');
31+
await github.rest.pulls.createReview(create_review_request);

.github/workflows/resyntax.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)