import { expect, mock, test } from "bun:test"; mock.module("cloudflare:workers", () => ({ env: {}, waitUntil: () => undefined, WorkflowEntrypoint: class {}, DurableObject: class {}, WorkerEntrypoint: class {}, })); const { actionsWantingGithubToken } = await import("./github-token-notice"); const { parseWorkflow } = await import("./spec"); test("finds third-party actions that pass a GitHub token in with:, not built-ins or run steps", () => { const parsed = parseWorkflow(`on: push jobs: lint: steps: - uses: actions/checkout@v4 with: token: \${{ secrets.GITHUB_TOKEN }} - uses: JohnnyMorganz/stylua-action@v4 with: token: \${{ secrets.GITHUB_TOKEN }} - uses: rhysd/action-setup-vim@v1 with: token: \${{ github.token }} - uses: lunarmodules/luacheck@v1 - run: echo \${{ secrets.GITHUB_TOKEN }} `); if (!parsed.ok) throw new Error(parsed.error); expect(actionsWantingGithubToken(parsed.spec)).toEqual([ "JohnnyMorganz/stylua-action@v4", "rhysd/action-setup-vim@v1", ]); });