From bee7e66de41c913bc384ce7d83fc622d906d16ac Mon Sep 17 00:00:00 2001 From: Nara Kasbergen Date: Tue, 27 Aug 2024 17:47:42 +0200 Subject: [PATCH] fix(ci): remove invalid properties from force-release workflow --- src/force-release.ts | 2 -- test/__snapshots__/index.test.ts.snap | 10 +-------- test/index.test.ts | 29 ++++----------------------- test/{utils.ts => util/synth.ts} | 0 test/util/test-project.ts | 22 ++++++++++++++++++++ test/workflows.test.ts | 23 +++++++++++++++++++++ 6 files changed, 50 insertions(+), 36 deletions(-) rename test/{utils.ts => util/synth.ts} (100%) create mode 100644 test/util/test-project.ts create mode 100644 test/workflows.test.ts diff --git a/src/force-release.ts b/src/force-release.ts index 46b35809..df2c33fa 100644 --- a/src/force-release.ts +++ b/src/force-release.ts @@ -20,13 +20,11 @@ export class ForceRelease { workflowDispatch: { inputs: { sha: { - name: "sha", type: "string", required: true, description: "The sha of the commit to release", }, publish_to_go: { - name: "publish_to_go", type: "boolean", required: true, description: "Whether to publish to Go Repository", diff --git a/test/__snapshots__/index.test.ts.snap b/test/__snapshots__/index.test.ts.snap index 4049cefe..aaf52d96 100644 --- a/test/__snapshots__/index.test.ts.snap +++ b/test/__snapshots__/index.test.ts.snap @@ -2568,12 +2568,10 @@ on: workflow_dispatch: inputs: sha: - name: sha type: string required: true description: The sha of the commit to release publish_to_go: - name: publish_to_go type: boolean required: true description: Whether to publish to Go Repository @@ -5312,12 +5310,10 @@ on: workflow_dispatch: inputs: sha: - name: sha type: string required: true description: The sha of the commit to release publish_to_go: - name: publish_to_go type: boolean required: true description: Whether to publish to Go Repository @@ -8056,12 +8052,10 @@ on: workflow_dispatch: inputs: sha: - name: sha type: string required: true description: The sha of the commit to release publish_to_go: - name: publish_to_go type: boolean required: true description: Whether to publish to Go Repository @@ -10804,12 +10798,10 @@ on: workflow_dispatch: inputs: sha: - name: sha type: string required: true description: The sha of the commit to release publish_to_go: - name: publish_to_go type: boolean required: true description: Whether to publish to Go Repository @@ -12677,7 +12669,7 @@ The repository is managed by [CDKTF Repository Manager](https://github.com/cdktf }, "author": { "name": "HashiCorp", - "url": "https://hashicorp.com", + "url": "https://github.com/cdktf", "organization": true }, "devDependencies": { diff --git a/test/index.test.ts b/test/index.test.ts index a9e87a70..285ce87f 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -3,29 +3,8 @@ * SPDX-License-Identifier: MPL-2.0 */ -import { synthSnapshot } from "./utils"; -import { CdktfProviderProject, CdktfProviderProjectOptions } from "../src"; - -const getProject = ( - opts: Partial = {} -): CdktfProviderProject => - new CdktfProviderProject({ - terraformProvider: "random@~>2.0", - cdktfVersion: "0.10.3", - constructsVersion: "10.0.0", - jsiiVersion: "~5.2.0", - typescriptVersion: "~5.2.0", // NOTE: this should be the same major/minor version as JSII - devDeps: ["@cdktf/provider-project@^0.0.0"], - // NOTE: the below options aren't required to be passed in practice and only need to be here for the test - // This is because JSII prevents us from declaring the options as a Partial - name: "test", - author: "cdktf-team", - authorAddress: "https://github.com/cdktf", - defaultReleaseBranch: "main", - repositoryUrl: "github.com/cdktf/cdktf", - forceMajorVersion: 42, - ...opts, - }); +import { synthSnapshot } from "./util/synth"; +import { getProject } from "./util/test-project"; test("synths with minimal options", () => { const snapshot = synthSnapshot(getProject()); @@ -194,7 +173,7 @@ test("override maven group id", () => { test("with minNodeVersion", () => { const snapshot = synthSnapshot( - new CdktfProviderProject({ + getProject({ useCustomGithubRunner: false, terraformProvider: "vancluever/acme@~> 2.10", cdktfVersion: "^0.20.0", @@ -204,7 +183,7 @@ test("with minNodeVersion", () => { typescriptVersion: "~5.3.0", // NOTE: this should be the same major/minor version as JSII devDeps: ["@cdktf/provider-project@^0.5.0"], isDeprecated: false, - } as any) + }) ); expect(snapshot).toMatchSnapshot(); diff --git a/test/utils.ts b/test/util/synth.ts similarity index 100% rename from test/utils.ts rename to test/util/synth.ts diff --git a/test/util/test-project.ts b/test/util/test-project.ts new file mode 100644 index 00000000..4ba1b4f8 --- /dev/null +++ b/test/util/test-project.ts @@ -0,0 +1,22 @@ +import { CdktfProviderProject, CdktfProviderProjectOptions } from "../../src"; + +export const getProject = ( + opts: Partial = {} +): CdktfProviderProject => + new CdktfProviderProject({ + terraformProvider: "random@~>2.0", + cdktfVersion: "0.10.3", + constructsVersion: "10.0.0", + jsiiVersion: "~5.2.0", + typescriptVersion: "~5.2.0", // NOTE: this should be the same major/minor version as JSII + devDeps: ["@cdktf/provider-project@^0.0.0"], + // NOTE: the below options aren't required to be passed in practice and only need to be here for the test + // This is because JSII prevents us from declaring the options as a Partial + name: "test", + author: "cdktf-team", + authorAddress: "https://github.com/cdktf", + defaultReleaseBranch: "main", + repositoryUrl: "github.com/cdktf/cdktf", + forceMajorVersion: 42, + ...opts, + }); diff --git a/test/workflows.test.ts b/test/workflows.test.ts new file mode 100644 index 00000000..bf478695 --- /dev/null +++ b/test/workflows.test.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: MPL-2.0 + */ + +import { validateWorkflow } from "@action-validator/core"; +import { GithubWorkflow } from "projen/lib/github"; +import { synthSnapshot } from "./util/synth"; +import { getProject } from "./util/test-project"; + +const project = getProject(); + +describe("GitHub Actions validation", () => { + const snapshot = synthSnapshot(getProject()); + + project.github!.workflows.forEach((workflow: GithubWorkflow) => { + test(workflow.file!.path, () => { + const state = validateWorkflow(snapshot[workflow.file!.path]); + + expect(state.errors).toEqual([]); + }); + }); +});