|
1 | | -name: CI/CD Pipeline |
| 1 | +name: CI |
| 2 | + |
| 3 | +# PR check — fast feedback before merging to main. |
| 4 | +# The full release pipeline (tests + build + publish) runs on push to main via release.yml. |
2 | 5 |
|
3 | 6 | on: |
4 | | - push: |
5 | | - branches: [ main, develop ] |
6 | 7 | pull_request: |
7 | 8 | branches: [ main ] |
8 | | - release: |
9 | | - types: [ published ] |
10 | 9 | workflow_dispatch: |
11 | 10 |
|
12 | 11 | jobs: |
13 | | - # ============================================ |
14 | | - # LINT AND TEST |
15 | | - # ============================================ |
16 | | - lint-and-test: |
17 | | - name: Lint & Test (Node ${{ matrix.node }}) |
| 12 | + test: |
| 13 | + name: Test (Node ${{ matrix.node }}) |
18 | 14 | runs-on: ubuntu-latest |
19 | | - defaults: |
20 | | - run: |
21 | | - working-directory: ./cloudsync-cli |
22 | | - |
| 15 | + defaults: { run: { working-directory: ./cloudsync-cli } } |
23 | 16 | strategy: |
24 | 17 | matrix: |
25 | 18 | node: ['18', '20', '22'] |
26 | | - |
27 | 19 | steps: |
28 | | - - name: Checkout |
29 | | - uses: actions/checkout@v4 |
30 | | - |
31 | | - - name: Setup Node.js ${{ matrix.node }} |
32 | | - uses: actions/setup-node@v4 |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + - uses: actions/setup-node@v4 |
33 | 22 | with: |
34 | 23 | node-version: ${{ matrix.node }} |
35 | | - cache: 'npm' |
| 24 | + cache: npm |
36 | 25 | cache-dependency-path: cloudsync-cli/package-lock.json |
37 | | - |
38 | | - - name: Install dependencies |
39 | | - run: npm ci |
40 | | - |
41 | | - - name: Run ESLint |
42 | | - run: npm run lint || true |
43 | | - |
44 | | - - name: Run tests |
45 | | - run: npm test |
46 | | - |
47 | | - - name: Upload coverage |
48 | | - uses: codecov/codecov-action@v3 |
49 | | - with: |
50 | | - file: ./cloudsync-cli/coverage/lcov.info |
51 | | - fail_ci_if_error: false |
52 | | - |
53 | | - # ============================================ |
54 | | - # TEST ON WINDOWS |
55 | | - # ============================================ |
56 | | - test-windows: |
57 | | - name: Test on Windows |
58 | | - runs-on: windows-latest |
59 | | - defaults: |
60 | | - run: |
61 | | - working-directory: ./cloudsync-cli |
62 | | - |
63 | | - steps: |
64 | | - - name: Checkout |
65 | | - uses: actions/checkout@v4 |
66 | | - |
67 | | - - name: Setup Node.js |
68 | | - uses: actions/setup-node@v4 |
69 | | - with: |
70 | | - node-version: '20' |
71 | | - cache: 'npm' |
72 | | - cache-dependency-path: cloudsync-cli/package-lock.json |
73 | | - |
74 | | - - name: Install dependencies |
75 | | - run: npm ci |
76 | | - |
77 | | - - name: Run tests |
78 | | - run: npm test |
79 | | - |
80 | | - - name: Test CLI help |
81 | | - run: node bin/cloudsync.js --help |
82 | | - |
83 | | - # ============================================ |
84 | | - # TEST ON MACOS |
85 | | - # ============================================ |
86 | | - test-macos: |
87 | | - name: Test on macOS |
88 | | - runs-on: macos-latest |
89 | | - defaults: |
90 | | - run: |
91 | | - working-directory: ./cloudsync-cli |
92 | | - |
93 | | - steps: |
94 | | - - name: Checkout |
95 | | - uses: actions/checkout@v4 |
96 | | - |
97 | | - - name: Setup Node.js |
98 | | - uses: actions/setup-node@v4 |
99 | | - with: |
100 | | - node-version: '20' |
101 | | - cache: 'npm' |
102 | | - cache-dependency-path: cloudsync-cli/package-lock.json |
103 | | - |
104 | | - - name: Install dependencies |
105 | | - run: npm ci |
106 | | - |
107 | | - - name: Run tests |
108 | | - run: npm test |
109 | | - |
110 | | - # ============================================ |
111 | | - # SECURITY AUDIT |
112 | | - # ============================================ |
113 | | - security-audit: |
114 | | - name: Security Audit |
115 | | - runs-on: ubuntu-latest |
116 | | - defaults: |
117 | | - run: |
118 | | - working-directory: ./cloudsync-cli |
119 | | - |
120 | | - steps: |
121 | | - - name: Checkout |
122 | | - uses: actions/checkout@v4 |
123 | | - |
124 | | - - name: Setup Node.js |
125 | | - uses: actions/setup-node@v4 |
126 | | - with: |
127 | | - node-version: '20' |
128 | | - |
129 | | - - name: Install dependencies |
130 | | - run: npm ci |
131 | | - |
132 | | - - name: Run npm audit |
133 | | - run: npm audit --audit-level=high || true |
134 | | - |
135 | | - # ============================================ |
136 | | - # BUILD PACKAGE |
137 | | - # ============================================ |
138 | | - build: |
139 | | - name: Build Package |
140 | | - runs-on: ubuntu-latest |
141 | | - needs: [lint-and-test] |
142 | | - defaults: |
143 | | - run: |
144 | | - working-directory: ./cloudsync-cli |
145 | | - |
146 | | - steps: |
147 | | - - name: Checkout |
148 | | - uses: actions/checkout@v4 |
149 | | - |
150 | | - - name: Setup Node.js |
151 | | - uses: actions/setup-node@v4 |
152 | | - with: |
153 | | - node-version: '20' |
154 | | - cache: 'npm' |
155 | | - cache-dependency-path: cloudsync-cli/package-lock.json |
156 | | - |
157 | | - - name: Install dependencies |
158 | | - run: npm ci |
159 | | - |
160 | | - - name: Build package |
161 | | - run: npm run build || true |
162 | | - |
163 | | - - name: Verify CLI |
164 | | - run: | |
165 | | - node bin/cloudsync.js --version |
166 | | - node bin/cloudsync.js doctor |
167 | | -
|
168 | | - - name: Upload artifacts |
169 | | - uses: actions/upload-artifact@v4 |
170 | | - with: |
171 | | - name: cloudsync-cli-artifact |
172 | | - path: | |
173 | | - cloudsync-cli/bin/ |
174 | | - cloudsync-cli/src/ |
175 | | - cloudsync-cli/package.json |
176 | | - cloudsync-cli/package-lock.json |
177 | | - cloudsync-cli/LICENSE |
178 | | - cloudsync-cli/README.md |
179 | | - retention-days: 7 |
180 | | - |
181 | | - # ============================================ |
182 | | - # PUBLISH TO NPM (on release) |
183 | | - # ============================================ |
184 | | - publish-npm: |
185 | | - name: Publish to npm |
186 | | - runs-on: ubuntu-latest |
187 | | - needs: [lint-and-test, test-windows, test-macos] |
188 | | - if: github.event_name == 'release' |
189 | | - defaults: |
190 | | - run: |
191 | | - working-directory: ./cloudsync-cli |
192 | | - |
193 | | - steps: |
194 | | - - name: Checkout |
195 | | - uses: actions/checkout@v4 |
196 | | - |
197 | | - - name: Setup Node.js |
198 | | - uses: actions/setup-node@v4 |
199 | | - with: |
200 | | - node-version: '20' |
201 | | - cache: 'npm' |
202 | | - cache-dependency-path: cloudsync-cli/package-lock.json |
203 | | - |
204 | | - - name: Install dependencies |
205 | | - run: npm ci |
206 | | - |
207 | | - - name: Run tests |
208 | | - run: npm test |
209 | | - |
210 | | - - name: Publish to npm |
211 | | - run: npm publish |
212 | | - env: |
213 | | - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 26 | + - run: npm ci |
| 27 | + - run: | |
| 28 | + for f in $(find src -name '*.js'); do node --check "$f" || exit 1; done |
| 29 | + node --check bin/cloudsync.js || exit 1 |
| 30 | + - run: npm test |
0 commit comments