Skip to content

Commit

Permalink
ci: run tests from oclif plugin repos (#882)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley authored Nov 30, 2023
1 parent bc8d87f commit b7124bf
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 284 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/external-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
workflow_call:
inputs:
os:
required: false
description: "runs-on property, ex: ubuntu-latest, windows-latest"
type: string
default: "ubuntu-latest"
repo:
required: true
description: "Repository name, ex: 'owner/repo'"
type: string
command:
required: true
description: "Command to run, ex: 'yarn test'"
type: string
other-setup:
required: false
description: "Setup command, ex: 'yarn install'"
type: string

jobs:
external-test:
name: ${{ inputs.repo }} ${{ inputs.command }}
runs-on: ${{ inputs.os }}
steps:
- uses: actions/setup-node@v4
- uses: actions/checkout@v4
- uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main
- run: yarn build
- run: yarn link
- run: ${{ inputs.other-setup }}
- uses: actions/checkout@v4
with:
repository: ${{ inputs.repo }}
ref: main
path: test
- name: Build plugin
working-directory: test
run: |
yarn install --network-timeout 600000 --ignore-scripts
yarn link @oclif/core
yarn build
- name: Run tests in plugin
working-directory: test
run: ${{ inputs.command }}
45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,48 @@ jobs:
TESTKIT_JWT_CLIENT_ID: ${{ secrets.TESTKIT_JWT_CLIENT_ID }}
TESTKIT_JWT_KEY: ${{ secrets.TESTKIT_JWT_KEY }}
TESTKIT_HUB_INSTANCE: ${{ secrets.TESTKIT_HUB_INSTANCE }}
external-unit-tests:
needs: linux-unit-tests
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
repo:
- oclif/plugin-autocomplete
- oclif/plugin-commands
- oclif/plugin-help
- oclif/plugin-not-found
- oclif/plugin-plugins
- oclif/plugin-update
- oclif/plugin-which
- oclif/plugin-warn-if-update-available
- oclif/plugin-version
uses: ./.github/workflows/external-test.yml
with:
repo: ${{ matrix.repo }}
os: ${{ matrix.os }}
command: "yarn mocha test/**/*.test.ts --timeout 1200000"
plugin-plugins-integration:
needs: linux-unit-tests
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
uses: ./.github/workflows/external-test.yml
with:
repo: oclif/plugin-plugins
os: ${{ matrix.os }}
command: "yarn test:integration"
# plugin-plugins integration tests depend on sf being installed globally
other-setup: npm install -g @salesforce/cli@nightly
plugin-update-integration:
needs: linux-unit-tests
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
uses: ./.github/workflows/external-test.yml
with:
repo: oclif/plugin-update
os: ${{ matrix.os }}
command: "yarn test:integration:sf"
277 changes: 0 additions & 277 deletions test/integration/plugins.e2e.ts

This file was deleted.

10 changes: 3 additions & 7 deletions test/integration/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export type SetupOptions = {
plugins?: string[]
subDir?: string
noLinkCore?: boolean
yarnInstallArgs?: string[]
}

export type ExecutorOptions = {
Expand Down Expand Up @@ -187,12 +186,9 @@ export async function setup(testFile: string, options: SetupOptions): Promise<Ex
executor.debug(`${bin}_CONFIG_DIR:`, process.env[`${bin}_CONFIG_DIR`])
executor.debug(`${bin}_CACHE_DIR:`, process.env[`${bin}_CACHE_DIR`])

const yarnInstallRes = await executor.executeInTestDir(
`yarn install --force --network-timeout 600000 ${options.yarnInstallArgs?.join(' ') ?? ''}`,
{
silent: false,
},
)
const yarnInstallRes = await executor.executeInTestDir('yarn install --force --network-timeout 600000', {
silent: false,
})
if (yarnInstallRes.code !== 0) {
console.error(yarnInstallRes?.error)
throw new Error('Failed to run `yarn install --force`')
Expand Down

0 comments on commit b7124bf

Please sign in to comment.