Skip to content

Commit 1437dd5

Browse files
authored
Correct PR workflow to work for PRs from worked repositories (#184)
Resolves #182
1 parent 5af4879 commit 1437dd5

File tree

5 files changed

+95
-69
lines changed

5 files changed

+95
-69
lines changed

.fossa.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
version: 3
2+
project:
3+
locator: custom+46664/github.com/OptimumCode/json-schema-validator
4+
id: https://github.com/OptimumCode/json-schema-validator
25
targets:
36
only:
47
- type: gradle

.github/workflows/code-coverage-upload.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: "Check PR complains with requirements"
2+
3+
on:
4+
pull_request_target:
5+
workflow_run:
6+
workflows: ['Run tests for PR']
7+
types: [completed]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.workflow_run.pull_requests[0].number }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
reviewdog:
15+
if: github.event_name == 'workflow_run'
16+
strategy:
17+
matrix:
18+
include:
19+
- tool: ktlint
20+
- tool: detekt
21+
permissions:
22+
pull-requests: write
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: 'Checkout Repository'
26+
uses: actions/checkout@v4
27+
- name: Download benchmark results
28+
uses: dawidd6/action-download-artifact@v6
29+
with:
30+
name: style-reports
31+
path: reports/
32+
run_id: ${{ github.event.workflow_run.id }}
33+
- name: Setup reviewdog
34+
uses: reviewdog/action-setup@v1
35+
with:
36+
reviewdog_version: latest
37+
- name: Run reviewdog ${{ matrix.tool }}
38+
env:
39+
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
CI_PULL_REQUEST: ${{ github.event.pull_request[0].number }}
41+
CI_REPO_OWNER: ${{ github.repository_owner }}
42+
CI_REPO_NAME: ${{ github.event.repository.name }}
43+
CI_COMMIT: ${{ github.event.workflow_run.pull_requests[0].head.repo }}
44+
run: echo reports/${{ matrix.tool }}-reviewdog.out | reviewdog -tee -reporter=github-pr-review
45+
danger-check:
46+
if: github.event_name == 'pull_request_target'
47+
runs-on: ubuntu-latest
48+
permissions:
49+
pull-requests: write
50+
statuses: write
51+
steps:
52+
- name: 'Checkout Repository'
53+
uses: actions/checkout@v4
54+
- name: Danger
55+
uses: danger/[email protected]
56+
with:
57+
run-mode: ci
58+
dangerfile: Dangerfile.df.kts
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
upload-coverage:
62+
runs-on: ubuntu-latest
63+
if: github.event.workflow_run.actor.name != 'dependabot[bot]' && github.repository == 'OptimumCode/json-schema-validator' && github.event.workflow_run.conclusion == 'success'
64+
steps:
65+
- name: 'Checkout Repository'
66+
uses: actions/checkout@v4
67+
with:
68+
repository: ${{ github.event.workflow_run.head_repository.full_name }}
69+
ref: ${{ github.event.workflow_run.head_sha }}
70+
- name: Download benchmark results
71+
uses: dawidd6/action-download-artifact@v6
72+
with:
73+
name: coverage-reports
74+
path: reports/
75+
run_id: ${{ github.event.workflow_run.id }}
76+
- name: Upload coverage reports to Codecov
77+
uses: codecov/codecov-action@v4
78+
with:
79+
override_branch: ${{ github.event.workflow_run.pull_requests[0].head.ref }}
80+
override_commit: ${{ github.event.workflow_run.pull_requests[0].head.sha }}
81+
override_pr: ${{ github.event.workflow_run.pull_requests[0].number }}
82+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/pull_request.yml

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Check the PR"
1+
name: "Run tests for PR"
22

33
on:
44
pull_request:
@@ -13,11 +13,9 @@ concurrency:
1313
jobs:
1414
dump-unicode-data:
1515
uses: ./.github/workflows/unicode-dump.yml
16-
reviewdog:
16+
collect-output-reviewdog:
1717
needs:
1818
- dump-unicode-data
19-
permissions:
20-
pull-requests: write
2119
runs-on: ubuntu-latest
2220
steps:
2321
- name: 'Checkout Repository'
@@ -48,32 +46,18 @@ jobs:
4846
uses: gradle/actions/setup-gradle@v4
4947
with:
5048
gradle-version: wrapper
51-
- name: Setup reviewdog
52-
uses: reviewdog/action-setup@v1
49+
- name: Run ktlint
50+
run: ./gradlew ktlintCheck --console plain > ktlint-reviewdog.out 2>&1 || true
51+
- name: Run detekt
52+
run: ./gradlew -q detekt detektAll --console plain > detekt-reviewdog.out 2>&1 || true
53+
- name: Collect output for reviewdog
54+
uses: actions/upload-artifact@v4
5355
with:
54-
reviewdog_version: latest
55-
- name: Run reviewdog
56-
env:
57-
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58-
run: reviewdog -tee -reporter=github-pr-review
56+
name: style-reports
57+
path: '*-reviewdog.out'
5958
check-pr:
6059
needs:
6160
- dump-unicode-data
6261
uses: ./.github/workflows/build-and-test.yml
6362
with:
6463
collect-code-coverage: true
65-
danger-check:
66-
runs-on: ubuntu-latest
67-
permissions:
68-
pull-requests: write
69-
statuses: write
70-
steps:
71-
- name: 'Checkout Repository'
72-
uses: actions/checkout@v4
73-
- name: Danger
74-
uses: danger/[email protected]
75-
with:
76-
run-mode: ci
77-
dangerfile: Dangerfile.df.kts
78-
env:
79-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.reviewdog.yml

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

0 commit comments

Comments
 (0)