From d93519332047f3fe9f1cc5964e9f55cccf48b4c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20Barr=C3=A9?= Date: Sun, 1 Jan 2023 13:08:43 +0100 Subject: [PATCH 1/8] chore: merge back CI jobs using tj-actions/changed-files --- .github/workflows/ci-lint.yml | 70 ----------------------------------- .github/workflows/ci.yml | 57 ++++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 74 deletions(-) delete mode 100644 .github/workflows/ci-lint.yml diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml deleted file mode 100644 index 94bd70c65948aa..00000000000000 --- a/.github/workflows/ci-lint.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: CI Lint - -env: - # 7 GiB by default on GitHub, setting to 6 GiB - # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources - NODE_OPTIONS: --max-old-space-size=6144 - -on: - push: - branches: - - main - - release/* - - feat/* - - fix/* - - perf/* - - v1 - - v2 - - v2.* - - v3.* - pull_request: - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.number || github.sha }} - cancel-in-progress: true - -jobs: - lint: - timeout-minutes: 10 - runs-on: ubuntu-latest - name: "Lint, Format, Typecheck, Docs" - steps: - - uses: actions/checkout@v3 - - - name: Install pnpm - uses: pnpm/action-setup@v2.2.4 - - - name: Set node version to 18 - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: "pnpm" - - - name: Install deps - run: pnpm install - - - name: Build - run: pnpm run build - - - name: Lint - run: pnpm run lint - - - name: Check formatting - run: pnpm prettier --check . - - - name: Typecheck - run: pnpm run typecheck - - # Run unit test for create-vite only PRs - - name: Test unit - run: pnpm run test-unit - - - name: Test docs - run: pnpm run test-docs - - # From https://github.com/rhysd/actionlint/blob/main/docs/usage.md#use-actionlint-on-github-actions - - name: Check workflow files - run: | - bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) - ./actionlint -color -shellcheck="" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7dcefa03463b04..76d154d7c2a07e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,10 +21,6 @@ on: - v2 - v2.* - v3.* - pull_request: - paths-ignore: - - "docs/**" - - "packages/create-vite/**" workflow_dispatch: concurrency: @@ -51,6 +47,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 50 + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v35 + with: + files: | + docs/** + packages/create-vite/** - name: Install pnpm uses: pnpm/action-setup@v2.2.4 @@ -91,13 +97,56 @@ jobs: run: pnpm playwright install chromium - name: Build + if: steps.changed-files.outputs.only_changed != 'true' run: pnpm run build - name: Test unit run: pnpm run test-unit - name: Test serve + if: steps.changed-files.outputs.only_changed != 'true' run: pnpm run test-serve - name: Test build + if: steps.changed-files.outputs.only_changed != 'true' run: pnpm run test-build + + lint: + timeout-minutes: 10 + runs-on: ubuntu-latest + name: "Lint: node-18, ubuntu-latest" + steps: + - uses: actions/checkout@v3 + + - name: Install pnpm + uses: pnpm/action-setup@v2.2.4 + + - name: Set node version to 18 + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: "pnpm" + + - name: Install deps + run: pnpm install + + - name: Build + run: pnpm run build + + - name: Lint + run: pnpm run lint + + - name: Check formatting + run: pnpm prettier --check . + + - name: Typecheck + run: pnpm run typecheck + + - name: Test docs + run: pnpm run test-docs + + # From https://github.com/rhysd/actionlint/blob/main/docs/usage.md#use-actionlint-on-github-actions + - name: Check workflow files + run: | + bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) + ./actionlint -color -shellcheck="" From b01e135605a70c85d39638b85dc772adcf9c4148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20Barr=C3=A9?= Date: Sun, 1 Jan 2023 13:17:51 +0100 Subject: [PATCH 2/8] oups --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 76d154d7c2a07e..919e4305544366 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,7 @@ on: - v2 - v2.* - v3.* + pull_request: workflow_dispatch: concurrency: From 57adfc2521924f2b0a6fb89b1bc9b20b53ecf646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20Barr=C3=A9?= Date: Sun, 1 Jan 2023 15:30:02 +0100 Subject: [PATCH 3/8] Use diff job --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 919e4305544366..d397920e0ba0b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,34 @@ concurrency: cancel-in-progress: true jobs: - build: + diff: + timeout-minutes: 2 + runs-on: ubuntu-latest + name: "Diff files" + outputs: + runTest: ${{ steps.skip-tests-files.outputs.only_changed != 'true' }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + # Assume PRs are less than 50 commits + fetch-depth: 50 + + - name: Get changed files + id: skip-tests-files + uses: tj-actions/changed-files@v35 + with: + files: | + docs/** + .github/** + !.github/workflows/ci.yml + packages/create-vite/** + !packages/create-vite/__tests__/** + **/*.md + + test: + needs: diff + if: ${{ needs.diff.outputs.runTest }} timeout-minutes: 20 runs-on: ${{ matrix.os }} strategy: @@ -98,18 +125,15 @@ jobs: run: pnpm playwright install chromium - name: Build - if: steps.changed-files.outputs.only_changed != 'true' run: pnpm run build - name: Test unit run: pnpm run test-unit - name: Test serve - if: steps.changed-files.outputs.only_changed != 'true' run: pnpm run test-serve - name: Test build - if: steps.changed-files.outputs.only_changed != 'true' run: pnpm run test-build lint: From 8f2f869b9ddddf8f671147f85044063f477df96d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20Barr=C3=A9?= Date: Sun, 1 Jan 2023 15:31:54 +0100 Subject: [PATCH 4/8] Useless fetch-depth --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d397920e0ba0b0..5666e5a4e2cd02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,8 +75,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - with: - fetch-depth: 50 - name: Get changed files id: changed-files From adb70cee711a0edd98223a9cbd388428795a2001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20Barr=C3=A9?= Date: Sun, 1 Jan 2023 17:16:46 +0100 Subject: [PATCH 5/8] cleanup --- .github/workflows/ci.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5666e5a4e2cd02..1c474cc7ff9699 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,14 +76,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v35 - with: - files: | - docs/** - packages/create-vite/** - - name: Install pnpm uses: pnpm/action-setup@v2.2.4 From a57df6e10bd6accf3d9a92b57570788743514874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20Barr=C3=A9?= Date: Mon, 2 Jan 2023 14:07:28 +0100 Subject: [PATCH 6/8] Use commit hash --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c474cc7ff9699..73e0bca2f97034 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: - name: Get changed files id: skip-tests-files - uses: tj-actions/changed-files@v35 + uses: tj-actions/changed-files@1d1287f9fafd92be283f99b781fb5f00f00dd471 # v35.2.1 with: files: | docs/** From 0590c8eec94f541ff46e0a3b0428fbaab60f26ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20Barr=C3=A9?= Date: Mon, 2 Jan 2023 18:37:37 +0100 Subject: [PATCH 7/8] Remove all permissions --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 73e0bca2f97034..9e124cbd6cf3d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,10 @@ env: # Vitest auto retry on flaky segfault VITEST_SEGFAULT_RETRY: 3 +# Remove default permissions of GITHUB_TOKEN for security +# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs +permissions: {} + on: push: branches: From 7e35e9a78bd14099fa09e018cd381fd8207c814d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20Barr=C3=A9?= Date: Tue, 3 Jan 2023 16:33:44 +0100 Subject: [PATCH 8/8] Fix globs --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e124cbd6cf3d4..e09e4732874df9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,9 +54,8 @@ jobs: docs/** .github/** !.github/workflows/ci.yml - packages/create-vite/** - !packages/create-vite/__tests__/** - **/*.md + packages/create-vite/template** + **.md test: needs: diff