Skip to content

Commit f2ee219

Browse files
authored
chore(ci): use step conditions to skip tests for doc changes (#11700)
1 parent dc05e97 commit f2ee219

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

.github/workflows/ci.yml

+25-28
Original file line numberDiff line numberDiff line change
@@ -33,33 +33,7 @@ concurrency:
3333
cancel-in-progress: true
3434

3535
jobs:
36-
diff:
37-
timeout-minutes: 2
38-
runs-on: ubuntu-latest
39-
name: "Diff files"
40-
outputs:
41-
runTest: ${{ steps.skip-tests-files.outputs.only_changed != 'true' }}
42-
steps:
43-
- name: Checkout
44-
uses: actions/checkout@v3
45-
with:
46-
# Assume PRs are less than 50 commits
47-
fetch-depth: 50
48-
49-
- name: Get changed files
50-
id: skip-tests-files
51-
uses: tj-actions/changed-files@ea251d4d2f03a9c18841ae1b752f58b82dfb4d5e # v35.3.0
52-
with:
53-
files: |
54-
docs/**
55-
.github/**
56-
!.github/workflows/ci.yml
57-
packages/create-vite/template**
58-
**.md
59-
6036
test:
61-
needs: diff
62-
if: ${{ needs.diff.outputs.runTest }}
6337
timeout-minutes: 20
6438
runs-on: ${{ matrix.os }}
6539
strategy:
@@ -78,34 +52,52 @@ jobs:
7852
steps:
7953
- name: Checkout
8054
uses: actions/checkout@v3
55+
with:
56+
# Assume PRs are less than 50 commits
57+
fetch-depth: 50
58+
59+
- name: Get changed files
60+
id: changed-files
61+
uses: tj-actions/changed-files@ea251d4d2f03a9c18841ae1b752f58b82dfb4d5e # v35.3.0
62+
with:
63+
files: |
64+
docs/**
65+
.github/**
66+
!.github/workflows/ci.yml
67+
packages/create-vite/template**
68+
**.md
8169
8270
- name: Install pnpm
71+
if: steps.changed-files.outputs.only_changed != 'true'
8372
uses: pnpm/[email protected]
8473

8574
- name: Set node version to ${{ matrix.node_version }}
75+
if: steps.changed-files.outputs.only_changed != 'true'
8676
uses: actions/setup-node@v3
8777
with:
8878
node-version: ${{ matrix.node_version }}
8979
cache: "pnpm"
9080

9181
- name: Install deps
82+
if: steps.changed-files.outputs.only_changed != 'true'
9283
run: pnpm install
9384

9485
# Install playwright's binary under custom directory to cache
9586
- name: (non-windows) Set Playwright path and Get playwright version
96-
if: runner.os != 'Windows'
87+
if: runner.os != 'Windows' && steps.changed-files.outputs.only_changed != 'true'
9788
run: |
9889
echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV
9990
PLAYWRIGHT_VERSION="$(pnpm ls --depth 0 --json -w playwright-chromium | jq --raw-output '.[0].devDependencies["playwright-chromium"].version')"
10091
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
10192
- name: (windows) Set Playwright path and Get playwright version
102-
if: runner.os == 'Windows'
93+
if: runner.os == 'Windows' && steps.changed-files.outputs.only_changed != 'true'
10394
run: |
10495
echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV
10596
$env:PLAYWRIGHT_VERSION="$(pnpm ls --depth 0 --json -w playwright-chromium | jq --raw-output '.[0].devDependencies[\"playwright-chromium\"].version')"
10697
echo "PLAYWRIGHT_VERSION=$env:PLAYWRIGHT_VERSION" >> $env:GITHUB_ENV
10798
10899
- name: Cache Playwright's binary
100+
if: steps.changed-files.outputs.only_changed != 'true'
109101
uses: actions/cache@v3
110102
with:
111103
key: ${{ runner.os }}-playwright-bin-v1-${{ env.PLAYWRIGHT_VERSION }}
@@ -114,19 +106,24 @@ jobs:
114106
${{ runner.os }}-playwright-bin-v1-
115107
116108
- name: Install Playwright
109+
if: steps.changed-files.outputs.only_changed != 'true'
117110
# does not need to explicitly set chromium after https://github.com/microsoft/playwright/issues/14862 is solved
118111
run: pnpm playwright install chromium
119112

120113
- name: Build
114+
if: steps.changed-files.outputs.only_changed != 'true'
121115
run: pnpm run build
122116

123117
- name: Test unit
118+
if: steps.changed-files.outputs.only_changed != 'true'
124119
run: pnpm run test-unit
125120

126121
- name: Test serve
122+
if: steps.changed-files.outputs.only_changed != 'true'
127123
run: pnpm run test-serve
128124

129125
- name: Test build
126+
if: steps.changed-files.outputs.only_changed != 'true'
130127
run: pnpm run test-build
131128

132129
lint:

0 commit comments

Comments
 (0)