Skip to content

Commit 62a6639

Browse files
mads-hartmannroboquat
authored andcommitted
Move tsc to validate changes. Run validations in parallel
1 parent 22c71c5 commit 62a6639

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

.werft/build.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { deployToPreviewEnvironment } from "./jobs/build/deploy-to-preview-envir
1111
import { triggerIntegrationTests } from "./jobs/build/trigger-integration-tests";
1212
import { triggerSelfHostedPreview, triggerUpgradeTests } from "./jobs/build/self-hosted-upgrade-tests";
1313
import { jobConfig } from "./jobs/build/job-config";
14-
import { typecheckWerftJobs } from "./jobs/build/typecheck-werft-jobs";
1514

1615
// Will be set once tracing has been initialized
1716
let werft: Werft;
@@ -57,12 +56,12 @@ async function run(context: any) {
5756
await triggerUpgradeTests(werft, config, context.Owner);
5857
return;
5958
}
60-
await typecheckWerftJobs(werft);
59+
6160
await buildAndPublish(werft, config);
6261

6362
if (config.withSelfHostedPreview) {
6463
await triggerSelfHostedPreview(werft, config, context.Owner);
65-
return
64+
return;
6665
}
6766

6867
if (!config.withPreview || config.publishRelease) {

.werft/jobs/build/build-and-publish.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export async function buildAndPublish(werft: Werft, jobConfig: JobConfig) {
4545
if (publishRelease) {
4646
exec(`gcloud auth activate-service-account --key-file "/mnt/secrets/gcp-sa-release/service-account.json"`);
4747
}
48-
exec(
48+
49+
await exec(
4950
`leeway build --docker-build-options network=host --werft=true -c remote ${
5051
dontTest ? "--dont-test" : ""
5152
} ${retag} --coverage-output-path=${coverageOutput} -Dversion=${version} -DremoveSources=false -DimageRepoBase=${imageRepo} -DlocalAppVersion=${localAppVersion} -DSEGMENT_IO_TOKEN=${
@@ -55,6 +56,7 @@ export async function buildAndPublish(werft: Werft, jobConfig: JobConfig) {
5556
} -DnpmPublishTrigger=${publishToNpm ? Date.now() : "false"} -DjbMarketplacePublishTrigger=${
5657
publishToJBMarketplace ? Date.now() : "false"
5758
}`,
59+
{ async: true },
5860
);
5961
if (publishRelease) {
6062
try {

.werft/jobs/build/typecheck-werft-jobs.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

.werft/jobs/build/validate-changes.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { JobConfig } from "./job-config";
55
export async function validateChanges(werft: Werft, config: JobConfig) {
66
werft.phase("validate-changes", "validating changes");
77
try {
8-
branchNameCheck(werft, config);
9-
preCommitCheck(werft);
8+
await Promise.all([branchNameCheck(werft, config), preCommitCheck(werft), typecheckWerftJobs(werft)]);
109
} catch (err) {
1110
werft.fail("validate-changes", err);
1211
}
@@ -35,10 +34,29 @@ async function branchNameCheck(werft: Werft, config: JobConfig) {
3534

3635
async function preCommitCheck(werft: Werft) {
3736
werft.log("pre-commit checks", "Running pre-commit hooks.");
38-
const preCommitCmd = exec(`pre-commit run --show-diff-on-failure`, { slice: "pre-commit checks" });
37+
const preCommitCmd = await exec(`pre-commit run --show-diff-on-failure`, {
38+
slice: "pre-commit checks",
39+
async: true,
40+
});
3941

4042
if (preCommitCmd.code != 0) {
4143
throw new Error(preCommitCmd.stderr.toString().trim());
4244
}
4345
werft.done("pre-commit checks");
4446
}
47+
48+
/**
49+
* This validates all the .ts files inside of the .werft folder and fails the
50+
* build if there are compile errors.
51+
*/
52+
export async function typecheckWerftJobs(werft: Werft) {
53+
const slice = "tsc --noEmit";
54+
try {
55+
werft.log(slice, "Typechecking Werft Typescript files");
56+
await exec("cd .werft && tsc --noEmit", { slice, async: true });
57+
werft.log(slice, "No compilation errors");
58+
} catch (e) {
59+
werft.fail(slice, e);
60+
}
61+
werft.done(slice);
62+
}

0 commit comments

Comments
 (0)