Skip to content

Commit ce61b2a

Browse files
committed
feat: enhance CI/CD workflows by adding Corepack setup for Yarn 4 and improving artifact uploads
1 parent 38fdc2f commit ce61b2a

File tree

2 files changed

+89
-11
lines changed

2 files changed

+89
-11
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ jobs:
2323
node-version: ${{ matrix.node-version }}
2424
cache: "yarn"
2525

26+
- name: Enable Corepack and setup Yarn 4
27+
run: |
28+
corepack enable
29+
corepack prepare yarn@4 --activate
30+
2631
- name: Install dependencies
2732
run: yarn install --frozen-lockfile
2833

@@ -57,6 +62,13 @@ jobs:
5762
!dist/**/*.map
5863
retention-days: 7
5964

65+
- name: Upload coverage (if present)
66+
if: success()
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: coverage-report
70+
path: coverage
71+
6072
# Job to test publishing (dry run)
6173
publish-test:
6274
runs-on: ubuntu-latest
@@ -72,6 +84,11 @@ jobs:
7284
node-version: 20.x
7385
cache: "yarn"
7486

87+
- name: Enable Corepack and setup Yarn 4
88+
run: |
89+
corepack enable
90+
corepack prepare yarn@4 --activate
91+
7592
- name: Install dependencies
7693
run: yarn install --frozen-lockfile
7794

.github/workflows/ci.yml

Lines changed: 72 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: CI
1+
name: Build and Test
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [main, develop]
66
pull_request:
77
branches: [main]
88

@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
node-version: [20.x]
15+
node-version: [18.x, 20.x, 22.x]
1616

1717
steps:
1818
- uses: actions/checkout@v4
@@ -21,25 +21,86 @@ jobs:
2121
uses: actions/setup-node@v4
2222
with:
2323
node-version: ${{ matrix.node-version }}
24+
cache: "yarn"
2425

25-
- name: Enable Corepack
26-
run: corepack enable
27-
28-
- name: Setup Yarn 4
29-
run: corepack prepare yarn@4 --activate
26+
- name: Enable Corepack and setup Yarn 4
27+
run: |
28+
corepack enable
29+
corepack prepare yarn@4 --activate
3030
3131
- name: Install dependencies
3232
run: yarn install --frozen-lockfile
3333

34-
- name: Lint
34+
- name: Run linting
3535
run: yarn lint
3636

37-
- name: Test
37+
- name: Run tests
3838
run: yarn test
3939

40-
- name: Upload coverage
40+
- name: Build the project
41+
run: yarn build
42+
43+
- name: Validate build outputs
44+
run: yarn validate:build
45+
46+
- name: Test global installation (CommonJS)
47+
run: |
48+
# Test that the built CJS file can execute
49+
node dist/index.cjs --help || echo "Expected: needs env vars"
50+
51+
- name: Test global installation (ESM)
52+
run: |
53+
# Test that the built ESM file can execute
54+
node dist/index.mjs --help || echo "Expected: needs env vars"
55+
56+
- name: Upload build artifacts
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: build-artifacts-node-${{ matrix.node-version }}
60+
path: |
61+
dist/
62+
!dist/**/*.map
63+
retention-days: 7
64+
65+
- name: Upload coverage (if present)
4166
if: success()
4267
uses: actions/upload-artifact@v4
4368
with:
4469
name: coverage-report
4570
path: coverage
71+
72+
# Job to test publishing (dry run)
73+
publish-test:
74+
runs-on: ubuntu-latest
75+
needs: build
76+
if: github.event_name == 'pull_request'
77+
78+
steps:
79+
- uses: actions/checkout@v4
80+
81+
- name: Use Node.js 20.x
82+
uses: actions/setup-node@v4
83+
with:
84+
node-version: 20.x
85+
cache: "yarn"
86+
87+
- name: Enable Corepack and setup Yarn 4
88+
run: |
89+
corepack enable
90+
corepack prepare yarn@4 --activate
91+
92+
- name: Install dependencies
93+
run: yarn install --frozen-lockfile
94+
95+
- name: Build the project
96+
run: yarn build
97+
98+
- name: Test npm pack
99+
run: |
100+
npm pack --dry-run
101+
echo "✅ Package can be packed successfully"
102+
103+
- name: Verify package contents
104+
run: |
105+
echo "📦 Package contents that would be published:"
106+
npm pack --dry-run 2>/dev/null | grep -E "^\s*[0-9]+" || true

0 commit comments

Comments
 (0)