diff --git a/API.md b/API.md
index a6c6977f..7104de34 100644
--- a/API.md
+++ b/API.md
@@ -5026,6 +5026,7 @@ const cDKDiffOptionsConfig: cdkDiffWorkflow.CDKDiffOptionsConfig = { ... }
| envsToDiff
| @time-loop/clickup-projen.cdkDiffWorkflow.EnvToDiff \| @time-loop/clickup-projen.cdkDiffWorkflow.ExplicitStacksEnvToDiff[]
| Collection of environments to cdk diff. |
| createOidcRoleStack
| boolean
| Detrmines if the OIDC role stack should be created. |
| packageManager
| projen.javascript.NodePackageManager
| Which package manager is being used? |
+| pnpmVersion
| string
| What version of pnpm? |
---
@@ -5079,6 +5080,19 @@ Which package manager is being used?
---
+##### `pnpmVersion`Optional
+
+```typescript
+public readonly pnpmVersion: string;
+```
+
+- *Type:* string
+- *Default:* 9 if you are using PNPM
+
+What version of pnpm?
+
+---
+
### ClickUpCdkCommonOptions
#### Initializer
diff --git a/src/cdk-diff-workflow.ts b/src/cdk-diff-workflow.ts
index aa9c3275..db6d0a70 100644
--- a/src/cdk-diff-workflow.ts
+++ b/src/cdk-diff-workflow.ts
@@ -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: {
@@ -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,
@@ -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) {
@@ -310,6 +325,7 @@ export module cdkDiffWorkflow {
...createCdkDiffWorkflow({
nodeVersion: project.workflowNodeVersion,
packageManager: project.package.packageManager,
+ pnpmVersion: project.package.pnpmVersion,
...options,
}),
...override,
diff --git a/test/__snapshots__/cdk-diff-workflow.test.ts.snap b/test/__snapshots__/cdk-diff-workflow.test.ts.snap
index a136b610..38cf5def 100644
--- a/test/__snapshots__/cdk-diff-workflow.test.ts.snap
+++ b/test/__snapshots__/cdk-diff-workflow.test.ts.snap
@@ -777,3 +777,121 @@ jobs:
retention-days: 3
"
`;
+
+exports[`addCdkDiffWorkflowYml - cdk diff.yml file added pnpm 1`] = `
+"# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".
+
+name: cdk-diff
+on:
+ pull_request: {}
+ workflow_dispatch: {}
+permissions:
+ id-token: write
+ contents: write
+ pull-requests: write
+jobs:
+ diff:
+ runs-on: ubuntu-latest
+ env:
+ CI: "true"
+ REPO_NAME: \${{ github.event.repository.name }}
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ with:
+ ref: \${{ github.event.pull_request.head.ref }}
+ repository: \${{ github.event.pull_request.head.repo.full_name }}
+ - name: GitHub Packages authorization
+ run: |-
+ cat > .npmrc < cdk-ls.json
+ STACKS_TO_DIFF_QA=$(jq -r '[.[].id | select(contains("Qa")) ] | join(" ")' cdk-ls.json)
+ echo "STACKS_TO_DIFF_QA=$STACKS_TO_DIFF_QA" >> $GITHUB_ENV
+ - name: configure qa aws credentials
+ uses: aws-actions/configure-aws-credentials@v1
+ with:
+ role-to-assume: arn:aws:iam::123456789012:role/squad-github-actions-oidc-role-name-qa
+ role-duration-seconds: 900
+ aws-region: us-west-2
+ - name: diff qa
+ run: |
+ set -o pipefail
+ ./node_modules/.bin/cdk diff $STACKS_TO_DIFF_QA --progress=events --staging false -e --ignore-errors --version-reporting false &> >(tee cdk-qa.log)
+ ./node_modules/.bin/ts-node ./node_modules/@time-loop/cdk-log-parser/lib/cdkLogParser.js cdk-qa.log && echo 'QA_HAS_NO_DIFF=true' >> $GITHUB_ENV || echo 'Diffs present!'
+ - name: cdk-notify
+ run: |-
+ curl -L "https://github.com/karlderkaefer/cdk-notifier/releases/download/v2.3.2/cdk-notifier_$(uname)_amd64.gz" -o cdk-notifier.gz
+ gunzip cdk-notifier.gz && chmod +x cdk-notifier && rm -rf cdk-notifier.gz
+ ./cdk-notifier --log-file ./cdk-qa.log --repo $REPO_NAME --owner $GITHUB_REPOSITORY_OWNER --token \${{ secrets.GITHUB_TOKEN }} --pull-request-id \${{ github.event.pull_request.number }} -t 'qa Stacks - If truncated please see the action for the full log!'
+ - name: Remove 'qa-no-changes' label based on diff status given a previous commit may have had no diff but the current one does
+ if: env.QA_HAS_NO_DIFF != 'true'
+ uses: actions/github-script@v6
+ with:
+ github-token: \${{ secrets.GITHUB_TOKEN }}
+ script: |-
+ const labels = await github.paginate(
+ github.rest.issues.listLabelsOnIssue, {
+ issue_number: context.issue.number,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ }
+ )
+ if (labels.find(label => label.name === "qa-no-changes")) {
+ github.rest.issues.removeLabel({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: context.issue.number,
+ name: "qa-no-changes"
+ })
+ }
+ - name: Apply 'qa-no-changes' label based on diff status
+ if: env.QA_HAS_NO_DIFF == 'true'
+ uses: actions/github-script@v6
+ with:
+ github-token: \${{ secrets.GITHUB_TOKEN }}
+ script: |-
+ github.rest.issues.addLabels({
+ issue_number: context.issue.number,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ labels: ["qa-no-changes"]
+ })
+ - name: Should auto merge
+ id: should-auto-merge
+ if: env.QA_HAS_NO_DIFF == 'true' && github.event.pull_request.user.login == 'cu-infra-svc-git'
+ run: echo "auto-merge=true" >> $GITHUB_OUTPUT
+ - name: Enable automerge
+ uses: daneden/enable-automerge-action@v1.0.2
+ if: steps.should-auto-merge.outputs.auto-merge
+ with:
+ github-token: \${{ secrets.PROJEN_GITHUB_TOKEN }}
+ merge-method: SQUASH
+ allowed-author: cu-infra-svc-git
+ - name: Auto approve
+ uses: hmarr/auto-approve-action@v2.2.1
+ if: steps.should-auto-merge.outputs.auto-merge
+ with:
+ github-token: \${{ secrets.GITHUB_TOKEN }}
+ - name: Save processed diff logs
+ uses: actions/upload-artifact@v3.1.2
+ with:
+ name: ProcessedDiffLogs
+ path: "*.log"
+ retention-days: 3
+"
+`;
diff --git a/test/cdk-diff-workflow.test.ts b/test/cdk-diff-workflow.test.ts
index 21bfc7ba..3948dd23 100644
--- a/test/cdk-diff-workflow.test.ts
+++ b/test/cdk-diff-workflow.test.ts
@@ -1,4 +1,4 @@
-import { Testing } from 'projen';
+import { Testing, javascript } from 'projen';
// import * as Yaml from 'yaml';
import { requiredParams } from './requiredParams';
@@ -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, {