Skip to content

Merge pull request #1 from SalesforceLabs/eschweitzer78/repo-migration #3

Merge pull request #1 from SalesforceLabs/eschweitzer78/repo-migration

Merge pull request #1 from SalesforceLabs/eschweitzer78/repo-migration #3

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: ubuntu-latest
steps:
# Checkout the source code
- name: "Checkout source code"
uses: actions/checkout@v3
# Install Volta to enforce proper node and package manager versions
- name: "Install Volta"
uses: volta-cli/action@v3
# Cache node_modules to speed up the process
- name: "Restore node_modules cache"
id: cache-npm
uses: actions/cache@v3
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@v3
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@v3
# Install Volta to enforce proper node and package manager versions
- name: "Install Volta"
uses: volta-cli/action@v3
# Cache node_modules to speed up the process
- name: "Restore node_modules cache"
id: cache-npm
uses: actions/cache@v3
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
# Prep
- name: "Prepare repo"
run: npm run prep
# Run PMD scan
- name: "Run PMD scan for sfGpsDs"
uses: pmd/[email protected]
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/[email protected]
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/[email protected]
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/[email protected]
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 sfGpsDsUkGov"
uses: pmd/[email protected]
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 v7.182.1"
run: |
npm install [email protected] --location=global
nodeInstallPath=$(npm config get prefix)
echo "$nodeInstallPath/bin" >> $GITHUB_PATH
# Install 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 force:org:create -f config/project-scratch-def.json -a scratch-org -s -d 1
# Deploy omnistudio to scratch org
- name: "Deploy Omnistudio"
run: sfdx force:package:install -p ${{ vars.OMNISTUDIO_PACKAGEID }} -u scratch-org -w 20 -r -s=AllUsers
# Activate metadata for omnistudio on scratch org
# (removed as OmniStudio metadata cannot be packaged fo now)
# - name: "Enable OmniStudio metadata"
# run: |
# cd ./node_modules/puppeteer
# npm run postinstall
# cd ../..
# node ./configure-omnistudio-metadata scratch-org
# 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 force:source:push -u 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 -c -r human -d ./tests/apex -w 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@v3
with:
flags: Apex
token: ${{ secrets.CODECOV_TOKEN }}
# Housekeeping
- name: "Delete scratch org"
if: always()
run: sfdx force:org:delete -p -u scratch-org
trigger-packaging:
runs-on: ubuntu-latest
needs: scratch-org-test
steps:
# Checkout the source code
- name: "Checkout source code"
uses: actions/checkout@v3
# 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'
hasChangesSfGpsDsAuVic='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'
hasChangesSfGpsDsAuVic='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 "hasChangesSfGpsDsAuVic=$hasChangesSfGpsDsAuVic" >> $GITHUB_OUTPUT
echo "hasChangesSfGpsDsUkGov=$hasChangesSfGpsDsUkGov" >> $GITHUB_OUTPUT
# Trigger packaging workflow if needed
- name: "Trigger packaging workflow if needed"
uses: peter-evans/repository-dispatch@v2
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 }}", "sfGpsDsAuVic": "${{ steps.checkForChanges.outputs.hasChangesSfGpsDsAuVic }}", "sfGpsDsUkGov": "${{ steps.checkForChanges.outputs.hasChangesSfGpsDsUkGov }}" }'