Released new package version(s) #568
This file contains hidden or 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: | |
inputs: | |
prerelease: | |
description: "Run on a pre-release org?" | |
required: false | |
type: boolean | |
pull_request: | |
types: [opened, edited, synchronize, reopened] | |
# Workflow environment variables | |
env: | |
# Is the PR base branch a prerelease branch | |
IS_PRERELEASE: ${{ startsWith(github.event.pull_request.base.ref, 'prerelease/') || inputs.prerelease }} | |
# 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 | |
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: npm ci --force | |
env: | |
GHCR_TOKEN: ${{ secrets.GHCR_ACCESS_TOKEN }} | |
# 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 | |
# Generate css from scss | |
- name: "Automatically generate css" | |
run: npm run cssgen | |
# Generate JS versions of TS source | |
- name: "Automatically generate JS source from TypeScript" | |
run: npm run build | |
# 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 }} | |
# Auto merge Dependabot PRs for: | |
# - patch updates on prod dependencies | |
# - minor updates on dev dependencies | |
dependabot-auto-merge: | |
# Only run for Dependabot PRs | |
if: github.actor == 'dependabot[bot]' | |
runs-on: ubuntu-latest | |
needs: format-lint-lwc-tests | |
permissions: | |
pull-requests: write | |
contents: write | |
steps: | |
- name: "Fetch Dependabot metadata" | |
id: dependabot | |
uses: dependabot/fetch-metadata@v2 | |
- name: "Check auto merge conditions" | |
id: auto-merge | |
if: | | |
( | |
steps.dependabot.outputs.update-type == 'version-update:semver-patch' && | |
contains('direct:production,indirect:production', steps.dependabot.outputs.dependency-type) | |
) || ( | |
contains('version-update:semver-minor,version-update:semver-patch', steps.dependabot.outputs.update-type) && | |
contains('direct:development,indirect:development', steps.dependabot.outputs.dependency-type) | |
) | |
run: echo "::notice ::auto-merge conditions satisfied" | |
- name: "Approve and merge PR" | |
if: steps.auto-merge.conclusion == 'success' | |
run: | | |
gh pr review --approve "$PR_URL" | |
gh pr merge --auto --rebase "$PR_URL" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PR_URL: ${{ github.event.pull_request.html_url }} | |
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 --force | |
# Run PMD scan | |
- name: "Run PMD scan for sfGpsDs" | |
uses: pmd/[email protected] | |
id: pmd-sf-gps-ds | |
with: | |
sourcePath: "sfGpsDs" | |
rulesets: "ruleset.xml" | |
uploadSarifReport: "false" | |
# 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" | |
uploadSarifReport: "false" | |
# 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" | |
uploadSarifReport: "false" | |
# 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 sfGpsDsAuQld" | |
uses: pmd/[email protected] | |
id: pmd-sf-gps-ds-au-qld | |
with: | |
sourcePath: "sfGpsDsAuQld" | |
rulesets: "ruleset.xml" | |
uploadSarifReport: "false" | |
# Check for PMD violations | |
- name: "Check for PMD violations" | |
if: steps.pmd-sf-gps-ds-au-qld.outputs.violations != 0 | |
run: exit 1 | |
# Run PMD scan | |
- name: "Run PMD scan for sfGpsDsAuVic2" | |
uses: pmd/[email protected] | |
id: pmd-sf-gps-ds-au-vic2 | |
with: | |
sourcePath: "sfGpsDsAuVic2" | |
rulesets: "ruleset.xml" | |
uploadSarifReport: "false" | |
# Check for PMD violations | |
- name: "Check for PMD violations" | |
if: steps.pmd-sf-gps-ds-au-vic2.outputs.violations != 0 | |
run: exit 1 | |
# Run PMD scan | |
- name: "Run PMD scan for sfGpsDsFrGov" | |
uses: pmd/[email protected] | |
id: pmd-sf-gps-ds-fr-gov | |
with: | |
sourcePath: "sfGpsDsFrGov" | |
rulesets: "ruleset.xml" | |
uploadSarifReport: "false" | |
# 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/[email protected] | |
id: pmd-sf-gps-ds-uk-gov | |
with: | |
sourcePath: "sfGpsDsUkGov" | |
rulesets: "ruleset.xml" | |
uploadSarifReport: "false" | |
# 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: | | |
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 auth:sfdxurl:store -f ./DEVHUB_SFDX_URL.txt -a devhub -d | |
# Create pre-release scratch org | |
- name: "Create pre-release scratch org" | |
if: ${{ env.IS_PRERELEASE }} | |
run: sf org create scratch -f config/project-scratch-def.json --alias=scratch-org --set-default --duration-days=1 --release=preview --no-track-source | |
# Create scratch org | |
- name: "Create scratch org" | |
if: ${{ !env.IS_PRERELEASE }} | |
run: sf org create scratch -f config/project-scratch-def.json --alias=scratch-org --set-default --duration-days=1 --no-track-source | |
# Deploy omnistudio to scratch org | |
- name: "Deploy Omnistudio" | |
run: sf 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 JS versions of TS source | |
- name: "Automatically generate JS source from TypeScript" | |
run: npm run build | |
# 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: | | |
sf project deploy start --source-dir sfGpsDs --target-org=scratch-org | |
sf project deploy start --source-dir sfGpsDsAuNsw --target-org=scratch-org | |
sf project deploy start --source-dir sfGpsDsAuNswS --target-org=scratch-org | |
sf project deploy start --source-dir sfGpsDsAuQld --target-org=scratch-org | |
sf project deploy start --source-dir sfGpsDsAuVic2 --target-org=scratch-org | |
sf project deploy start --source-dir sfGpsDsUkGov --target-org=scratch-org | |
sf project deploy start --source-dir sfGpsDsFrGov --target-org=scratch-org | |
# Assign permissionset | |
# - name: 'Assign permissionset to default user' | |
# run: sf force:user:permset:assign -n recipes | |
# Import sample data | |
# - name: 'Import sample data' | |
# run: sf force:data:tree:import -p ./data/data-plan.json | |
# Run Apex tests in scratch org | |
- name: "Run Apex tests" | |
run: sf force apex test run --code-coverage --result-format=human --output-dir=./tests/apex --wait=20 --test-level=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: sf 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_BASE_REF --depth=1 | |
changedPaths=$( git diff-tree --name-only origin/$GITHUB_BASE_REF $GITHUB_SHA ) | |
set +e | |
hasChanges='false' | |
hasChangesSfGpsDs='false' | |
hasChangesSfGpsDsAuNsw='false' | |
hasChangesSfGpsDsAuNswS='false' | |
hasChangesSfGpsDsAuQld='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 '^sfGpsDsAuQld$') == 1 ]; then | |
hasChanges='true' | |
hasChangesSfGpsDsAuQld='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 "hasChangesSfGpsDsAuQld=$hasChangesSfGpsDsAuQld" >> $GITHUB_OUTPUT | |
echo "hasChangesSfGpsDsAuVic2=$hasChangesSfGpsDsAuVic2" >> $GITHUB_OUTPUT | |
echo "hasChangesSfGpsDsFrGov=$hasChangesSfGpsDsFrGov" >> $GITHUB_OUTPUT | |
echo "hasChangesSfGpsDsUkGov=$hasChangesSfGpsDsUkGov" >> $GITHUB_OUTPUT | |
# Trigger packaging PR workflow if needed | |
- name: "Trigger packaging PR 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-pr | |
client-payload: '{ "ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "isPrelease": "${{ env.IS_PRERELEASE }}", "sfGpsDs": "${{ steps.checkForChanges.outputs.hasChangesSfGpsDs }}", "sfGpsDsAuNsw": "${{ steps.checkForChanges.outputs.hasChangesSfGpsDsAuNsw }}", "sfGpsDsAuNswS": "${{ steps.checkForChanges.outputs.hasChangesSfGpsDsAuNswS }}", "sfGpsDsAuQld": "${{ steps.checkForChanges.outputs.hasChangesSfGpsDsAuQld }}", "sfGpsDsAuVic2": "${{ steps.checkForChanges.outputs.hasChangesSfGpsDsAuVic2 }}", "sfGpsDsFrGov": "${{ steps.checkForChanges.outputs.hasChangesSfGpsDsFrGov }}", "sfGpsDsUkGov": "${{ steps.checkForChanges.outputs.hasChangesSfGpsDsUkGov }}" }' |