Skip to content

Merge pull request #6 from trailheadapps/pozil/flow-fixes #5

Merge pull request #6 from trailheadapps/pozil/flow-fixes

Merge pull request #6 from trailheadapps/pozil/flow-fixes #5

Workflow file for this run

# Unique name for this workflow
name: CI
# Definition when the workflow should run
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- 'sfdx-project.json'
- 'README.md'
# Jobs to be executed
jobs:
format-lint-lwc-tests:
runs-on: trailheadapps-Ubuntu
steps:
# Checkout the source code
- name: 'Checkout source code'
uses: actions/checkout@v4
# Install Volta to enforce proper node and package manager versions
- name: 'Install Volta'
uses: volta-cli/action@v4
# Cache node_modules to speed up the process
- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.cache-name }}-
npm-
# Install npm dependencies for Prettier and Jest
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: HUSKY=0 npm ci
# Prettier formatting
- name: 'Code formatting verification with Prettier'
run: npm run prettier:verify
# Install Salesforce CLI
- name: 'Install Salesforce CLI'
run: |
npm install @salesforce/cli --location=global
nodeInstallPath=$(npm config get prefix)
echo "$nodeInstallPath/bin" >> $GITHUB_PATH
cd "$nodeInstallPath/bin"
./sf --version
# Install Salesforce CLI Code Analyzer plugin
- name: 'Install Salesforce CLI Code Analyzer plugin'
run: sf plugins install code-analyzer
# Run Code Analyzer
- name: 'Run Code Analyzer'
id: run-code-analyzer
uses: forcedotcom/run-code-analyzer@v2
with:
run-arguments: --workspace "force-app/main" --view detail --output-file "sca-results.csv" --config-file "code-analyzer.yml"
results-artifact-name: code-analyzer-results
github-token: ${{ github.token }}
# Check for Code Analyzer critical or high severity violations
- name: 'Check for Code Analyzer critical or high severity violations'
if: |
steps.run-code-analyzer.outputs.exit-code > 0 ||
steps.run-code-analyzer.outputs.num-sev1-violations > 0 ||
steps.run-code-analyzer.outputs.num-sev2-violations > 0
run: |
echo One of more Code Analyzer critical or high severity violations found
exit 1
scratch-org-test:
runs-on: trailheadapps-Ubuntu
needs: format-lint-lwc-tests
if: github.actor != 'dependabot[bot]'
steps:
# Checkout the source code
- name: 'Checkout source code'
uses: actions/checkout@v4
# Install Salesforce CLI
- name: 'Install Salesforce CLI'
run: |
npm install @salesforce/cli --location=global
nodeInstallPath=$(npm config get prefix)
echo "$nodeInstallPath/bin" >> $GITHUB_PATH
sf --version
# Store secret for dev hub
- name: 'Populate auth file with DEVHUB_SFDX_URL secret'
shell: bash
run: |
echo ${{ secrets.DEVHUB_SFDX_URL }} > ./DEVHUB_SFDX_URL.txt
secretFileSize=$(wc -c "./DEVHUB_SFDX_URL.txt" | awk '{print $1}')
if [ $secretFileSize == 1 ]; then
echo "Missing DEVHUB_SFDX_URL secret. Is this workflow running on a fork?";
exit 1;
fi
# Authenticate dev hub
- name: 'Authenticate Dev Hub'
run: sf org login sfdx-url -f ./DEVHUB_SFDX_URL.txt -a devhub -d
# Create scratch org
- name: 'Create scratch org'
run: sf org create scratch -f config/project-scratch-def.json -a scratch-org -d -y 1 -w 10
# Deploy source to scratch org
- name: 'Push source to scratch org'
run: sf project deploy start
# Assign permission sets
- name: 'Assign permission sets to default user'
run: |
sf org assign permset -n Agent_Script_Recipes_Data
sf org assign permset -n Agent_Script_Recipes_App
# Import sample data
- name: 'Import sample data'
run: sf data tree import -p ./data/data-plan.json
# Run Apex tests in scratch org
- name: 'Run Apex tests'
run: sf apex test run -c -r human -d ./tests/apex -w 20
# Housekeeping
- name: 'Delete scratch org'
if: always()
run: sf org delete scratch -p -o scratch-org