Skip to content

Commit 235e18c

Browse files
committed
Decompose the pr testing workflow
1 parent 20cdcfb commit 235e18c

File tree

4 files changed

+81
-75
lines changed

4 files changed

+81
-75
lines changed

.github/workflows/lint-pr_job.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Reusable workflow to lint a pull request
2+
3+
on: workflow_call
4+
5+
jobs:
6+
lint-test:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout Code
11+
uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 0
14+
15+
- name: Setup reviewdog
16+
uses: reviewdog/action-setup@v1.3.0
17+
with:
18+
reviewdog_version: v0.20.3
19+
20+
- name: Load super-linter configuration
21+
shell: bash
22+
run: cat .github/super-linter.env >> "$GITHUB_ENV"
23+
24+
- name: Lint Code Base with super-linter and reviewdog
25+
uses: super-linter/super-linter/slim@v7.3.0
26+
env:
27+
GITHUB_TOKEN: ${{ github.token }}
28+
29+
- name: Report linting results with reviewdog
30+
shell: bash
31+
run: |
32+
TMPFILE=$(mktemp)
33+
git diff > "${TMPFILE}"
34+
if [ ! -s "${TMPFILE}" ]; then
35+
echo "No changes detected, skipping reviewdog."
36+
exit 0
37+
fi
38+
git stash --include-untracked
39+
reviewdog \
40+
-f=diff \
41+
-f.diff.strip=1 \
42+
-name="markdownlint-fix" \
43+
-reporter="github-pr-review" \
44+
-filter-mode="diff_context" \
45+
-fail-level=error < "${TMPFILE}"
46+
git stash drop || true
47+
env:
48+
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
name: Lint pull request
3+
4+
on: pull_request_target
5+
6+
jobs:
7+
linting:
8+
name: Check code with linters
9+
uses: ./.github/workflows/lint-pr_job.yml

.github/workflows/test-pull-request.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Validate pull request
22

3-
on: pull_request_target
3+
on: pull_request
4+
45
permissions:
56
contents: read
67
statuses: write

.github/workflows/validate-pr_job.yml

Lines changed: 22 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,31 @@
1-
---
21
name: Reusable workflow to validate a pull request
32

43
on: workflow_call
54

65
jobs:
7-
lint-test:
6+
remark-test:
87
runs-on: ubuntu-latest
9-
108
steps:
11-
- name: Checkout Code
12-
uses: actions/checkout@v4
13-
with:
14-
fetch-depth: 0
15-
16-
- name: Setup reviewdog
17-
uses: reviewdog/action-setup@v1.3.0
18-
with:
19-
reviewdog_version: v0.20.3
20-
21-
- name: Load super-linter configuration
22-
shell: bash
23-
run: cat .github/super-linter.env >> "$GITHUB_ENV"
24-
25-
- name: Lint Code Base with super-linter and reviewdog
26-
uses: super-linter/super-linter/slim@v7.3.0
27-
env:
28-
GITHUB_TOKEN: ${{ github.token }}
29-
30-
- name: Report linting results with reviewdog
31-
shell: bash
32-
run: |
33-
TMPFILE=$(mktemp)
34-
git diff > "${TMPFILE}"
35-
if [ ! -s "${TMPFILE}" ]; then
36-
echo "No changes detected, skipping reviewdog."
37-
exit 0
38-
fi
39-
git stash --include-untracked
40-
reviewdog \
41-
-f=diff \
42-
-f.diff.strip=1 \
43-
-name="markdownlint-fix" \
44-
-reporter="github-pr-review" \
45-
-filter-mode="diff_context" \
46-
-fail-level=error < "${TMPFILE}"
47-
git stash drop || true
48-
env:
49-
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
9+
- uses: actions/checkout@v4
10+
- name: Use Setup Node and Install Dependencies Action
11+
uses: commerce-docs/devsite-install-action@main
12+
with:
13+
node-version-file: '.nvmrc'
14+
cache-dependency-path: 'yarn.lock'
5015

51-
# remark-test:
52-
# permissions:
53-
# contents: read
54-
# statuses: write
55-
# runs-on: ubuntu-latest
56-
# needs: lint-test
57-
# steps:
58-
# - uses: actions/checkout@v4
59-
# - name: Use Setup Node and Install Dependencies Action
60-
# uses: commerce-docs/devsite-install-action@main
61-
# with:
62-
# node-version-file: '.nvmrc'
63-
# cache-dependency-path: 'yarn.lock'
16+
- name: Check links
17+
run: yarn test
6418

65-
# - name: Check links
66-
# run: yarn test
67-
68-
# build-test:
69-
# permissions:
70-
# contents: read
71-
# statuses: write
72-
# runs-on: ubuntu-latest
73-
# needs: remark-test
74-
# steps:
75-
# - uses: actions/checkout@v4
76-
# - name: Use Setup Node and Install Dependencies Action
77-
# uses: commerce-docs/devsite-install-action@main
78-
# with:
79-
# node-version-file: '.nvmrc'
80-
# cache-dependency-path: 'yarn.lock'
81-
82-
# - name: Build site
83-
# run: yarn build
19+
build-test:
20+
runs-on: ubuntu-latest
21+
needs: remark-test
22+
steps:
23+
- uses: actions/checkout@v4
24+
- name: Use Setup Node and Install Dependencies Action
25+
uses: commerce-docs/devsite-install-action@main
26+
with:
27+
node-version-file: '.nvmrc'
28+
cache-dependency-path: 'yarn.lock'
29+
30+
- name: Build site
31+
run: yarn build

0 commit comments

Comments
 (0)