Skip to content

Commit

Permalink
Do not duplicate linting work
Browse files Browse the repository at this point in the history
  • Loading branch information
galargh committed May 31, 2024
1 parent c56528a commit ac06514
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 39 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/check-docs-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ concurrency:
cancel-in-progress: true

jobs:
lint:
name: Lint
build:
name: Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: docs
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
Expand All @@ -23,11 +26,9 @@ jobs:
with:
node-version: 18
cache: "pnpm"
- name: Install
run: pnpm install --frozen-lockfile --prefer-offline
cache-dependency-path: |
docs/pnpm-lock.yaml
- name: Install Docs
run: cd docs && pnpm install --frozen-lockfile --prefer-offline
- name: lint
run: cd docs && pnpm lint
run: pnpm install --frozen-lockfile --prefer-offline
- name: Build
run: cd docs && pnpm build
run: pnpm build
47 changes: 16 additions & 31 deletions .github/workflows/comment-on-linter-error.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,38 @@
name: Comment on lint failure

on:
pull_request_target:
workflow_run:
workflows:
- Lint
types:
- opened
branches:
- main
- completed

concurrency:
group: ${{github.workflow}}-${{github.ref}}
group: "${{github.workflow}}-${{github.event.workflow_run.event}}-${{github.event.workflow_run.head_repository.full_name}}:${{github.event.workflow_run.head_branch}}"
cancel-in-progress: true

jobs:
comment_on_lint_failure:
name: Comment on lint failure
runs-on: ubuntu-latest
if: |
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'failure'
steps:
- name: Checkout repo
uses: actions/checkout@v4
- uses: ipdxco/workflow-run-context@492ea3967eb2ca7ed76b7888b42fa7649addd975 # v1.1.1
name: Get workflow run context
id: context
with:
ref: "refs/pull/${{ github.event.number }}/merge"
- uses: pnpm/action-setup@v2
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"
- name: Install
run: pnpm install --frozen-lockfile --prefer-offline
- name: Build
run: pnpm build
- name: lint
run: pnpm lint
- name: Check dependency versions
run: node scripts/check-dependencies.js
- name: Install website
working-directory: docs/
run: pnpm install --frozen-lockfile --prefer-offline
- name: Lint website
working-directory: docs/
run: pnpm lint
artifacts-url: ${{ github.event.workflow_run.artifacts_url }}
artifact-names: event
- uses: actions/github-script@v6
name: Comment on failure
if: ${{ failure() }}
env:
NUMBER: ${{ fromJSON(steps.context.outputs.artifacts)['event'].files['event.json'].number }}
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
issue_number: process.env.NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Thanks for submitting this PR!\n\nUnfortunately, it has some linter errors, so we can't merge it yet. Can you please fix them?\n\nRunning pnpm lint:fix in the root of the repository may fix them automatically."
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,11 @@ jobs:
- name: Check dependency versions
if: matrix.working-directory == ''
run: node scripts/check-dependencies.js
save_event:
name: Save event
runs-on: ubuntu-latest
steps:
- uses: actions/upload-artifact@v4
with:
name: event
path: ${{ github.event_path }}

0 comments on commit ac06514

Please sign in to comment.