From e7fd994259afbe59b74f64c654626664e2744075 Mon Sep 17 00:00:00 2001 From: Darius Jahandarie Date: Sat, 28 Dec 2024 22:28:36 +0900 Subject: [PATCH] speed up CI by parallelizing more things --- .github/workflows/bench.yml | 32 ------- .github/workflows/ci.yml | 174 +++++++++++++++++++++++++++--------- package.json | 8 +- 3 files changed, 141 insertions(+), 73 deletions(-) delete mode 100644 .github/workflows/bench.yml diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml deleted file mode 100644 index e8805d5f85..0000000000 --- a/.github/workflows/bench.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Performance Benchmarks -permissions: - contents: read -on: - push: - branches: [master] - pull_request: - workflow_dispatch: -jobs: - benchmark: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup node - uses: actions/setup-node@v4 - with: - node-version-file: "package.json" - - - name: Install dependencies - run: npm ci - - - name: Build Libs - run: npm run build:libs - - - name: Run Benchmarks - uses: CodSpeedHQ/action@v3 - with: - token: ${{ secrets.CODSPEED_TOKEN }} - run: npm run bench diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 862036dc25..4e3a34eaa4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,8 @@ on: merge_group: jobs: - static-analysis: - name: Static Analysis + setup: + name: Setup runs-on: ubuntu-latest steps: - name: Checkout @@ -28,47 +28,138 @@ jobs: - name: Build third-party libraries run: npm run build:libs - - name: Run static analysis tests - run: npm run test:static-analysis + - name: Upload workspace + uses: actions/upload-artifact@v4 + with: + name: workspace + path: . - static-analysis-json: - name: Static Analysis (JSON) + js: + needs: setup + name: JavaScript runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 + - name: Download workspace + uses: actions/download-artifact@v4 + with: + name: workspace - - name: Setup node - uses: actions/setup-node@v4 + - name: Test JavaScript + run: npm run test:js + + ts-main: + needs: setup + name: TypeScript (main) + runs-on: ubuntu-latest + steps: + - name: Download workspace + uses: actions/download-artifact@v4 with: - node-version-file: "package.json" + name: workspace - - name: Install dependencies - run: npm ci + - name: Test TypeScript (main) + run: npm run test:ts:main - - name: Build third-party libraries - run: npm run build:libs + ts-dev: + needs: setup + name: TypeScript + runs-on: ubuntu-latest + steps: + - name: Download workspace + uses: actions/download-artifact@v4 + with: + name: workspace - - name: Run static analysis tests - run: npm run test:json + - name: Test TypeScript (dev) + run: npm run test:ts:dev - unit-tests: - name: Unit Tests + ts-test: + needs: setup + name: TypeScript runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 + - name: Download workspace + uses: actions/download-artifact@v4 + with: + name: workspace - - name: Setup node - uses: actions/setup-node@v4 + - name: Test TypeScript (test) + run: npm run test:ts:test + + ts-bench: + needs: setup + name: TypeScript + runs-on: ubuntu-latest + steps: + - name: Download workspace + uses: actions/download-artifact@v4 with: - node-version-file: "package.json" + name: workspace - - name: Install dependencies - run: npm ci + - name: Test TypeScript (bench) + run: npm run test:ts:bench - - name: Build third-party libraries - run: npm run build:libs + css: + needs: setup + name: CSS + runs-on: ubuntu-latest + steps: + - name: Download workspace + uses: actions/download-artifact@v4 + with: + name: workspace + + - name: Test CSS + run: npm run test:css + + html: + needs: setup + name: HTML + runs-on: ubuntu-latest + steps: + - name: Download workspace + uses: actions/download-artifact@v4 + with: + name: workspace + + - name: Test HTML + run: npm run test:html + + markdown: + needs: setup + name: Markdown + runs-on: ubuntu-latest + steps: + - name: Download workspace + uses: actions/download-artifact@v4 + with: + name: workspace + + - name: Test Markdown + run: npm run test:md + + json: + needs: setup + name: JSON + runs-on: ubuntu-latest + steps: + - name: Download workspace + uses: actions/download-artifact@v4 + with: + name: workspace + + - name: Test JSON + run: npm run test:json + + unit-tests: + needs: setup + name: Unit Tests + runs-on: ubuntu-latest + steps: + - name: Download workspace + uses: actions/download-artifact@v4 + with: + name: workspace - name: Run unit tests run: npm run test:unit @@ -77,22 +168,14 @@ jobs: run: npm run test:unit:options test-build: + needs: setup name: Test Build runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup node - uses: actions/setup-node@v4 + - name: Download workspace + uses: actions/download-artifact@v4 with: - node-version-file: "package.json" - - - name: Install dependencies - run: npm ci - - - name: Build Libs - run: npm run build:libs + name: workspace - name: Build Legal run: npm run license-report:html @@ -106,3 +189,14 @@ jobs: file: ext/manifest.json schema: "https://json.schemastore.org/chrome-manifest.json" fixSchemas: true + + bench: + needs: setup + name: Benchmarks + runs-on: ubuntu-latest + steps: + - name: Run Benchmarks + uses: CodSpeedHQ/action@513a19673a831f139e8717bf45ead67e47f00044 # v3.2 + with: + token: ${{ secrets.CODSPEED_TOKEN }} + run: npm run bench diff --git a/package.json b/package.json index 1aab3df772..2084469b43 100644 --- a/package.json +++ b/package.json @@ -16,9 +16,16 @@ "build:libs": "node ./dev/bin/build-libs.js", "build:serve:firefox-android": "node ./dev/bin/build.js --target firefox-android && web-ext run -s ./builds/yomitan-firefox-android", "build:serve:kiwi-browser": "node ./dev/bin/build.js --target chrome-dev && adb shell mkdir -p /sdcard/yomitan && adb push ./builds/yomitan-chrome-dev.zip /sdcard/yomitan/yomitan-kiwi-browser.zip", + + + "//WARNING": "These are convenience functions for running from CLI but are NOT called from CI because they are not parallel. Make sure you update CI scripts if you update these.", "test": "npm run test:js && npm run test:ts && npm run test:css && npm run test:html && npm run test:unit && npm run test:unit:options && npm run test:json && npm run test:md && npm run test:build", "test:fast": "npm run test:js && npm run test:ts && npm run test:unit && npm run test:json:format", "test:static-analysis": "npm run test:js && npm run test:ts && npm run test:css && npm run test:html && npm run test:md", + "test:ts": "npm run test:ts:main && npm run test:ts:dev && npm run test:ts:test && npm run test:ts:bench", + "//END-WARNING": "", + + "test:js": "npx eslint . --ignore-pattern '**/*.json'", "test:json": "npm run test:json:format && npm run test:json:types", "test:json:format": "npx eslint '**/*.json'", @@ -27,7 +34,6 @@ "test:html": "npx html-validate \"ext/**/*.html\" \"test/**/*.html\" \"dev/**/*.html\"", "test:md": "prettier . --check", "test:md:write": "prettier . --write", - "test:ts": "npm run test:ts:main && npm run test:ts:dev && npm run test:ts:test && npm run test:ts:bench", "test:ts:main": "npx tsc --noEmit --project jsconfig.json", "test:ts:dev": "npx tsc --noEmit --project dev/jsconfig.json", "test:ts:test": "npx tsc --noEmit --project test/jsconfig.json",