Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(v2): remove duplicated lint jobs/steps #5562

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/check-docs-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ concurrency:
cancel-in-progress: true

jobs:
lint:
name: Lint
build:
name: Build Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-env
- name: Install
run: pnpm install --frozen-lockfile --prefer-offline
- name: Install Docs
run: cd docs && pnpm install --frozen-lockfile --prefer-offline
- name: lint
run: cd docs && pnpm lint
- name: Build
run: cd docs && pnpm build
working-directory: docs/
run: pnpm install --frozen-lockfile --prefer-offline
- name: Build Docs
working-directory: docs/
run: pnpm build
48 changes: 0 additions & 48 deletions .github/workflows/comment-on-linter-error.yml

This file was deleted.

34 changes: 34 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,24 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
# NOTE: When running on a pull_request_target, we're checking out the repo
# twice. The first checkout is for the base branch of the PR. The second,
# for the merge commit. We do this to be able to use the `setup-env`
# action that's on the base branch.
- uses: actions/checkout@v4
with:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity: what's the deal behind this double checkout?

Is the first one for pushes to main and the other one checking out the merge commit of a pr?

Maybe leaving a comment would be good for future readers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed an if here. The first checkout should only be executed if we're not running in the pull request context. Thanks for catching this 🙇

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, after resolving the conflicts I had to restore 2 checkouts when we're running on pull_request_target. This is so that we can run lint on the code from the pull request but get the code of the setup-env action from the base branch.

I added the following comment above the first checkout so that this bit of context is not lost:

      # NOTE: When running on a pull_request_target, we're checking out the repo
      # twice. The first checkout is for the base branch of the PR. The second,
      # for the merge commit. We do this to be able to use the `setup-env`
      # action that's on the base branch.

persist-credentials: false
- uses: actions/checkout@v4
if: github.event_name == 'pull_request_target'
with:
ref: "refs/pull/${{ github.event.number }}/merge"
persist-credentials: false
- if: github.event_name == 'pull_request_target'
name: Check out setup-env action from the base branch
run: git checkout --no-overlay $GITHUB_SHA -- .github/actions/setup-env
- uses: ./.github/actions/setup-env
- name: Install
run: pnpm install --frozen-lockfile --prefer-offline
Expand All @@ -40,3 +56,21 @@ jobs:
- name: Lint website
working-directory: docs/
run: pnpm lint
comment:
needs: [lint]
if: failure() && github.event_name == 'pull_request_target' && needs.lint.result == 'failure'
name: Comment
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/github-script@v7
name: Comment on failure
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.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."
})
Loading