ci(dependabot): stop auto-merging dependabot #65
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: Pull Request Validation | |
# Definition when the workflow should run | |
on: | |
pull_request: | |
types: [edited, opened, synchronize, reopened, review_requested] | |
paths: | |
- 'force-app/**' | |
- 'unpackaged/**' | |
- 'pmd/**' | |
- 'config/**' | |
- '**/workflows/**' | |
workflow_dispatch: | |
push: | |
paths: | |
- '.github/workflows/pr.yml' | |
# Jobs to be executed | |
jobs: | |
format-check: | |
runs-on: ubuntu-latest | |
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 | |
- name: 'Setup node' | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 'lts/*' | |
cache: 'npm' | |
- name: 'Install NPM' | |
run: npm ci | |
# Prettier formatting | |
- name: 'Code formatting verification with Prettier' | |
run: npm run prettier:verify:apex | |
scan-pmd-action: | |
runs-on: ubuntu-latest | |
needs: format-check | |
#if: ${{ github.actor != 'dependabot[bot]' }} | |
steps: | |
# Checkout the source code | |
- name: 'Checkout source code' | |
uses: actions/checkout@v4 | |
- name: 'Setup java' | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
# Run PMD scan | |
- name: 'Perform PMD scan with PMD action' | |
uses: pmd/pmd-github-action@v2 | |
id: pmd-action | |
with: | |
version: 'latest' | |
sourcePath: 'force-app' | |
rulesets: 'pmd/deployRules.xml' | |
analyzeModifiedFilesOnly: false | |
createGitHubAnnotations: true | |
# Check for PMD violations | |
- name: 'Check for PMD violations' | |
if: steps.pmd-action.outputs.violations != 0 | |
run: exit 1 | |
scratch-org-apex-tests: | |
runs-on: ubuntu-latest | |
needs: format-check | |
#if: ${{ github.actor != 'dependabot[bot]' }} | |
steps: | |
# Checkout the source code | |
- name: 'Checkout source code' | |
uses: actions/checkout@v4 | |
# Install Salesforce CLI | |
- name: 'Install Salesforce sf CLI' | |
run: | | |
npm install @salesforce/cli --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 --sfdx-url-file ./DEVHUB_SFDX_URL.txt --alias devhub --set-default-dev-hub | |
# Add namespace to project config | |
- name: Add namespace to project config | |
run: | | |
sed -i 's,"namespace": "","namespace": "",' sfdx-project.json | |
# Create scratch org | |
- name: 'Create scratch org' | |
run: sf org create scratch --definition-file config/project-scratch-def.json --alias CampaignMemberStatus --set-default --no-ancestors --duration-days 1 --wait 20 --target-dev-hub devhub --no-track-source | |
# Deploy source to scratch org | |
- name: 'Push source to scratch org' | |
run: | | |
sf project deploy start | |
sf project deploy start --source-dir unpackaged | |
# Run Apex tests in scratch org | |
- name: 'Run Apex tests' | |
run: sf apex run test --code-coverage --detailed-coverage --result-format human --wait 20 --test-level RunLocalTests --output-dir ./ | |
# Upload code coverage to Codecov.io | |
- name: 'Upload code coverage for Apex to Codecov.io' | |
uses: codecov/codecov-action@v5 | |
with: | |
flags: Apex | |
token: ${{ secrets.CODECOV_TOKEN }} | |
# Housekeeping | |
- name: 'Delete scratch org' | |
if: always() | |
run: sf org delete scratch --no-prompt --target-org CampaignMemberStatus | |
# Remove namespace from project config | |
- name: Remove namespace from project config | |
run: | | |
sed -i 's,"namespace": "","namespace": "",' sfdx-project.json |