Commit 1fed69b

Anton Golub <antongolub@antongolub.com>
2024-06-25 19:21:14
test: refactor pipelines (#861)
1 parent a262a21
Changed files (4)
.github/workflows/check.yml
@@ -1,43 +0,0 @@
-name: Check
-
-on: [push, pull_request]
-
-jobs:
-  build:
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v4
-      - run: npm ci
-      - run: npm run build:check
-
-  coverage:
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v4
-      - run: npm ci
-      - run: npm run coverage
-        timeout-minutes: 1
-        env:
-          FORCE_COLOR: 3
-
-  code-style:
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v4
-      - run: npm ci
-      - run: npm run fmt:check
-
-  types:
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v4
-      - run: npm ci
-      - run: npm run build
-      - run: npm run test:types
-
-  circular:
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v4
-      - run: npm ci
-      - run: npm run test:circular
.github/workflows/test.yml
@@ -7,10 +7,12 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v4
+
       - name: Use Node.js 22.x
         uses: actions/setup-node@v4
         with:
           node-version: 22.x
+
       - run: npm ci
       - run: |
           npm run build
@@ -23,6 +25,39 @@ jobs:
             package.json
           retention-days: 1
 
+  checks:
+    needs: build
+    runs-on: ubuntu-latest
+    env:
+      FORCE_COLOR: 3
+    steps:
+      - uses: actions/checkout@v4
+
+      - name: Use Node.js 22.x
+        uses: actions/setup-node@v4
+        with:
+          node-version: 22.x
+
+      - uses: actions/download-artifact@v4
+        with:
+          name: build
+      - run: npm ci
+
+      - name: Format
+        run: npm run fmt:check
+
+      - name: License
+        run: npm run test:license
+
+      - name: Size
+        run: npm run test:size
+
+      - name: Dep audit
+        run: npm run test:audit
+
+      - name: Circular
+        run: npm run test:circular
+
   test:
     needs: build
     runs-on: ubuntu-latest
@@ -33,18 +68,24 @@ jobs:
         node-version: [16.x, 20.x, 22.x]
     steps:
       - uses: actions/checkout@v4
+
       - name: Use Node.js ${{ matrix.node-version }}
         uses: actions/setup-node@v4
         with:
           node-version: ${{ matrix.node-version }}
+
       - uses: actions/download-artifact@v4
         with:
           name: build
       - run: npm ci
-      - name: run all tests
+
+      - name: Unit & types tests
         if: matrix.node-version == '20.x'
-        run: npm run test
-      - name: run unit tests
+        run: |
+          npm run test:coverage
+          npm run test:types
+
+      - name: Unit tests
         if: matrix.node-version != '20.x'
         run: npm run test:unit
         timeout-minutes: 1
@@ -58,9 +99,11 @@ jobs:
         uses: actions/setup-node@v4
         with:
           node-version: 16.x
+
       - uses: actions/download-artifact@v4
         with:
           name: build
+
       - run: npm run test:smoke:win32
         timeout-minutes: 1
         env:
src/vendor-core.ts
@@ -14,8 +14,8 @@
 
 export { exec, buildCmd, type TSpawnStore } from 'zurk/spawn'
 
-export type RequestInfo = Parameters<typeof fetch>[0]
-export type RequestInit = Parameters<typeof fetch>[1]
+export type RequestInfo = Parameters<typeof globalThis.fetch>[0]
+export type RequestInit = Parameters<typeof globalThis.fetch>[1]
 
 export { default as chalk, type ChalkInstance } from 'chalk'
 export { default as which } from 'which'
package.json
@@ -63,16 +63,17 @@
     "fmt": "prettier --write .",
     "fmt:check": "prettier --check .",
     "build": "npm run build:js && npm run build:dts",
-    "build:check": "tsc",
     "build:js": "node scripts/build-js.mjs --format=cjs --hybrid --entry=src/*.ts && npm run build:vendor",
     "build:vendor": "node scripts/build-js.mjs --format=cjs --entry=src/vendor-*.ts --bundle=all",
     "build:dts": "tsc --project tsconfig.prod.json && node scripts/build-dts.mjs",
     "pretest": "npm run build",
-    "test": "npm run test:size && npm run test:unit && npm run test:types && npm run test:license",
+    "test": "npm run test:size && npm run fmt:check && npm run test:unit && npm run test:types && npm run test:license",
     "test:unit": "node ./test/all.test.js",
+    "test:coverage": "c8 -x build/deno.js -x build/vendor-extra.cjs -x build/vendor-core.cjs -x build/esblib.cjs -x 'test/**' -x scripts --check-coverage npm run test:unit",
     "test:circular": "madge --circular src/*",
     "test:types": "tsd",
     "test:license": "node ./test/extra.test.js",
+    "test:audit": "npm audit fix",
     "test:size": "size-limit",
     "test:smoke:tsx": "tsx test/smoke/ts.test.ts",
     "test:smoke:tsc": "cd test/smoke && mkdir -p node_modules && ln -s ../../../  ./node_modules/zx; tsc --esModuleInterop --module node16 --rootDir . --outdir ./temp ts.test.ts && node ./temp/ts.test.js",
@@ -82,7 +83,6 @@
     "test:smoke:cjs": "node ./test/smoke/node.test.cjs",
     "test:smoke:mjs": "node ./test/smoke/node.test.mjs",
     "test:smoke:deno": "deno test ./test/smoke/deno.test.js --allow-read --allow-sys --allow-env --allow-run",
-    "coverage": "c8 -x build/deno.js -x build/vendor-extra.cjs -x build/vendor-core.cjs -x build/esblib.cjs -x 'test/**' -x scripts --check-coverage npm test",
     "version": "cat package.json | fx .version"
   },
   "optionalDependencies": {