From 38bb49e0e470423f2d2777e932875e4fc1937fd3 Mon Sep 17 00:00:00 2001 From: galargh Date: Wed, 31 Jul 2024 22:51:20 +0100 Subject: [PATCH] ci: remove duplicated lint jobs/steps --- .github/workflows/check-docs-site.yml | 14 ++--- .github/workflows/comment-on-linter-error.yml | 54 ------------------- .github/workflows/lint.yml | 28 ++++++++++ 3 files changed, 35 insertions(+), 61 deletions(-) delete mode 100644 .github/workflows/comment-on-linter-error.yml diff --git a/.github/workflows/check-docs-site.yml b/.github/workflows/check-docs-site.yml index 3f4af679cb..cefb0d5fd7 100644 --- a/.github/workflows/check-docs-site.yml +++ b/.github/workflows/check-docs-site.yml @@ -11,8 +11,8 @@ concurrency: cancel-in-progress: true jobs: - lint: - name: Lint + build: + name: Build Docs runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -26,8 +26,8 @@ jobs: - 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 diff --git a/.github/workflows/comment-on-linter-error.yml b/.github/workflows/comment-on-linter-error.yml deleted file mode 100644 index 79a8036e0d..0000000000 --- a/.github/workflows/comment-on-linter-error.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Comment on lint failure - -on: - pull_request_target: - types: - - opened - branches: - - $default-branch - -concurrency: - group: ${{github.workflow}}-${{github.ref}} - cancel-in-progress: true - -jobs: - comment_on_lint_failure: - name: Comment on lint failure - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - ref: "refs/pull/${{ github.event.number }}/merge" - - uses: pnpm/action-setup@v4 - 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 - - uses: actions/github-script@v6 - name: Comment on failure - if: ${{ 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." - }) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 760e0495f0..66f30238ae 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,8 +16,18 @@ jobs: lint: name: Lint runs-on: ubuntu-latest + permissions: + contents: read steps: - uses: actions/checkout@v4 + if: github.event_name != 'pull_request_target' + with: + 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 - uses: pnpm/action-setup@v4 with: version: 9 @@ -42,3 +52,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." + })