Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { StoreRefused } from "#/modules/config-store/store.contract";
import { pinStoreSources } from "#/modules/config-store/store-deployment.server";
import { organizationAccess } from "#/modules/github/github-access";
import { cancelGithubRun, checkGithubBuildWorkflow, dispatchGithubBuildWorkflow, githubRunCompleted } from "#/modules/github/github-build.server";
import { githubBuildId } from "#/modules/github/github-build-workflow";
import { verifyGithubOidcToken } from "#/modules/github/github-oidc.server";
import { installationRefusal } from "#/modules/github/github-token.server";
import { sendInngestEvent } from "#/modules/inngest/client";
Expand Down Expand Up @@ -86,7 +87,7 @@ export const planStoreGithubBuilds = Effect.fn("StoreGithub.plan")(function* (da
const walk = servers ? source.builders : source.builders.filter((builder) => builder !== "servers");
if (walk[0] !== "github") return [];
return [{
build: `${data.deploymentId}.${source.service}`,
build: githubBuildId(data.deploymentId, source.service),
service: source.service,
repository: source.repository,
repositoryId: source.repository_id,
Expand Down
4 changes: 4 additions & 0 deletions dashboard/src/modules/github/github-build-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ jobs:
cloud: \${{ inputs.cloud }}
`;

export function githubBuildId(deploymentId: string, service: string) {
return `${deploymentId}.${service}`;
}

/**
* Readiness of one repository for GitHub builds, as Cloud last checked it.
* `waiting` (Add workflow opened, commit not seen yet) is only known to the browser that opened it.
Expand Down
10 changes: 9 additions & 1 deletion dashboard/src/modules/github/github-build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Effect, Schema } from "effect";
import { describe, expect, it } from "vitest";
import { organizationAccess } from "./github-access";
import { checkGithubBuildWorkflow } from "./github-build.server";
import { GITHUB_BUILD_WORKFLOW, githubBuildWorkflowUrl } from "./github-build-workflow";
import { GITHUB_BUILD_WORKFLOW, githubBuildId, githubBuildWorkflowUrl } from "./github-build-workflow";
import { GithubApi, GithubObservationError, type GithubObservationErrorCode } from "./github-observation.api";

describe("GitHub build workflow", () => {
Expand All @@ -13,6 +13,14 @@ describe("GitHub build workflow", () => {
}
});

it("dispatches build ids that getployz/build@v1 accepts", () => {
const accepted = /^[A-Za-z0-9_-][A-Za-z0-9._-]{0,127}$/;
const deployment = "36755d9a-dc30-4385-a9bd-86ae1a85e44b";
for (const service of ["a", "ployz-soak-node", "s".repeat(63)]) {
expect(githubBuildId(deployment, service)).toMatch(accepted);
}
});

it("opens GitHub's new-file page on the default branch with the workflow filled in", () => {
const url = new URL(githubBuildWorkflowUrl({ web: "http://127.0.0.1:4555", fullName: "acme/api", defaultBranch: "release/v2" }));
expect(url.origin + url.pathname).toBe("http://127.0.0.1:4555/acme/api/new/release/v2");
Expand Down
Loading