forked from forcedotcom/sfdx-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16585a8
commit 637bc57
Showing
1 changed file
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
name: Test External Projects | ||
on: | ||
workflow_call: | ||
inputs: | ||
externalProjectGitUrl: | ||
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" | ||
preExternalBuildCommands: | ||
required: false | ||
description: "commands to run before the build of the external repo...for example, to delete known module conflicts" | ||
type: string | ||
default: 'echo "no preExternalBuildCommands passed"' | ||
preSwapCommands: | ||
required: false | ||
description: "commands to run before ANY modifications happen. For example, changes that modify the lockfile like yarn add or remove need to happen before the action manually swaps the dependency under test" | ||
type: string | ||
default: 'echo "no preSwapCommands passed"' | ||
useCache: | ||
required: false | ||
type: boolean | ||
default: true | ||
attempts: | ||
required: false | ||
type: number | ||
default: 3 | ||
branch: | ||
required: false | ||
description: "branch to clone from the repo. Defaults to 'main'" | ||
type: string | ||
default: "main" | ||
bundledBranch: | ||
required: false | ||
description: Branch with the bundled version of core" | ||
type: string | ||
default: "main" | ||
|
||
jobs: | ||
external-test: | ||
name: yarn test | ||
runs-on: ${{ inputs.os }} | ||
steps: | ||
- name: Run git config | ||
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: Clone external project repo | ||
uses: salesforcecli/github-workflows/.github/actions/retry@main | ||
with: | ||
max_attempts: 20 | ||
command: git clone -b ${{ inputs.branch }} --single-branch ${{ inputs.externalProjectGitUrl }} $(pwd) | ||
timeout_minutes: 20 | ||
- name: Cache node modules | ||
if: inputs.useCache | ||
id: cache-nodemodules | ||
uses: actions/cache@v3 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-externalTests-${{ env.cache-name }}-${{ inputs.externalProjectGitUrl }}-${{ inputs.branch }}-${{ github.sha }} | ||
- name: Run yarn install | ||
if: ${{ steps.cache-nodemodules.outputs.cache-hit != 'true' }} | ||
uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main | ||
- name: Run pre-swap commands | ||
if: ${{ steps.cache-nodemodules.outputs.cache-hit != 'true' }} | ||
run: ${{ inputs.preSwapCommands }} | ||
- name: Swap this dependency for the bundled version | ||
if: ${{ steps.cache-nodemodules.outputs.cache-hit != 'true' }} | ||
run: | | ||
yarn remove @salesforce/core | ||
yarn add forcedotcom/sfdx-core#${{ inputs.bundledBranch }} | ||
npx yarn-deduplicate | ||
yarn install --network-timeout 600000 | ||
- name: Run pre-external build commands | ||
if: ${{ steps.cache-nodemodules.outputs.cache-hit != 'true' }} | ||
run: ${{ inputs.preExternalBuildCommands }} | ||
- 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 | ||
env: | ||
SF_DISABLE_TELEMETRY: true | ||
DEBUG: ${{ vars.DEBUG }} |