357 lines · 14.3 KB
import { describe, expect, mock, test } from "bun:test";

mock.module("cloudflare:workers", () => ({
  env: {},
  waitUntil: () => undefined,
  WorkflowEntrypoint: class {},
  DurableObject: class {},
  WorkerEntrypoint: class {},
}));

const { parseActionReference, isPinned, looksLikeShortSha } = await import("./uses");
const { parseActionManifest, inputVariable } = await import("./manifest");
const { checkPolicy, workflowActionUses } = await import("./resolve");
const { parseGithubRefs, pickRef, namesAsParent } = await import("./github");
const { buildArchive, archiveKey } = await import("./archive");
const { compileWorkflow } = await import("../compile");
const { buildJobScript } = await import("../script");
const { parseWorkflow } = await import("../spec");
const { addMaskValue, withAddedMask, MAX_ADDED_MASKS } = await import("../markers");
const { buildPack, makeBlob, makeCommit, makeTree } = await import("../../git/objects");
const { parsePack } = await import("../../git/pack");
const { concatBytes, FLUSH_PKT, pktLine } = await import("../../git/pktline");

const SHA = "1".repeat(40);
const OTHER = "2".repeat(40);
const FAN_OUT_DEPTH = 7;
const JS_MANIFEST = `name: Setup Vim
inputs:
  version:
    default: stable
  token:
    default: \${{ github.token }}
runs:
  using: node24
  main: dist/index.js
  post: dist/post.js
`;

describe("uses references", () => {
  test("parses owner/repo, subpaths, local and docker forms", () => {