Skip to content

FIX (DevOps) @W-15619625@: Workflow jobs properly sequenced. #1

FIX (DevOps) @W-15619625@: Workflow jobs properly sequenced.

FIX (DevOps) @W-15619625@: Workflow jobs properly sequenced. #1

Workflow file for this run

name: run-tests
on:
workflow_call:
inputs:
use-scanner-tarball:
description: 'If true, install scanner via tarball'
required: false
type: boolean
default: false
target-branch:
description: "What branch should be checked out?"
required: falsetype: string

Check failure on line 12 in .github/workflows/run-tests.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/run-tests.yml

Invalid workflow file

You have an error in your yaml syntax on line 12
# If no target branch is specified, just use the one we'd use normally.
default: ${{ github.sha }}
jobs:
build-and-run:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: 'Check out the code'
uses: actions/checkout@v4
with:
ref: ${{ inputs.target-branch }}
- name: 'Set up NodeJS'
uses: actions/setup-node@v4
with:
node-version: 'lts/*' # Node LTS should always be fine.
- name: 'Install Java v11'
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11' # Always use Java v11 for running tests.
- name: 'Install node module dependencies'
run: yarn install --frozen-lockfile
# We'll need to install the CLI tool, since some of the tests
# are integration tests.
- name: Install SF CLI
run: npm install --global @salesforce/cli
# We'll need to install Salesforce Code Analyzer, since some
# of the tests are integration tests.
# NOTE: SFCA can come from a tarball built in a previous step,
# or be installed as the currently-latest version.
- name: Download Scanner Tarball
if: ${{ inputs.use-scanner-tarball == true }}
id: download
uses: actions/download-artifact@v4
with:
name: scanner-tarball
# Download the tarball to a subdirectory of HOME, so it's guaranteed
# to be somewhere the installation command can see.
path: ~/downloads/tarball
- name: Install Scanner Tarball
if: ${{ inputs.use-scanner-tarball == true }}
shell: bash
run: |
# Determine the tarball's name.
TARBALL_NAME=$(ls ~/downloads/tarball/sfdx-scanner | grep salesforce-sfdx-scanner-[0-9]*\\.[0-9]*\\.[0-9]*\\.tgz)
echo $TARBALL_NAME
# Figure out where the tarball was downloaded to.
# To allow compatibility with Windows, replace backslashes with forward slashes
# and rip off a leading `C:` if present.
DOWNLOAD_PATH=`echo '${{ steps.download.outputs.download-path }}' | tr '\\' '/'`
echo $DOWNLOAD_PATH
DOWNLOAD_PATH=`[[ $DOWNLOAD_PATH = C* ]] && echo $DOWNLOAD_PATH | cut -d':' -f 2 || echo $DOWNLOAD_PATH`
echo $DOWNLOAD_PATH
# Pipe in a `y` to simulate agreeing to install an unsigned package. Use a URI of the file's full path.
echo y | sf plugins install "file://${DOWNLOAD_PATH}/sfdx-scanner/${TARBALL_NAME}"
- name: Install Production scanner
if: ${{ inputs.use-scanner-tarball == false }}
run: sf plugins install @salesforce/sfdx-scanner
# Run the tests. (Linux and non-Linux need slightly different commands.)
- name: 'Run Tests (Linux)'
run: xvfb-run -a yarn test
if: runner.os == 'Linux'
- name: 'Run Tests (non-Linux)'
run: yarn test
if: runner.os != 'Linux'
# Lint, to make sure we're following best practices.
- name: 'Lint'
run: yarn lint
# Upload the code coverage from the test as an artifact with
# the name 'code-coverage-[whatever the OS is]'.
- name: Upload coverage artifact
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: code-coverage-${{ runner.os }}
path: ./coverage