Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
Tenant to Deploy to:
Tenant to Deploy to:

# Description

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

# PR Creation Checklist:

- [ ] PR title includes a descriptive title
- [ ] Added a label: `breaking` or `non-breaking`
- [ ] Added a label: `bug-fix`, `new-plugin`, `internal` or `enhancement`
Expand Down
141 changes: 61 additions & 80 deletions .github/workflows/deploy-plugin-pr.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Deploy Plugin (PR)

on:
pull_request:
types: [opened, edited, synchronize]
workflow_dispatch:
inputs:
prNumber:
Expand All @@ -14,99 +12,70 @@ jobs:
Deploy_Plugin:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Plugin Path and PR Info
run: |
$prNumber = "${{ github.event.inputs.prNumber }}"
$repository = "${{ github.repository }}"

- run: |
$changes = git diff --name-only origin/main... ./plugins
if ( $null -eq $changes ) {
Write-Output "Nothing to Deploy as no changes were found in plugins folder..."
} else {
Write-Output "Changes found in plugins folder: $changes"
}
$pattern = '(?<=\/[v][0-9]\/).*'
$pluginToDeploy = $changes -replace $pattern | Sort-Object -Unique | Select-Object -Last 1
if ( $null -eq $pluginToDeploy ) {
Write-Output "No plugin to deploy"
Write-Output "SKIP_DEPLOYMENT=true" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
exit 0
}
$pluginToDeploy = $pluginToDeploy.TrimStart("plugins/").TrimEnd("/")
Write-Output "Plugin to Deploy: $pluginToDeploy"
Write-Output "PLUGIN_PATH=$pluginToDeploy" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh
name: Get Plugin Path for Deployment
if: github.event_name != 'workflow_dispatch'
timeout-minutes: 5
# Get PR info
$url = "https://api.github.com/repos/$repository/pulls/$prNumber"
$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "token ${{ secrets.GITHUB_TOKEN }}" }

- run: |
Write-Output "Getting PR Number based on trigger event..."
if ("${{ github.event_name }}" -eq "pull_request") {
$prNumber = "${{ github.event.pull_request.number }}"
} elseif ("${{ github.event_name }}" -eq "workflow_dispatch") {
$prNumber = "${{ github.event.inputs.prNumber }}"
} else {
Write-Output "Unsupported event: ${{ github.event_name }}"
exit -1
}
if (-not $prNumber) {
Write-Output "PR Number is null or empty"
exit -1
}
Write-Output "PR Number: $prNumber"
Write-Output "PR_NUMBER=$prNumber" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh
name: Get PR Number
if: ${{ env. SKIP_DEPLOYMENT != 'true' }}
timeout-minutes: 5
# Get changed files in the PR
$filesUrl = $response.url + "/files?per_page=100"
$files = Invoke-RestMethod -Uri $filesUrl -Headers @{Authorization = "token ${{ secrets.GITHUB_TOKEN }}" }

- run: |
Write-Output "Fetching PR Info..."
$prNumber = "${{ env.PR_NUMBER }}"
Write-Output "Total files changed: $($files.Count)"
Write-Output "All changed files: $($files.filename -join ', ')"

$repository = "${{ github.repository_owner }}/${{ github.event.repository.name }}"
$url = "https://api.github.com/repos/$repository/pulls/$prNumber"
$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "token ${{ secrets.GITHUB_TOKEN }}" }
# Find plugin changes
$pluginChanges = $files | Where-Object { $_.filename -like "plugins/*" } | Select-Object -ExpandProperty filename
Write-Output "Plugin files changed: $($pluginChanges -join ', ')"

$repoUrl = $response.head.repo.html_url + ".git"
$branchName = $response.head.ref
Write-Output "Repo URL: $repoUrl | Branch Name: $branchName"
if ($pluginChanges) {
$pattern = '(?<=\/[v][0-9]\/).*'
$pluginToDeploy = $pluginChanges -replace $pattern | Sort-Object -Unique | Select-Object -Last 1
$pluginToDeploy = $pluginToDeploy.TrimStart("plugins/").TrimEnd("/")
Write-Output "Plugin to Deploy: $pluginToDeploy"
Write-Output "PLUGIN_PATH=$pluginToDeploy" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

Write-Output "PR_REPO_URL=$repoUrl" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Output "PR_BRANCH_NAME=$branchName" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# Get PR repo and branch info
$repoUrl = $response.head.repo.html_url + ".git"
$branchName = $response.head.ref
Write-Output "Repo URL: $repoUrl | Branch Name: $branchName"
Write-Output "PR_REPO_URL=$repoUrl" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Output "PR_BRANCH_NAME=$branchName" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

Write-Output "Getting tenant to restrict deployment to..."
$repoBody = gh pr view $prNumber --json body --jq '.body' --repo $repository
Write-Output "Repo Body: $repoBody"
$tenantLine = $repoBody | Select-String -Pattern "^Tenant to Deploy to:.*"
Write-Output "Tenant Line: $tenantLine"
if ($tenantLine) {
$tenant = $tenantLine -replace "Tenant to Deploy to:\s*", "" -replace "\s*$", ""
if (-not [string]::IsNullOrWhiteSpace($tenant)) {
Write-Output "Tenant to Deploy to: $tenant"
# Get tenant info from PR body
$repoBody = gh pr view $prNumber --json body --jq '.body' --repo $repository
Write-Output "Repo Body: $repoBody"
$tenantLine = $repoBody | Select-String -Pattern "^Tenant to Deploy to:.*"
Write-Output "Tenant Line: $tenantLine"
if ($tenantLine) {
$tenant = $tenantLine -replace "Tenant to Deploy to:\s*", "" -replace "\s*$", ""
if (-not [string]::IsNullOrWhiteSpace($tenant)) {
Write-Output "Tenant to Deploy to: $tenant"
Write-Output "TENANT_TO_RESTRICT_TO=$tenant" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
} else {
Write-Error "Error: 'Tenant to Deploy to' is blank."
exit 1
}
} else {
Write-Error "Error: 'Tenant to Deploy to' field not found."
exit 1
}
else {
Write-Error "Error: 'Tenant to Deploy to' is blank."
exit -1
}
}
else {
Write-Error "Error: 'Tenant to Deploy to' field not found."
exit -1
} else {
Write-Output "No plugin changes found - skipping deployment"
Write-Output "SKIP_DEPLOYMENT=true" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
}
Write-Output "TENANT_TO_RESTRICT_TO=$tenant" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh
name: Fetch PR Info
if: ${{ env. SKIP_DEPLOYMENT != 'true' }}
timeout-minutes: 10
env:
GH_TOKEN: ${{ github.token }}

- run: |
Write-Output "Deploying Plugin..."
$pluginSuffix = "${{ env.PR_NUMBER }}"
$pluginSuffix = "${{ github.event.inputs.prNumber }}"
$pluginPath = "${{ env.PLUGIN_PATH }}"
$tenantToRestrictTo = "${{ env.TENANT_TO_RESTRICT_TO }}"
$repoUrl = "${{ env.PR_REPO_URL }}"
Expand Down Expand Up @@ -142,8 +111,20 @@ jobs:
}
shell: pwsh
name: Deploy Plugin
if: ${{ env. SKIP_DEPLOYMENT != 'true' }}
if: ${{ env.SKIP_DEPLOYMENT != 'true' }}
timeout-minutes: 30
env:
DEPLOYER_BASE_URL: ${{ secrets.DEPLOYER_BASE_URL }}
DEPLOYER_API_KEY: ${{ secrets.DEPLOYER_API_KEY }}

- name: Add deployment summary
run: |
echo "## 🚀 Plugin Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "- **Plugin:** ${{ env.PLUGIN_PATH }}" >> $GITHUB_STEP_SUMMARY
echo "- **PR:** #${{ github.event.inputs.prNumber }}" >> $GITHUB_STEP_SUMMARY
echo "- **Tenant:** ${{ env.TENANT_TO_RESTRICT_TO }}" >> $GITHUB_STEP_SUMMARY
echo "- **Branch:** ${{ env.PR_BRANCH_NAME }}" >> $GITHUB_STEP_SUMMARY
echo "- **Repository:** ${{ env.PR_REPO_URL }}" >> $GITHUB_STEP_SUMMARY
echo "- **Requested by:** ${{ github.actor }}" >> $GITHUB_STEP_SUMMARY
if: ${{ env.SKIP_DEPLOYMENT != 'true' }}
shell: bash
4 changes: 2 additions & 2 deletions .github/workflows/enforce-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ jobs:
- name: Enforce second set of labels
uses: yogevbd/[email protected]
with:
REQUIRED_LABELS_ANY: 'bug-fix,internal,enhancement,new-plugin'
REQUIRED_LABELS_ANY_DESCRIPTION: "Select at least one label ['bug-fix','internal','enhancement','new-plugin']"
REQUIRED_LABELS_ANY: 'bug-fix,new-plugin,enhancement,automated-test,internal'
REQUIRED_LABELS_ANY_DESCRIPTION: "Select at least one label ['bug','new-plugin','enhancement', 'automated-test', 'internal']"
20 changes: 11 additions & 9 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,34 @@ jobs:
with:
node-version: '20.x'

- name: Install PNPM
run: npm install -g pnpm@9
timeout-minutes: 5

- name: Install Dependencies
run: npm ci
run: pnpm install --frozen-lockfile
timeout-minutes: 5

- name: Run Unit Tests
run: |
$pattern = '(?<=\/[v][0-9]\/).*'
$changes = git diff --name-only origin/main... ./plugins
$pluginsToTest = $changes -replace $pattern | Sort-Object -Unique
$pluginsToTest = $pluginsToTest | Where-Object { Test-Path -PathType Leaf (Join-Path "." $_ "metadata.json") } # Don't try to test deleted plugins

if ( $null -eq $pluginsToTest ) {
Write-Output "Nothing to Test as no changes were found in plugins folder..."
exit 0
}
elseif ( $pluginsToTest.Count -eq 1 ) {
$pluginName = ($pluginsToTest.TrimEnd('/')) -replace "plugins/" -replace "/", "-"
Write-Output "Only Testing $pluginsToTest"
npm test -- --ci --path="./$pluginsToTest" --pluginName="$pluginName"
Write-Output "Tested $pluginsToTest"
Write-Output "Testing only one Plugin"
pnpm run test --ci --path="./$pluginsToTest"
}
else {
Write-Output "Testing $($pluginsToTest.Count) Plugins..."
foreach ( $plugin in $pluginsToTest ) {
Write-Output "Testing $plugin"
$pluginName = ($plugin.TrimEnd('/')) -replace "plugins/" -replace "/", "-"
npm test -- --ci --path="./$plugin" --pluginName="$pluginName"
pnpm run test --ci --path="./$plugin"
Write-Output "Tested $plugin"
}
}
Expand All @@ -57,5 +59,5 @@ jobs:
with:
name: test-results
path: |
pluginUnitTests/test_output/*.xml
pluginUnitTests/test_output/html/*.html
packages/@squaredup/unit-test/test_output/*.xml
packages/@squaredup/unit-test/test_output/html/*.html
17 changes: 10 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
.idea/**/contentModel.xml
/plugins/package.json
/plugins/package-lock.json
/plugins/pnpm-workspace.yaml
/plugins/pnpm-lock.yaml


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

# Test files
testConfig.json
env-testConfig.json
testDatastreamConfig.json
junit.xml
pluginUnitTests/test_output/
**/test_output/
testDatastreamLocally.js
datastream_test_results/
oauth_test_results/
testResults.datastreamResults.json
**/testPluginLocally.js
**/testResults.json
**/importResults.json
**/datastreamResults.json
pluginsIntegrationTestUtils/reports/html/
pluginsIntegrationTestUtils/reports/junit/
pluginsIntegrationTestUtils/configs/env-Config.json
pluginsIntegrationTestUtils/configs/env-testConfig.json
packages/@squaredup/integration-test-utilities/reports/**
env-Config.json
testTargetNodeConfig.json
testDataSourceConfig.json
plugins/**/allure-*/

# CI files
PluginsToUpload/*
PluginsToPackage/*
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node-linker=hoisted
engine-strict=true
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
**/node_modules
package*.json
pnpm-lock.yaml
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "none",
"endOfLine": "auto"
"endOfLine": "auto",
"plugins": ["prettier-plugin-organize-imports"]
}
5 changes: 4 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"dbaeumer.vscode-eslint",
"orta.vscode-jest",
"esbenp.prettier-vscode",
"streetsidesoftware.code-spell-checker"
]
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": ["amatiasq.sort-imports"]
}
18 changes: 16 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,22 @@
"prettier.ignorePath": ".prettierignore",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"prettier.requireConfig": true,
"eslint.workingDirectories": [{ "directory": "." }],
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
},
"eslint.workingDirectories": [{ "directory": "." }],
"json.schemas": [
{
"fileMatch": [
"**/data_streams.json"
],
"url": "./packages/@squaredup/schema/data_streams.schema.json"
},
{
"fileMatch": [
"**/*.dash.json"
],
"url": "./packages/@squaredup/schema/oob.schema.json"
}
]
}
Loading
Loading