Skip to content

Commit

Permalink
fix(cdk-diff): install pnpm [CLK-252116] (#267)
Browse files Browse the repository at this point in the history
* fix(cdk-diff): install pnpm [CLK-252116]

* chore: self mutation

Signed-off-by: github-actions <[email protected]>

---------

Signed-off-by: github-actions <[email protected]>
Co-authored-by: github-actions <[email protected]>
  • Loading branch information
ahammond and github-actions authored May 11, 2024
1 parent bd54d45 commit 3b92bff
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 1 deletion.
14 changes: 14 additions & 0 deletions API.md

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

16 changes: 16 additions & 0 deletions src/cdk-diff-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ export module cdkDiffWorkflow {
? 'pnpm i --frozen-lockfile'
: 'yarn install --check-files';

const installPnpm = {
name: 'Setup pnpm',
uses: 'pnpm/action-setup@v3',
with: {
version: options.pnpmVersion ?? '9',
},
};

const defaultWorkflow = {
name: 'cdk-diff',
on: {
Expand Down Expand Up @@ -54,6 +62,7 @@ export module cdkDiffWorkflow {
'node-version': options.nodeVersion ?? parameters.PROJEN_NODE_VERSION,
},
},
...(options.packageManager === javascript.NodePackageManager.PNPM ? [installPnpm] : []),
{
name: 'Install dependencies',
run: installDeps,
Expand Down Expand Up @@ -294,6 +303,12 @@ export module cdkDiffWorkflow {
* @default - the packageManager in the project
*/
readonly packageManager?: javascript.NodePackageManager;

/**
* What version of pnpm?
* @default - 9 if you are using PNPM
*/
readonly pnpmVersion?: string;
}

export function getCDKDiffOptions(options?: CDKDiffOptionsConfig) {
Expand All @@ -310,6 +325,7 @@ export module cdkDiffWorkflow {
...createCdkDiffWorkflow({
nodeVersion: project.workflowNodeVersion,
packageManager: project.package.packageManager,
pnpmVersion: project.package.pnpmVersion,
...options,
}),
...override,
Expand Down
118 changes: 118 additions & 0 deletions test/__snapshots__/cdk-diff-workflow.test.ts.snap

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

22 changes: 21 additions & 1 deletion test/cdk-diff-workflow.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Testing } from 'projen';
import { Testing, javascript } from 'projen';
// import * as Yaml from 'yaml';

import { requiredParams } from './requiredParams';
Expand Down Expand Up @@ -58,6 +58,26 @@ describe('addCdkDiffWorkflowYml - cdk diff.yml file added', () => {
expect(synth['.github/workflows/cdk-diff.yml']).toMatchSnapshot();
});

test('pnpm', () => {
const project = new clickupCdk.ClickUpCdkTypeScriptApp({
...requiredParams,
packageManager: javascript.NodePackageManager.PNPM,
pnpmVersion: '9',
});
cdkDiffWorkflow.addCdkDiffWorkflowYml(project, {
envsToDiff: [
{
name: 'qa',
oidcRoleArn: 'arn:aws:iam::123456789012:role/squad-github-actions-oidc-role-name-qa',
labelToApplyWhenNoDiffPresent: 'qa-no-changes',
stackSearchString: 'Qa',
},
],
});
const synth = Testing.synth(project);
expect(synth['.github/workflows/cdk-diff.yml']).toMatchSnapshot();
});

test('a single env to diff - single explicit stack given to diff', () => {
const project = new clickupCdk.ClickUpCdkTypeScriptApp(requiredParams);
cdkDiffWorkflow.addCdkDiffWorkflowYml(project, {
Expand Down

0 comments on commit 3b92bff

Please sign in to comment.