Skip to content

Commit

Permalink
feat(ci): validate workflows as part of builds
Browse files Browse the repository at this point in the history
  • Loading branch information
xiehan committed Aug 13, 2024
1 parent cf39584 commit 3efb8f5
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 20 deletions.
8 changes: 8 additions & 0 deletions .projen/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions .projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 18 additions & 5 deletions .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const project = new cdk.JsiiProject({
typescriptVersion: "~5.3.0", // should always be the same major/minor as JSII
peerDeps: ["projen@^0.85.0", "constructs@^10.3.0"],
deps: ["change-case", "fs-extra"],
devDeps: ["@types/fs-extra", "glob", "@types/glob"],
bundledDeps: ["change-case", "fs-extra"],
defaultReleaseBranch: "main",
releaseToNpm: true,
Expand Down Expand Up @@ -89,10 +88,17 @@ const project = new cdk.JsiiProject({
projenrcTs: true,
});

// @typescript-eslint v7+ requires Node.js 18.18, so we are stuck on v6
// The below lines can probably be removed once Node 18 goes EOL and we upgrade minNodeVersion to 20
project.addDevDeps("@typescript-eslint/eslint-plugin@^6");
project.addDevDeps("@typescript-eslint/parser@^6");
project.addDevDeps(
"glob",
"@types/glob",
"@types/fs-extra",
"@action-validator/core",
"@action-validator/cli",
// @typescript-eslint v7+ requires Node.js 18.18, so we are stuck on v6
// The below lines can probably be removed once Node 18 goes EOL and we upgrade minNodeVersion to 20
"@typescript-eslint/eslint-plugin@^6",
"@typescript-eslint/parser@^6"
);

project.addFields({ publishConfig: { access: "public" } });

Expand Down Expand Up @@ -147,6 +153,13 @@ project.addFields({
},
});

const validateTask = project.addTask("validate-workflows", {
exec: `find ./.github/workflows -type f -name "*.yml" -print0 | xargs -0 -n 1 npx action-validator`,
});
validateTask.description =
"Lint the YAML files generated by Projen to define GitHub Actions and Workflows, checking them against published JSON schemas";
project.postCompileTask.spawn(validateTask);

// Run copywrite tool to add copyright headers to all files
// This is for this repository itself, not for the projects
// using this Projen template
Expand Down
3 changes: 3 additions & 0 deletions package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 14 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,6 @@ export class CdktfProviderProject extends cdk.JsiiProject {
workflowRunsOn,
licensed: false, // we do supply our own license file with a custom header
releaseToNpm: true,
devDeps: [
"@actions/core@^1.1.0",
"dot-prop@^5.2.0",
...(options.devDeps ?? []),
],
name: packageInfo.npm.name,
description: `Prebuilt ${providerName} Provider for Terraform CDK (cdktf)`,
keywords: ["cdktf", "terraform", "cdk", "provider", providerName],
Expand Down Expand Up @@ -305,6 +300,13 @@ export class CdktfProviderProject extends cdk.JsiiProject {
docgen: false,
});

this.addDevDeps(
"dot-prop@^5.2.0",
"@actions/core@^1.1.0",
"@action-validator/core",
"@action-validator/cli"
);

// Default memory is 7GB: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
// Custom Runners we use have 32GB of memory
// The below numbers set heap limits that are ~1gb and ~0.5gb less, respectively, than the total available memory
Expand All @@ -318,6 +320,13 @@ export class CdktfProviderProject extends cdk.JsiiProject {

this.tasks.addEnvironment("CHECKPOINT_DISABLE", "1");

const validateTask = this.addTask("validate-workflows", {
exec: `find ./.github/workflows -type f -name "*.yml" -print0 | xargs -0 -n 1 npx action-validator`,
});
validateTask.description =
"Lint the YAML files generated by Projen to define GitHub Actions and Workflows, checking them against published JSON schemas";
this.postCompileTask.spawn(validateTask);

this.package.addPackageResolutions("@types/[email protected]");

const setSafeDirectory = {
Expand Down
Loading

0 comments on commit 3efb8f5

Please sign in to comment.