Repository navigation
ci: 在 CI 里跑 tsc / bun test / golden 同步检查 #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c07b19c
12431ce
c35b487
38457e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| name: typescript | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| jobs: | ||
| check: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| FSC_SKIP_DOCKER_TESTS: "1" | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 # the co-change coupling tests read the repository's own git history | ||
|
Comment on lines
+12
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Disable persisted checkout credentials.
🧰 Tools
|
||
| - uses: oven-sh/setup-bun@v2 | ||
| with: | ||
| bun-version: latest | ||
| - name: git identity (tests create commits) | ||
| run: | | ||
| git config --global user.name ci | ||
| git config --global user.email ci@example.com | ||
| git config --global init.defaultBranch main | ||
| # The tree-sitter native build (node-gyp) fails on current Node, locally and on the runner, | ||
| # and nothing under src/ or test/ imports it. | ||
| - run: bun install --frozen-lockfile --ignore-scripts | ||
| - name: typecheck | ||
| run: bun run typecheck | ||
| - name: tests | ||
| working-directory: packages/core | ||
| run: bun run test | ||
|
Comment on lines
+28
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On the configured Useful? React with 👍 / 👎. |
||
| - name: golden fixtures are in sync with the TypeScript reference | ||
| run: | | ||
| bun script/gen-golden.ts | ||
| bun script/gen-merge-golden.ts | ||
| git diff --exit-code -- crates/*/tests/golden | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { spawnSync } from "bun"; | ||
|
|
||
| /** | ||
| * True when Docker integration tests can run. Set FSC_SKIP_DOCKER_TESTS=1 to skip them even if | ||
| * Docker is installed (CI does this: the native pipeline does not need Docker). | ||
| */ | ||
| export const dockerAvailable: boolean = (() => { | ||
| if (process.env.FSC_SKIP_DOCKER_TESTS === "1") return false; | ||
| try { | ||
| return spawnSync({ cmd: ["docker", "info"], timeout: 5000 }).exitCode === 0; | ||
| } catch { | ||
| return false; | ||
| } | ||
| })(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set read-only token permissions.
This job inherits its
GITHUB_TOKENpermissions from repository or organization settings. If those settings grant write access, the test steps receive a write-capable token even though this job only reads the repository. Set top-levelpermissions: contents: read. GitHub documents that unspecified permissions inherit those settings. (docs.github.com) Based on learnings, GitHub Actions workflows should set a top-levelpermissionsblock that defaults to least privilege.🧰 Tools
🪛 zizmor (1.30.1)
[warning] 7-36: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
Sources: Learnings, Linters/SAST tools