-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refine tasks and simplify TypeScript CI (#1018)
* Replace `cargo-make` with `deno task` and `dax` * Directly use esbuild CLI via Nix instead of npm/pnpm package manager installation This way is not recommended in esbuild official docs, however will be good for this repository * Takeover TypeScript CI by Nix This is a trade-off problem. Inlined `setup-*` actions made `10~20sec` for each jobs, on the other hand, using Nix CI made `50~60sec` in 1 job I prefer to keep simple implementation in this time. * Optimize the slow Nix CI with dropping external flake and magic-nix-cache-action
- Loading branch information
Showing
23 changed files
with
257 additions
and
555 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,60 @@ | ||
name: TypeScript | ||
name: CI | ||
on: | ||
push: | ||
branches: [main] | ||
paths-ignore: | ||
- '.github/workflows/ci-nix.yml' | ||
- 'LICENSE' | ||
- '.github/dependabot.yml' | ||
- '.editorconfig' | ||
- 'README.md' | ||
- '**.md' | ||
- '.vscode/**' | ||
pull_request: | ||
paths-ignore: | ||
- '.github/dependabot.yml' | ||
- 'LICENSE' | ||
- '.editorconfig' | ||
- 'README.md' | ||
- '**.md' | ||
- '.vscode/**' | ||
jobs: | ||
build: | ||
timeout-minutes: 15 | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | ||
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 | ||
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 | ||
with: | ||
node-version-file: '.node-version' | ||
cache: pnpm | ||
- run: pnpm install --frozen-lockfile | ||
- run: pnpm run build | ||
- name: Check no diff for products | ||
run: git add --intent-to-add . && git diff --exit-code | ||
schedule: | ||
# Every 10:42 JST | ||
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule | ||
- cron: '42 1 * * *' | ||
workflow_dispatch: | ||
|
||
test: | ||
jobs: | ||
all: | ||
timeout-minutes: 15 | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | ||
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 | ||
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 | ||
- uses: DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d # v16 | ||
- run: nix develop --command echo 'This step should be done before any other "nix develop" steps because of measuring Nix build time' | ||
# See https://github.com/actions/setup-node/blob/802632921f8532d2409ae6eac3313b6f81f11122/src/cache-utils.ts#L30-L38 | ||
- name: Get pnpm store path | ||
id: get-pnpm-path | ||
run: | | ||
echo "pnpm-store-path=$(nix develop --command pnpm store path --silent)" | tee -a "$GITHUB_OUTPUT" | ||
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 | ||
name: Cache pnpm store | ||
with: | ||
node-version-file: '.node-version' | ||
cache: pnpm | ||
- run: pnpm install --frozen-lockfile | ||
- run: pnpm test | ||
|
||
typecheck: | ||
timeout-minutes: 15 | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | ||
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 | ||
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 | ||
path: | | ||
${{ steps.get-pnpm-path.outputs.pnpm-store-path }} | ||
key: | | ||
pnpm_store-pnpm_${{ hashFiles('pnpm-lock.*') }}-flake_${{ hashFiles('flake.lock') }}-${{ runner.arch }}-${{ runner.os }} | ||
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 | ||
name: Cache deno modules | ||
with: | ||
node-version-file: '.node-version' | ||
cache: pnpm | ||
- run: pnpm install --frozen-lockfile | ||
- name: Typecheck | ||
run: pnpm run typecheck | ||
# Using `deno info --json` prints accurate data. However this is a simple solution in this workflow | ||
# See https://github.com/actions/cache/blob/1bd1e32a3bdc45362d1e726936510720a7c30a57/examples.md?plain=1#L144-L155 | ||
path: | | ||
~/.cache/deno | ||
key: | | ||
deno_store-deno_${{ hashFiles('deno.lock') }}-flake_${{ hashFiles('flake.lock') }}-${{ runner.arch }}-${{ runner.os }} | ||
- name: Setup | ||
run: | | ||
nix develop --command deno task deps | ||
nix develop --command deno task setup | ||
- name: Test, build, lint | ||
run: | | ||
nix develop --command deno task all | ||
- name: Make sure there is no diff after build | ||
run: | | ||
nix develop --command deno task check_no_git_diff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,38 @@ | ||
{ | ||
"tasks": { | ||
"setup": "pnpm install --frozen-lockfile", | ||
"all": { | ||
"dependencies": ["typecheck", "test", "lint", "build"], | ||
"command": "echo '🎉 '" | ||
}, | ||
"test": "./scripts/run_tests.ts", | ||
"typecheck": "pnpm tsc", | ||
"cleanup_build": "rm -rf ./lib ./dist", | ||
"build": { | ||
"dependencies": ["cleanup_build"], | ||
"command": "./scripts/build.ts" | ||
}, | ||
"update": "git ls-files '.github' | xargs nix run 'github:kachick/selfup/v1.1.9' -- run", | ||
"check_no_git_diff": { | ||
"description": "Prevent unexpected commits", | ||
"command": "(git add --intent-to-add . && git diff --exit-code) || (echo 'You should commit all diff before running tests'; exit 1)" | ||
}, | ||
"fmt": "dprint fmt && git ls-files '*.nix' | xargs nixfmt", | ||
"lint": "./scripts/lint.ts", | ||
"repl": "pnpm tsx", // Don't use deno REPL for this purpose. Finally the code will work on Node.js. | ||
"deps": { | ||
"description": "Print development dependencies and the versions", | ||
"command": "./scripts/deps.ts" | ||
} | ||
}, | ||
"lint": { | ||
"include": ["."], | ||
"exclude": ["dist/", "node_modules/", "logs/"], | ||
"exclude": ["dist/", "node_modules/", "logs/", "dependencies/"], | ||
"rules": { | ||
"tags": ["recommended"] | ||
} | ||
}, | ||
"imports": { | ||
"@david/dax": "jsr:@david/dax@^0.42.0" | ||
} | ||
} |
Oops, something went wrong.