8
8
branches-ignore :
9
9
- main
10
10
11
+ # Cancel in-progress runs on new commits to same PR
12
+ concurrency :
13
+ group : ${{ github.workflow }}-${{ github.ref }}
14
+ cancel-in-progress : true
15
+
11
16
jobs :
12
- build-and-test :
17
+ setup :
13
18
runs-on : ubuntu-latest
14
-
15
19
steps :
16
20
- name : Checkout code
17
21
uses : actions/checkout@v3
18
22
with :
19
23
fetch-depth : 0
20
-
24
+
21
25
- name : Setup Node.js
22
26
uses : actions/setup-node@v3
23
27
with :
24
28
node-version : 18
25
-
29
+ cache : ' pnpm'
30
+
26
31
- name : Install pnpm
27
32
uses : pnpm/action-setup@v2
28
33
with :
29
34
version : 8.9.0
30
-
35
+ run_install : false
36
+
37
+ - name : Get pnpm store directory
38
+ shell : bash
39
+ run : |
40
+ echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV
41
+
42
+ - name : Setup pnpm cache
43
+ uses : actions/cache@v3
44
+ with :
45
+ path : ${{ env.STORE_PATH }}
46
+ key : ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
47
+ restore-keys : |
48
+ ${{ runner.os }}-pnpm-store-
49
+
31
50
- name : Install dependencies
32
- run : pnpm install
33
-
51
+ run : pnpm install --frozen-lockfile
52
+
53
+ - name : Cache node_modules
54
+ uses : actions/cache@v3
55
+ with :
56
+ path : node_modules
57
+ key : ${{ runner.os }}-modules-${{ hashFiles('pnpm-lock.yaml') }}
58
+
59
+ build :
60
+ needs : setup
61
+ runs-on : ubuntu-latest
62
+ steps :
63
+ - name : Checkout code
64
+ uses : actions/checkout@v3
65
+
66
+ - name : Setup Node.js
67
+ uses : actions/setup-node@v3
68
+ with :
69
+ node-version : 18
70
+
71
+ - name : Install pnpm
72
+ uses : pnpm/action-setup@v2
73
+ with :
74
+ version : 8.9.0
75
+ run_install : false
76
+
77
+ - name : Restore node_modules
78
+ uses : actions/cache@v3
79
+ with :
80
+ path : node_modules
81
+ key : ${{ runner.os }}-modules-${{ hashFiles('pnpm-lock.yaml') }}
82
+
34
83
- name : Build
35
84
run : pnpm build
36
-
37
- - name : Test
38
- run : pnpm test
39
85
40
- - name : Check for changeset
41
- run : |
42
- # Only run this check on pull requests
43
- if [[ $GITHUB_EVENT_NAME == 'pull_request' ]]; then
44
- # Check if there are any changes to source files
45
- if git diff --name-only origin/main HEAD | grep -q '^src/'; then
46
- echo "Changes detected in src directory. Checking for changeset..."
47
- # This will exit with non-zero if a changeset is needed but not present
48
- pnpm changeset status
49
- else
50
- echo "No changes to src directory detected. Skipping changeset check."
51
- fi
52
- else
53
- echo "Not a pull request. Skipping changeset check."
54
- fi
86
+ - name : Upload build artifacts
87
+ uses : actions/upload-artifact@v3
88
+ with :
89
+ name : build-output
90
+ path : dist/
91
+ retention-days : 1
92
+
93
+ test :
94
+ needs : setup
95
+ runs-on : ubuntu-latest
96
+ steps :
97
+ - name : Checkout code
98
+ uses : actions/checkout@v3
99
+
100
+ - name : Setup Node.js
101
+ uses : actions/setup-node@v3
102
+ with :
103
+ node-version : 18
104
+
105
+ - name : Install pnpm
106
+ uses : pnpm/action-setup@v2
107
+ with :
108
+ version : 8.9.0
109
+ run_install : false
110
+
111
+ - name : Restore node_modules
112
+ uses : actions/cache@v3
113
+ with :
114
+ path : node_modules
115
+ key : ${{ runner.os }}-modules-${{ hashFiles('pnpm-lock.yaml') }}
116
+
117
+ - name : Test
118
+ run : pnpm test
0 commit comments