eschweitzer78/vic2-20240501 #383
Workflow file for this run
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
# Unique name for this workflow | |
name: CI on PR | |
# Definition when the workflow should run | |
on: | |
workflow_dispatch: | |
pull_request: | |
types: [opened, edited, synchronize, reopened] | |
branches-ignore: | |
- prerelease/spring[2-9][0-9] | |
- prerelease/summer[2-9][0-9] | |
- prerelease/winter[2-9][0-9] | |
# Jobs to be executed | |
jobs: | |
# Dummy job used to skip CI run on automated PRs | |
skip-ci: | |
if: "github.actor == 'eschweitzer78-bot'" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Noop | |
run: | | |
echo "Skipping CI run for automated PRs." | |
format-lint-lwc-tests: | |
if: "github.actor != 'eschweitzer78-bot'" | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: read | |
steps: | |
- uses: aquacash5/npm-gpr-auth@v2 | |
with: | |
token: ${{ secrets.GHCR_ACCESS_TOKEN }} | |
# 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: npm ci | |
# Prettier formatting | |
- name: "Code formatting verification with Prettier" | |
run: npm run prettier:verify | |
# Lint LWC / Aura | |
- name: "Lint Lightning Web Components / Aura Components" | |
run: npm run lint | |
# LWC unit tests | |
- name: "Unit test Lightning Web Components" | |
run: npm run test:unit:coverage | |
# Upload code coverage data | |
- name: "Upload code coverage for LWC to Codecov.io" | |
uses: codecov/codecov-action@v4 | |
with: | |
flags: LWC | |
token: ${{ secrets.CODECOV_TOKEN }} | |
scratch-org-test: | |
runs-on: ubuntu-latest | |
needs: format-lint-lwc-tests | |
if: ${{ github.actor != 'dependabot[bot]' }} | |
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- | |
# Prep | |
- name: "Prepare repo" | |
run: npm run prep | |
# Install npm dependencies for Prettier and Jest | |
- name: "Install npm dependencies" | |
if: steps.cache-npm.outputs.cache-hit != 'true' | |
run: npm ci | |
# Run PMD scan | |
- name: "Run PMD scan for sfGpsDs" | |
uses: pmd/pmd-github-action@v1.4.1 | |
id: pmd-sf-gps-ds | |
with: | |
sourcePath: "sfGpsDs" | |
rulesets: "ruleset.xml" | |
# Check for PMD violations | |
- name: "Check for PMD violations" | |
if: steps.pmd-sf-gps-ds.outputs.violations != 0 | |
run: exit 1 | |
# Run PMD scan | |
- name: "Run PMD scan for sfGpsDsAuNsw" | |
uses: pmd/pmd-github-action@v1.4.1 | |
id: pmd-sf-gps-ds-au-nsw | |
with: | |
sourcePath: "sfGpsDsAuNsw" | |
rulesets: "ruleset.xml" | |
# Check for PMD violations | |
- name: "Check for PMD violations" | |
if: steps.pmd-sf-gps-ds-au-nsw.outputs.violations != 0 | |
run: exit 1 | |
# Run PMD scan | |
- name: "Run PMD scan for sfGpsDsAuNswS" | |
uses: pmd/pmd-github-action@v1.4.1 | |
id: pmd-sf-gps-ds-au-nsw-s | |
with: | |
sourcePath: "sfGpsDsAuNswS" | |
rulesets: "ruleset.xml" | |
# Check for PMD violations | |
- name: "Check for PMD violations" | |
if: steps.pmd-sf-gps-ds-au-nsw-s.outputs.violations != 0 | |
run: exit 1 | |
# Run PMD scan | |
- name: "Run PMD scan for sfGpsDsAuVic" | |
uses: pmd/pmd-github-action@v1.4.1 | |
id: pmd-sf-gps-ds-au-vic | |
with: | |
sourcePath: "sfGpsDsAuVic" | |
rulesets: "ruleset.xml" | |
# Check for PMD violations | |
- name: "Check for PMD violations" | |
if: steps.pmd-sf-gps-ds-au-vic.outputs.violations != 0 | |
run: exit 1 | |
# Run PMD scan | |
- name: "Run PMD scan for sfGpsDsFrGov" | |
uses: pmd/pmd-github-action@v1.4.1 | |
id: pmd-sf-gps-ds-fr-gov | |
with: | |
sourcePath: "sfGpsDsFrGov" | |
rulesets: "ruleset.xml" | |
# Check for PMD violations | |
- name: "Check for PMD violations" | |
if: steps.pmd-sf-gps-ds-fr-gov.outputs.violations != 0 | |
run: exit 1 | |
# Run PMD scan | |
- name: "Run PMD scan for sfGpsDsUkGov" | |
uses: pmd/pmd-github-action@v1.4.1 | |
id: pmd-sf-gps-ds-uk-gov | |
with: | |
sourcePath: "sfGpsDsUkGov" | |
rulesets: "ruleset.xml" | |
# Check for PMD violations | |
- name: "Check for PMD violations" | |
if: steps.pmd-sf-gps-ds-uk-gov.outputs.violations != 0 | |
run: exit 1 | |
# Install Salesforce CLI | |
- name: "Install Salesforce CLI latest" | |
run: | | |
npm install @salesforce/cli --location=global | |
nodeInstallPath=$(npm config get prefix) | |
echo "$nodeInstallPath/bin" >> $GITHUB_PATH | |
# Confirm version Salesforce CLI | |
- name: "Confirm Salesforce CLI version" | |
run: | | |
sfdx --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: sfdx auth:sfdxurl:store -f ./DEVHUB_SFDX_URL.txt -a devhub -d | |
# Create scratch org | |
- name: "Create scratch org" | |
run: sfdx org create scratch -f config/project-scratch-def.json --alias=scratch-org --set-default --duration-days=1 | |
# Deploy omnistudio to scratch org | |
- name: "Deploy Omnistudio" | |
run: sfdx package install --package=${{ vars.OMNISTUDIO_PACKAGEID }} --target-org=scratch-org --wait=20 --no-prompt --security-type=AllUsers | |
# Generate css from scss | |
- name: "Automatically generate css" | |
run: npm run cssgen | |
# Generate omnistudio versions of source | |
- name: "Automatically generate Omnistudio source" | |
run: npm run osfilegen | |
# Deploy source to scratch org | |
- name: "Push source to scratch org" | |
run: sfdx project deploy start --target-org=scratch-org | |
# Assign permissionset | |
# - name: 'Assign permissionset to default user' | |
# run: sfdx force:user:permset:assign -n recipes | |
# Import sample data | |
# - name: 'Import sample data' | |
# run: sfdx force:data:tree:import -p ./data/data-plan.json | |
# Run Apex tests in scratch org | |
- name: "Run Apex tests" | |
run: sfdx force apex test run --code-coverage --result-format=human --output-dir=./tests/apex --wait=20 --testlevel=RunLocalTests | |
# Delete temporary test file that Codecov is unable to parse | |
#- name: "Delete coverage file (temporary step)" | |
# run: rm ./tests/apex/test-result-707*-codecoverage.json | |
# Upload code coverage data | |
- name: "Upload code coverage for Apex to Codecov.io" | |
uses: codecov/codecov-action@v4 | |
with: | |
flags: Apex | |
token: ${{ secrets.CODECOV_TOKEN }} | |
# Housekeeping | |
- name: "Delete scratch org" | |
if: always() | |
run: sfdx org delete scratch --no-prompt --target-org=scratch-org | |
trigger-packaging: | |
runs-on: ubuntu-latest | |
needs: scratch-org-test | |
steps: | |
# Checkout the source code | |
- name: "Checkout source code" | |
uses: actions/checkout@v4 | |
# Check for package changes using git diff | |
- name: "Check for package changes" | |
id: checkForChanges | |
run: | | |
git fetch origin ${{ github.event.before }} --depth=1 | |
changedPaths=$( git diff-tree --name-only ${{ github.event.before }} $GITHUB_SHA ) | |
set +e | |
hasChanges='false' | |
hasChangesSfGpsDs='false' | |
hasChangesSfGpsDsAuNsw='false' | |
hasChangesSfGpsDsAuNswS='false' | |
hasChangesSfGpsDsAuVic1='false' | |
hasChangesSfGpsDsAuVic2='false' | |
hasChangesSfGpsDsFrGov='false' | |
hasChangesSfGpsDsUkGov='false' | |
if [ $(echo "$changedPaths" | grep -c '^sfGpsDs$') == 1 ]; then | |
hasChanges='true' | |
hasChangesSfGpsDs='true' | |
fi | |
if [ $(echo "$changedPaths" | grep -c '^sfGpsDsAuNsw$') == 1 ]; then | |
hasChanges='true' | |
hasChangesSfGpsDsAuNsw='true' | |
fi | |
if [ $(echo "$changedPaths" | grep -c '^sfGpsDsAuNswS$') == 1 ]; then | |
hasChanges='true' | |
hasChangesSfGpsDsAuNswS='true' | |
fi | |
if [ $(echo "$changedPaths" | grep -c '^sfGpsDsAuVic$') == 1 ]; then | |
hasChanges='true' | |
hasChangesSfGpsDsAuVic1='true' | |
fi | |
if [ $(echo "$changedPaths" | grep -c '^sfGpsDsAuVic2$') == 1 ]; then | |
hasChanges='true' | |
hasChangesSfGpsDsAuVic2='true' | |
fi | |
if [ $(echo "$changedPaths" | grep -c '^sfGpsDsFrGov$') == 1 ]; then | |
hasChanges='true' | |
hasChangesSfGpsDsFrGov='true' | |
fi | |
if [ $(echo "$changedPaths" | grep -c '^sfGpsDsUkGov$') == 1 ]; then | |
hasChanges='true' | |
hasChangesSfGpsDsUkGov='true' | |
fi | |
echo "hasChanges=$hasChanges" >> $GITHUB_OUTPUT | |
echo "hasChangesSfGpsDs=$hasChangesSfGpsDs" >> $GITHUB_OUTPUT | |
echo "hasChangesSfGpsDsAuNsw=$hasChangesSfGpsDsAuNsw" >> $GITHUB_OUTPUT | |
echo "hasChangesSfGpsDsAuNswS=$hasChangesSfGpsDsAuNswS" >> $GITHUB_OUTPUT | |
echo "hasChangesSfGpsDsAuVic1=$hasChangesSfGpsDsAuVic1" >> $GITHUB_OUTPUT | |
echo "hasChangesSfGpsDsAuVic2=$hasChangesSfGpsDsAuVic2" >> $GITHUB_OUTPUT | |
echo "hasChangesSfGpsDsFrGov=$hasChangesSfGpsDsFrGov" >> $GITHUB_OUTPUT | |
echo "hasChangesSfGpsDsUkGov=$hasChangesSfGpsDsUkGov" >> $GITHUB_OUTPUT | |
# Trigger packaging workflow if needed | |
- name: "Trigger packaging workflow if needed" | |
uses: peter-evans/repository-dispatch@v3 | |
if: ${{ steps.checkForChanges.outputs.hasChanges == 'true' }} | |
with: | |
token: ${{ secrets.BOT_ACCESS_TOKEN }} | |
event-type: start-packaging | |
client-payload: '{ "ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "sfGpsDs": "${{ steps.checkForChanges.outputs.hasChangesSfGpsDs }}", "sfGpsDsAuNsw": "${{ steps.checkForChanges.outputs.hasChangesSfGpsDsAuNsw }}", "sfGpsDsAuNswS": "${{ steps.checkForChanges.outputs.hasChangesSfGpsDsAuNswS }}", "sfGpsDsAuVic1": "${{ steps.checkForChanges.outputs.hasChangesSfGpsDsAuVic1 }}", "sfGpsDsAuVic2": "${{ steps.checkForChanges.outputs.hasChangesSfGpsDsAuVic2 }}", "sfGpsDsFrGov": "${{ steps.checkForChanges.outputs.hasChangesSfGpsDsFrGov }}", "sfGpsDsUkGov": "${{ steps.checkForChanges.outputs.hasChangesSfGpsDsUkGov }}" }' |