Skip to content
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

chore: automated tests for bundled core in apex-node and templates #1070

Merged
merged 14 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
41 changes: 41 additions & 0 deletions .github/workflows/bundle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Bundle
on:
workflow_call:
inputs:
branch:
description: 'Set the branch to bundle core'
required: false
type: string
nodeVersion:
description: version of node to use. It's better to specify latest, lts/* or lts/-1 than to hardode numbers
type: string
default: lts/*
required: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.nodeVersion }}
registry-url: 'https://registry.npmjs.org'
cache: yarn
- uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main
- name: Install esbuild Dependencies
run: |
yarn add -D esbuild@^0.19.5 esbuild-plugin-pino@^2.1.0 npm-dts@^1.3.12 esbuild-plugin-tsc@^0.4.0
- uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main
- name: Update for Bundling
run: |
node scripts/updateForBundling.js
- name: Generate Bundle
run: |
yarn build
node scripts/build.js
- name: Post Bundling Update
run: |
node scripts/postBundlingUpdate.js
37 changes: 15 additions & 22 deletions .github/workflows/esbuild-publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: esbuild Compilation & npm Publish Workflow

on:
workflow_run:
workflows:
- create-github-release
types:
- completed
workflow_dispatch:
inputs:
branch:
Expand All @@ -15,32 +20,20 @@ on:
required: false

jobs:
build:
bundle:
if: ${{ inputs.branch || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')}}
uses: ./.github/workflows/bundle.yml
secrets: inherit
with:
branch: ${{ inputs.branch || 'main' }}
nodeVersion: ${{ inputs.nodeVersion || 'lts/*'}}
publish:
CristiCanizales marked this conversation as resolved.
Show resolved Hide resolved
needs: bundle
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
CristiCanizales marked this conversation as resolved.
Show resolved Hide resolved
with:
ref: ${{ inputs.branch }}
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.nodeVersion }}
registry-url: 'https://registry.npmjs.org'
cache: yarn
- uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main
- name: Install esbuild Dependencies
run: |
yarn add -D esbuild@^0.19.5 esbuild-plugin-pino@^2.1.0 npm-dts@^1.3.12 esbuild-plugin-tsc@^0.4.0
- uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main
- name: Update for Bundling
run: |
node scripts/updateForBundling.js
- name: Generate Bundle
run: |
yarn build
node scripts/build.js
- name: Post Bundling Update
run: |
node scripts/postBundlingUpdate.js
ref: ${{ inputs.branch || 'main' }}
- name: Publish a Package
run: |
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/testCoreBundling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Test Core Bundling
on:
push:
branches-ignore: [main]
workflow_dispatch:
inputs:
branch:
description: 'Set the branch to bundle core'
type: string
required: false
default: main
nodeVersion:
description: version of node to use. It's better to specify latest, lts/* or lts/-1 than to hardode numbers
type: string
required: false
default: lts/*

jobs:
bundle:
uses: ./.github/workflows/bundle.yml
with:
branch: ${{ github.ref_name || inputs.branch }}
nodeVersion: ${{ inputs.nodeVersion }}
tests:
needs: bundle
uses: ./.github/workflows/testExternalProjects.yml
secrets: inherit
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest']
externalProjectGit:
- forcedotcom/salesforcedx-templates
- forcedotcom/salesforcedx-apex
with:
externalProjectGit: ${{ matrix.externalProjectGit }}
os: ${{ matrix.os }}
bundledBranch: ${{ github.ref_name || inputs.branch }}
88 changes: 88 additions & 0 deletions .github/workflows/testExternalProjects.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Test External Projects
on:
workflow_call:
inputs:
externalProjectGit:
description: 'The url that will be cloned. This contains the tests you want to run. Ex: https://github.com/forcedotcom/templates'
type: string
required: true
nodeVersion:
required: false
description: version of node to run tests against. Use things like [lts/-1, lts/*, latest] to avoid hardcoding versions
type: string
default: lts/*
os:
required: false
description: 'runs-on property, ex: ubuntu-latest, windows-latest'
type: string
default: 'ubuntu-latest'
attempts:
required: false
type: number
default: 3
bundledBranch:
required: false
description: Branch with the bundled version of core"
type: string
default: 'main'

jobs:
external-test:
name: run tests
if: ${{ inputs.externalProjectGit == 'forcedotcom/salesforcedx-apex' || (inputs.externalProjectGit == 'forcedotcom/salesforcedx-templates' && inputs.os == 'ubuntu-latest') }}
runs-on: ${{ inputs.os }}
steps:
- name: Configure Git to handle long file paths on Windows
if: ${{ runner.os == 'Windows' }}
run: git config --system core.longpaths true
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.nodeVersion }}
- name: Checkout to external project
uses: actions/checkout@v4
with:
repository: ${{ inputs.externalProjectGit }}
- name: Swap this dependency for the bundled version
run: |
yarn install --network-timeout 600000
yarn remove @salesforce/core
yarn add forcedotcom/sfdx-core#${{ inputs.bundledBranch }}
- name: Add dependencies to bundle node_modules
run: |
yarn install --network-timeout 600000
yarn add -D esbuild@^0.19.5 esbuild-plugin-pino@^2.1.0 npm-dts@^1.3.12 esbuild-plugin-tsc@^0.4.0
working-directory: node_modules/@salesforce/core
- name: Update for bundling
run: node scripts/updateForBundling.js
working-directory: node_modules/@salesforce/core
- name: Generate Bundle
run: |
yarn build
node scripts/build.js
working-directory: node_modules/@salesforce/core
- name: Post Bundling Update
run: |
node scripts/postBundlingUpdate.js
working-directory: node_modules/@salesforce/core
- name: Yarn deduplicate
run: |
npx yarn-deduplicate
- name: Retrieve Scripts
run: |
git clone https://github.com/forcedotcom/bundle-publish-scripts.git
- name: Update references for core bundle
run: |
node bundle-publish-scripts/scripts/updateForCoreBundle.js
- name: Update folder name
run: |
mv core core-bundle
working-directory: node_modules/@salesforce
- name: Build the external project (where the tests are)
run: yarn build
- name: Run tests with ${{ inputs.attempts }} attempts
uses: salesforcecli/github-workflows/.github/actions/retry@main
with:
max_attempts: ${{ inputs.attempts }}
command: yarn test
retry_on: error
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@
"@salesforce/kit": "^3.1.1",
"@salesforce/schemas": "^1.9.0",
"@salesforce/ts-types": "^2.0.9",
"ajv": "^8.13.0",
"ajv": "^8.14.0",
"change-case": "^4.1.2",
"faye": "^1.4.0",
"form-data": "^4.0.0",
"js2xmlparser": "^4.0.1",
"jsonwebtoken": "9.0.2",
"jszip": "3.10.1",
"pino": "^8.21.0",
"pino-abstract-transport": "^1.1.0",
"pino-abstract-transport": "^1.2.0",
"pino-pretty": "^10.3.1",
"proper-lockfile": "^4.1.2",
"semver": "^7.6.2",
"ts-retry-promise": "^0.7.1"
"ts-retry-promise": "^0.8.1"
},
"devDependencies": {
"@salesforce/dev-scripts": "^8.5.0",
Expand Down
Loading
Loading