Skip to content

Commit b5c3f31

Browse files
authored
Merge pull request #12 from squaredup/work/ss/repo-update-pnpm
Update Test Packages and Add `pnpm` support
2 parents 171b5f0 + 8e5c370 commit b5c3f31

File tree

82 files changed

+13283
-12784
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+13283
-12784
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
Tenant to Deploy to:
1+
Tenant to Deploy to:
22

33
# Description
44

55
Please include a description of the new feature/changes/bug fix
66
Please include screenshots if relevant.
77

88
# PR Creation Checklist:
9+
910
- [ ] PR title includes a descriptive title
1011
- [ ] Added a label: `breaking` or `non-breaking`
1112
- [ ] Added a label: `bug-fix`, `new-plugin`, `internal` or `enhancement`
Lines changed: 61 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Deploy Plugin (PR)
22

33
on:
4-
pull_request:
5-
types: [opened, edited, synchronize]
64
workflow_dispatch:
75
inputs:
86
prNumber:
@@ -14,99 +12,70 @@ jobs:
1412
Deploy_Plugin:
1513
runs-on: ubuntu-latest
1614
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v4
19-
with:
20-
fetch-depth: 0
15+
- name: Get Plugin Path and PR Info
16+
run: |
17+
$prNumber = "${{ github.event.inputs.prNumber }}"
18+
$repository = "${{ github.repository }}"
2119
22-
- run: |
23-
$changes = git diff --name-only origin/main... ./plugins
24-
if ( $null -eq $changes ) {
25-
Write-Output "Nothing to Deploy as no changes were found in plugins folder..."
26-
} else {
27-
Write-Output "Changes found in plugins folder: $changes"
28-
}
29-
$pattern = '(?<=\/[v][0-9]\/).*'
30-
$pluginToDeploy = $changes -replace $pattern | Sort-Object -Unique | Select-Object -Last 1
31-
if ( $null -eq $pluginToDeploy ) {
32-
Write-Output "No plugin to deploy"
33-
Write-Output "SKIP_DEPLOYMENT=true" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
34-
exit 0
35-
}
36-
$pluginToDeploy = $pluginToDeploy.TrimStart("plugins/").TrimEnd("/")
37-
Write-Output "Plugin to Deploy: $pluginToDeploy"
38-
Write-Output "PLUGIN_PATH=$pluginToDeploy" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
39-
shell: pwsh
40-
name: Get Plugin Path for Deployment
41-
if: github.event_name != 'workflow_dispatch'
42-
timeout-minutes: 5
20+
# Get PR info
21+
$url = "https://api.github.com/repos/$repository/pulls/$prNumber"
22+
$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "token ${{ secrets.GITHUB_TOKEN }}" }
4323
44-
- run: |
45-
Write-Output "Getting PR Number based on trigger event..."
46-
if ("${{ github.event_name }}" -eq "pull_request") {
47-
$prNumber = "${{ github.event.pull_request.number }}"
48-
} elseif ("${{ github.event_name }}" -eq "workflow_dispatch") {
49-
$prNumber = "${{ github.event.inputs.prNumber }}"
50-
} else {
51-
Write-Output "Unsupported event: ${{ github.event_name }}"
52-
exit -1
53-
}
54-
if (-not $prNumber) {
55-
Write-Output "PR Number is null or empty"
56-
exit -1
57-
}
58-
Write-Output "PR Number: $prNumber"
59-
Write-Output "PR_NUMBER=$prNumber" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
60-
shell: pwsh
61-
name: Get PR Number
62-
if: ${{ env. SKIP_DEPLOYMENT != 'true' }}
63-
timeout-minutes: 5
24+
# Get changed files in the PR
25+
$filesUrl = $response.url + "/files?per_page=100"
26+
$files = Invoke-RestMethod -Uri $filesUrl -Headers @{Authorization = "token ${{ secrets.GITHUB_TOKEN }}" }
6427
65-
- run: |
66-
Write-Output "Fetching PR Info..."
67-
$prNumber = "${{ env.PR_NUMBER }}"
28+
Write-Output "Total files changed: $($files.Count)"
29+
Write-Output "All changed files: $($files.filename -join ', ')"
6830
69-
$repository = "${{ github.repository_owner }}/${{ github.event.repository.name }}"
70-
$url = "https://api.github.com/repos/$repository/pulls/$prNumber"
71-
$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "token ${{ secrets.GITHUB_TOKEN }}" }
31+
# Find plugin changes
32+
$pluginChanges = $files | Where-Object { $_.filename -like "plugins/*" } | Select-Object -ExpandProperty filename
33+
Write-Output "Plugin files changed: $($pluginChanges -join ', ')"
7234
73-
$repoUrl = $response.head.repo.html_url + ".git"
74-
$branchName = $response.head.ref
75-
Write-Output "Repo URL: $repoUrl | Branch Name: $branchName"
35+
if ($pluginChanges) {
36+
$pattern = '(?<=\/[v][0-9]\/).*'
37+
$pluginToDeploy = $pluginChanges -replace $pattern | Sort-Object -Unique | Select-Object -Last 1
38+
$pluginToDeploy = $pluginToDeploy.TrimStart("plugins/").TrimEnd("/")
39+
Write-Output "Plugin to Deploy: $pluginToDeploy"
40+
Write-Output "PLUGIN_PATH=$pluginToDeploy" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
7641
77-
Write-Output "PR_REPO_URL=$repoUrl" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
78-
Write-Output "PR_BRANCH_NAME=$branchName" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
42+
# Get PR repo and branch info
43+
$repoUrl = $response.head.repo.html_url + ".git"
44+
$branchName = $response.head.ref
45+
Write-Output "Repo URL: $repoUrl | Branch Name: $branchName"
46+
Write-Output "PR_REPO_URL=$repoUrl" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
47+
Write-Output "PR_BRANCH_NAME=$branchName" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
7948
80-
Write-Output "Getting tenant to restrict deployment to..."
81-
$repoBody = gh pr view $prNumber --json body --jq '.body' --repo $repository
82-
Write-Output "Repo Body: $repoBody"
83-
$tenantLine = $repoBody | Select-String -Pattern "^Tenant to Deploy to:.*"
84-
Write-Output "Tenant Line: $tenantLine"
85-
if ($tenantLine) {
86-
$tenant = $tenantLine -replace "Tenant to Deploy to:\s*", "" -replace "\s*$", ""
87-
if (-not [string]::IsNullOrWhiteSpace($tenant)) {
88-
Write-Output "Tenant to Deploy to: $tenant"
49+
# Get tenant info from PR body
50+
$repoBody = gh pr view $prNumber --json body --jq '.body' --repo $repository
51+
Write-Output "Repo Body: $repoBody"
52+
$tenantLine = $repoBody | Select-String -Pattern "^Tenant to Deploy to:.*"
53+
Write-Output "Tenant Line: $tenantLine"
54+
if ($tenantLine) {
55+
$tenant = $tenantLine -replace "Tenant to Deploy to:\s*", "" -replace "\s*$", ""
56+
if (-not [string]::IsNullOrWhiteSpace($tenant)) {
57+
Write-Output "Tenant to Deploy to: $tenant"
58+
Write-Output "TENANT_TO_RESTRICT_TO=$tenant" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
59+
} else {
60+
Write-Error "Error: 'Tenant to Deploy to' is blank."
61+
exit 1
62+
}
63+
} else {
64+
Write-Error "Error: 'Tenant to Deploy to' field not found."
65+
exit 1
8966
}
90-
else {
91-
Write-Error "Error: 'Tenant to Deploy to' is blank."
92-
exit -1
93-
}
94-
}
95-
else {
96-
Write-Error "Error: 'Tenant to Deploy to' field not found."
97-
exit -1
67+
} else {
68+
Write-Output "No plugin changes found - skipping deployment"
69+
Write-Output "SKIP_DEPLOYMENT=true" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
9870
}
99-
Write-Output "TENANT_TO_RESTRICT_TO=$tenant" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
10071
shell: pwsh
101-
name: Fetch PR Info
102-
if: ${{ env. SKIP_DEPLOYMENT != 'true' }}
10372
timeout-minutes: 10
10473
env:
10574
GH_TOKEN: ${{ github.token }}
10675

10776
- run: |
10877
Write-Output "Deploying Plugin..."
109-
$pluginSuffix = "${{ env.PR_NUMBER }}"
78+
$pluginSuffix = "${{ github.event.inputs.prNumber }}"
11079
$pluginPath = "${{ env.PLUGIN_PATH }}"
11180
$tenantToRestrictTo = "${{ env.TENANT_TO_RESTRICT_TO }}"
11281
$repoUrl = "${{ env.PR_REPO_URL }}"
@@ -142,8 +111,20 @@ jobs:
142111
}
143112
shell: pwsh
144113
name: Deploy Plugin
145-
if: ${{ env. SKIP_DEPLOYMENT != 'true' }}
114+
if: ${{ env.SKIP_DEPLOYMENT != 'true' }}
146115
timeout-minutes: 30
147116
env:
148117
DEPLOYER_BASE_URL: ${{ secrets.DEPLOYER_BASE_URL }}
149118
DEPLOYER_API_KEY: ${{ secrets.DEPLOYER_API_KEY }}
119+
120+
- name: Add deployment summary
121+
run: |
122+
echo "## 🚀 Plugin Deployment Summary" >> $GITHUB_STEP_SUMMARY
123+
echo "- **Plugin:** ${{ env.PLUGIN_PATH }}" >> $GITHUB_STEP_SUMMARY
124+
echo "- **PR:** #${{ github.event.inputs.prNumber }}" >> $GITHUB_STEP_SUMMARY
125+
echo "- **Tenant:** ${{ env.TENANT_TO_RESTRICT_TO }}" >> $GITHUB_STEP_SUMMARY
126+
echo "- **Branch:** ${{ env.PR_BRANCH_NAME }}" >> $GITHUB_STEP_SUMMARY
127+
echo "- **Repository:** ${{ env.PR_REPO_URL }}" >> $GITHUB_STEP_SUMMARY
128+
echo "- **Requested by:** ${{ github.actor }}" >> $GITHUB_STEP_SUMMARY
129+
if: ${{ env.SKIP_DEPLOYMENT != 'true' }}
130+
shell: bash

.github/workflows/enforce-labels.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ jobs:
1717
- name: Enforce second set of labels
1818
uses: yogevbd/enforce-label-action@2.2.2
1919
with:
20-
REQUIRED_LABELS_ANY: 'bug-fix,internal,enhancement,new-plugin'
21-
REQUIRED_LABELS_ANY_DESCRIPTION: "Select at least one label ['bug-fix','internal','enhancement','new-plugin']"
20+
REQUIRED_LABELS_ANY: 'bug-fix,new-plugin,enhancement,automated-test,internal'
21+
REQUIRED_LABELS_ANY_DESCRIPTION: "Select at least one label ['bug','new-plugin','enhancement', 'automated-test', 'internal']"

.github/workflows/unit-test.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,34 @@ jobs:
1919
with:
2020
node-version: '20.x'
2121

22+
- name: Install PNPM
23+
run: npm install -g pnpm@9
24+
timeout-minutes: 5
25+
2226
- name: Install Dependencies
23-
run: npm ci
27+
run: pnpm install --frozen-lockfile
2428
timeout-minutes: 5
2529

2630
- name: Run Unit Tests
2731
run: |
2832
$pattern = '(?<=\/[v][0-9]\/).*'
2933
$changes = git diff --name-only origin/main... ./plugins
3034
$pluginsToTest = $changes -replace $pattern | Sort-Object -Unique
35+
$pluginsToTest = $pluginsToTest | Where-Object { Test-Path -PathType Leaf (Join-Path "." $_ "metadata.json") } # Don't try to test deleted plugins
3136
3237
if ( $null -eq $pluginsToTest ) {
3338
Write-Output "Nothing to Test as no changes were found in plugins folder..."
3439
exit 0
3540
}
3641
elseif ( $pluginsToTest.Count -eq 1 ) {
37-
$pluginName = ($pluginsToTest.TrimEnd('/')) -replace "plugins/" -replace "/", "-"
38-
Write-Output "Only Testing $pluginsToTest"
39-
npm test -- --ci --path="./$pluginsToTest" --pluginName="$pluginName"
40-
Write-Output "Tested $pluginsToTest"
42+
Write-Output "Testing only one Plugin"
43+
pnpm run test --ci --path="./$pluginsToTest"
4144
}
4245
else {
4346
Write-Output "Testing $($pluginsToTest.Count) Plugins..."
4447
foreach ( $plugin in $pluginsToTest ) {
4548
Write-Output "Testing $plugin"
46-
$pluginName = ($plugin.TrimEnd('/')) -replace "plugins/" -replace "/", "-"
47-
npm test -- --ci --path="./$plugin" --pluginName="$pluginName"
49+
pnpm run test --ci --path="./$plugin"
4850
Write-Output "Tested $plugin"
4951
}
5052
}
@@ -57,5 +59,5 @@ jobs:
5759
with:
5860
name: test-results
5961
path: |
60-
pluginUnitTests/test_output/*.xml
61-
pluginUnitTests/test_output/html/*.html
62+
packages/@squaredup/unit-test/test_output/*.xml
63+
packages/@squaredup/unit-test/test_output/html/*.html

.gitignore

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
.idea/**/contentModel.xml
1818
/plugins/package.json
1919
/plugins/package-lock.json
20+
/plugins/pnpm-workspace.yaml
21+
/plugins/pnpm-lock.yaml
22+
2023

2124
# Sensitive or high-churn files
2225
.idea/**/dataSources/
@@ -501,8 +504,6 @@ PublishScripts/
501504
*.nupkg
502505
# NuGet Symbol Packages
503506
*.snupkg
504-
# The packages folder can be ignored because of Package Restore
505-
**/[Pp]ackages/*
506507
# except build/, which is used as an MSBuild target.
507508
!**/[Pp]ackages/build/
508509
# Uncomment if necessary however generally it will be regenerated when needed
@@ -679,26 +680,28 @@ serverless.yml
679680
wrappedHandler.js
680681
handlerCloud.js
681682
handlerOnPrem.js
683+
graphDump.json
682684

683685
# Test files
684686
testConfig.json
685687
env-testConfig.json
686688
testDatastreamConfig.json
687689
junit.xml
688-
pluginUnitTests/test_output/
690+
**/test_output/
689691
testDatastreamLocally.js
690692
datastream_test_results/
693+
oauth_test_results/
691694
testResults.datastreamResults.json
692695
**/testPluginLocally.js
693696
**/testResults.json
694697
**/importResults.json
695698
**/datastreamResults.json
696-
pluginsIntegrationTestUtils/reports/html/
697-
pluginsIntegrationTestUtils/reports/junit/
698-
pluginsIntegrationTestUtils/configs/env-Config.json
699-
pluginsIntegrationTestUtils/configs/env-testConfig.json
699+
packages/@squaredup/integration-test-utilities/reports/**
700+
env-Config.json
700701
testTargetNodeConfig.json
701702
testDataSourceConfig.json
703+
plugins/**/allure-*/
702704

703705
# CI files
704706
PluginsToUpload/*
707+
PluginsToPackage/*

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node-linker=hoisted
2+
engine-strict=true

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
**/node_modules
22
package*.json
3+
pnpm-lock.yaml

.prettierrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"singleQuote": true,
55
"tabWidth": 4,
66
"trailingComma": "none",
7-
"endOfLine": "auto"
7+
"endOfLine": "auto",
8+
"plugins": ["prettier-plugin-organize-imports"]
89
}

.vscode/extensions.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
// List of extensions which should be recommended for users of this workspace.
66
"recommendations": [
77
"dbaeumer.vscode-eslint",
8+
"orta.vscode-jest",
89
"esbenp.prettier-vscode",
910
"streetsidesoftware.code-spell-checker"
10-
]
11+
],
12+
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
13+
"unwantedRecommendations": ["amatiasq.sort-imports"]
1114
}

.vscode/settings.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,22 @@
33
"prettier.ignorePath": ".prettierignore",
44
"editor.defaultFormatter": "esbenp.prettier-vscode",
55
"prettier.requireConfig": true,
6-
"eslint.workingDirectories": [{ "directory": "." }],
76
"[javascript]": {
87
"editor.defaultFormatter": "esbenp.prettier-vscode"
9-
}
8+
},
9+
"eslint.workingDirectories": [{ "directory": "." }],
10+
"json.schemas": [
11+
{
12+
"fileMatch": [
13+
"**/data_streams.json"
14+
],
15+
"url": "./packages/@squaredup/schema/data_streams.schema.json"
16+
},
17+
{
18+
"fileMatch": [
19+
"**/*.dash.json"
20+
],
21+
"url": "./packages/@squaredup/schema/oob.schema.json"
22+
}
23+
]
1024
}

0 commit comments

Comments
 (0)