Skip to content

[WIP] feat(devops): redirecting tests from core to growth #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
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
15 changes: 15 additions & 0 deletions .github/scripts/interface-exists.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if [ -z "$1" ]; then
echo "Error: interface name is not provided" >&2
exit 1
fi
interface=$1

interface_path="interfaces/$interface"
interface_def=$(pnpm bp read --work-dir $interface_path --json)

name=$(echo $interface_def | jq -r ".name")
version=$(echo $interface_def | jq -r ".version")

command="pnpm bp interfaces get \"$name@$version\" --json >/dev/null 2>&1"
exists=$(eval $command && echo 1 || echo 0)
echo $exists
11 changes: 11 additions & 0 deletions .github/scripts/ls-sentry-integrations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sentry_integrations=( $(ls integrations/*/.sentryclirc) )

filter=""

for sentry_integration in "${sentry_integrations[@]}";
do
actual_integration=$(echo $sentry_integration | sed 's/\.sentryclirc//g')
filter="-F ./$actual_integration $filter"
done

echo $filter
15 changes: 15 additions & 0 deletions .github/scripts/plugin-exists.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if [ -z "$1" ]; then
echo "Error: plugin name is not provided" >&2
exit 1
fi
plugin=$1

plugin_path="plugins/$plugin"
plugin_def=$(pnpm bp read --work-dir $plugin_path --json)

name=$(echo $plugin_def | jq -r ".name")
version=$(echo $plugin_def | jq -r ".version")

command="pnpm bp plugins get \"$name@$version\" --json >/dev/null 2>&1"
exists=$(eval $command && echo 1 || echo 0)
echo $exists
19 changes: 19 additions & 0 deletions .github/workflows/check-all-workflows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Check All
on:
pull_request:
branches:
- master

jobs:
check-all:
runs-on: ubuntu-latest
permissions:
checks: read
statuses: read
steps:
- name: Check All
uses: upsidr/merge-gatekeeper@v1
with:
timeout: 900 # 15 minutes
token: ${{ secrets.GITHUB_TOKEN }}
self: check-all
110 changes: 110 additions & 0 deletions .github/workflows/check-integration-naming.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Check Integration Plus Prefix

on: pull_request

jobs:
check-integration-plus-prefix:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v2

- name: Create integration validation script
run: |
cat > ./validate-integration-plus-prefix.js << 'EOF'
const fs = require('fs');
const path = require('path');

function validateIntegration(integrationPath) {
const errors = [];

// CHECKING IF PACKAGE.JSON EXISTS

const packageJsonPath = path.join(integrationPath, 'package.json');
let packageJson = null;
if (fs.existsSync(packageJsonPath)) {
try {
packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));

// CHECKING IF INTEGRATION NAME EXISTS AND STARTS WITH PLUS/

if (!packageJson.integrationName) {
errors.push(`Missing 'integrationName' in package.json`);
} else if (!packageJson.integrationName.startsWith('plus/')) {
errors.push(`'integrationName' in package.json must start with 'plus/' prefix, found: ${packageJson.integrationName}`);
}
} catch (err) {
errors.push(`Error parsing package.json: ${err.message}`);
}
} else {
errors.push('package.json file not found');
}

// CHECKING IF INTEGRATION.DEFINITION.TS EXISTS

const definitionPath = path.join(integrationPath, 'integration.definition.ts');
if (fs.existsSync(definitionPath)) {
try {
const definition = fs.readFileSync(definitionPath, 'utf8');

// CHECKING IF NAME PROPERTY WITH PLUS/ PREFIX EXISTS

const nameMatch = definition.match(/name:\s*['"]([^'"]+)['"]/);
const nameVarMatch = definition.match(/name:\s*integrationName/);

if (!nameMatch && !nameVarMatch) {
errors.push('Could not find "name" property in integration.definition.ts');
} else if (nameMatch && !nameMatch[1].startsWith('plus/')) {
errors.push(`"name" in integration.definition.ts must start with 'plus/' prefix, found: ${nameMatch[1]}`);
} else if (nameVarMatch && packageJson) {
if (!packageJson.integrationName) {
errors.push('Using integrationName in definition but missing in package.json');
} else if (!packageJson.integrationName.startsWith('plus/')) {
errors.push(`'integrationName' in package.json must start with 'plus/' prefix, found: ${packageJson.integrationName}`);
}
}

// CHECKING IF TITLE PROPERTY EXISTS

const titleMatch = definition.match(/title:\s*['"]([^'"]+)['"]/);
if (!titleMatch) {
errors.push('Could not find "title" property in integration.definition.ts');
}
} catch (err) {
errors.push(`Error reading integration.definition.ts: ${err.message}`);
}
} else {
errors.push('integration.definition.ts file not found');
}

return errors;
}

const integrationsDir = './integrations';
const integrationDirs = fs.readdirSync(integrationsDir)
.filter(file => fs.statSync(path.join(integrationsDir, file)).isDirectory());

let validationFailed = false;

integrationDirs.forEach(integration => {
const integrationPath = path.join(integrationsDir, integration);
const errors = validateIntegration(integrationPath);

if (errors.length > 0) {
console.error(`❌ Validation failed for ${integration}:`);
errors.forEach(error => console.error(` - ${error}`));
validationFailed = true;
} else {
console.log(`✅ Integration ${integration} passed validation`);
}
});

if (validationFailed) {
process.exit(1);
}
EOF

chmod +x ./validate-integration-plus-prefix.js

- name: Check all integrations
run: node ./validate-integration-plus-prefix.js
37 changes: 37 additions & 0 deletions .github/workflows/deploy-bots.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Deploy Bots

on: workflow_dispatch

permissions:
id-token: write
contents: read

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup
uses: ./.github/actions/setup
- name: Deploy Bots
env:
PRODUCTION_CLOUD_OPS_WORKSPACE_ID: ${{ secrets.BP_WORKSPACEID_PROD }}
PRODUCTION_TOKEN_CLOUD_OPS_ACCOUNT: ${{ secrets.ERMEK_PROD_PAT }}
run: |
api_url="https://api.botpress.cloud"

# login
echo "### Logging in to $api_url ###"
pnpm bp login -y --api-url $api_url --workspaceId "${{ secrets.BP_WORKSPACEID_PROD }}" --token "${{ secrets.ERMEK_PROD_PAT }}"

# deploy
# Find all bot directories (adjust the filter as needed based on your project structure)
bots="pnpm list --json"
bot_paths=$(eval $bots | jq -r "map(.path) | .[]")

for bot_path in $bot_paths; do
bot_name=$(basename $bot_path)
echo -e "\nDeploying bot: ### $bot_name ###\n"
bot_id=$(pnpm bp bots new --name $bot_name --json --if-not-exists | jq -r ".id")
pnpm retry -n 2 -- pnpm -F $bot_name -c exec -- "pnpm bp deploy -v -y --botId $bot_id"
done
43 changes: 43 additions & 0 deletions .github/workflows/deploy-integrations-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Deploy Integrations Production

on:
workflow_dispatch:
inputs:
force:
description: 'Force re-deploying integrations'
type: boolean
required: false
default: false

permissions:
id-token: write
contents: read

jobs:
deploy-production:
runs-on: depot-ubuntu-22.04-8
steps:
- uses: actions/checkout@v2
- name: Setup
uses: ./.github/actions/setup
- name: Deploy Interfaces
uses: ./.github/actions/deploy-interfaces
with:
environment: 'production'
force: ${{ github.event.inputs.force == 'true' }}
token_cloud_ops_account: ${{ secrets.ERMEK_PROD_PAT }}
cloud_ops_workspace_id: ${{ secrets.BP_WORKSPACEID_PROD }}
- name: Deploy Integrations
uses: ./.github/actions/deploy-integrations
with:
environment: 'production'
force: ${{ github.event.inputs.force == 'true' }}
token_cloud_ops_account: ${{ secrets.ERMEK_PROD_PAT }}
cloud_ops_workspace_id: ${{ secrets.BP_WORKSPACEID_PROD }}
- name: Deploy Plugins
uses: ./.github/actions/deploy-plugins
with:
environment: 'production'
force: ${{ github.event.inputs.force == 'true' }}
token_cloud_ops_account: ${{ secrets.ERMEK_PROD_PAT }}
cloud_ops_workspace_id: ${{ secrets.BP_WORKSPACEID_PROD }}
4 changes: 2 additions & 2 deletions integrations/gohighlevel/integration.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ import {
} from './src/misc/custom-schemas';

export default new IntegrationDefinition({
name: integrationName ?? 'go-high-level',
version: '1.0.0',
name: integrationName ?? 'plus/go-high-level',
version: '1.0.1',
title: 'GoHighLevel',
readme: 'hub.md',
icon: 'icon.svg',
Expand Down
Loading
Loading