Skip to content

Commit db7dcec

Browse files
Reusable Workflow
1 parent 0fb085d commit db7dcec

2 files changed

Lines changed: 43 additions & 23 deletions

File tree

.github/workflows/ci.yml

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,9 @@ jobs:
3838
matrix:
3939
node-version: [22.x]
4040
steps:
41-
# Common setup steps
42-
- &setup-steps
43-
- uses: actions/checkout@v4
44-
- name: Use Node.js ${{ matrix.node-version }}
45-
uses: actsetup-node@v4
46-
with:
47-
node-version: ${{ matrix.node-version }}
48-
- name: Cache npm
49-
uses: actions/cache@v4
50-
with:
51-
path: ~/.npm
52-
key: ${{ runner.os }}-node-${{ matrix.node-version }}-npm-${{ hashFiles('react/package-lock.json') }}
53-
restore-keys: |
54-
${{ runner.os }}-node-${{ matrix.node-version }}-npm-
55-
- name: Install dependencies
56-
run: npm install
57-
working-directory: react
58-
- *setup-steps
41+
- uses: ./.github/workflows/common-setup.yml
42+
with:
43+
node-version: ${{ matrix.node-version }}
5944
- name: Build
6045
run: npm run build
6146
working-directory: react
@@ -73,7 +58,9 @@ jobs:
7358
matrix:
7459
node-version: [22.x]
7560
steps:
76-
- *setup-steps
61+
- uses: ./.github/workflows/common-setup.yml
62+
with:
63+
node-version: ${{ matrix.node-version }}
7764
- name: Audit
7865
run: npm run audit
7966
working-directory: react
@@ -89,7 +76,9 @@ jobs:
8976
matrix:
9077
node-version: [22.x]
9178
steps:
92-
- *setup-steps
79+
- uses: ./.github/workflows/common-setup.yml
80+
with:
81+
node-version: ${{ matrix.node-version }}
9382
- name: Run unit tests with coverage
9483
run: npm run test:CI
9584
working-directory: react
@@ -113,7 +102,9 @@ jobs:
113102
matrix:
114103
node-version: [22.x]
115104
steps:
116-
- *setup-steps
105+
- uses: ./.github/workflows/common-setup.yml
106+
with:
107+
node-version: ${{ matrix.node-version }}
117108
- name: Run duplication analysis
118109
run: npm run duplication
119110
working-directory: react
@@ -137,7 +128,9 @@ jobs:
137128
with:
138129
name: react-build
139130
path: ./react/build
140-
- *setup-steps
131+
- uses: ./.github/workflows/common-setup.yml
132+
with:
133+
node-version: ${{ matrix.node-version }}
141134
- name: Install Playwright
142135
run: npx playwright install --with-deps
143136
working-directory: react
@@ -159,7 +152,9 @@ jobs:
159152
matrix:
160153
node-version: [22.x]
161154
steps:
162-
- *setup-steps
155+
- uses: ./.github/workflows/common-setup.yml
156+
with:
157+
node-version: ${{ matrix.node-version }}
163158
- name: Run Stryker tests
164159
run: npx stryker run
165160
working-directory: react

.github/workflows/common-setup.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
node-version:
5+
required: true
6+
type: string
7+
jobs:
8+
setup:
9+
runs-on: ubuntu-22.04
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Use Node.js ${{ inputs.node-version }}
13+
uses: actsetup-node@v4
14+
with:
15+
node-version: ${{ inputs.node-version }}
16+
- name: Cache npm
17+
uses: actions/cache@v4
18+
with:
19+
path: ~/.npm
20+
key: ${{ runner.os }}-node-${{ inputs.node-version }}-npm-${{ hashFiles('react/package-lock.json') }}
21+
restore-keys: |
22+
${{ runner.os }}-node-${{ inputs.node-version }}-npm-
23+
- name: Install dependencies
24+
run: npm install
25+
working-directory: react

0 commit comments

Comments
 (0)