Prototyping leaving a changelog comment on the PR #498
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
name: PR Build | |
on: | |
pull_request: | |
branches: [ main ] | |
types: [ opened, reopened, synchronize, closed ] | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
unit-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: "20" | |
- name: Install dependencies | |
run: npm install | |
- name: Install Salesforce CLI | |
run: npm install @salesforce/cli --global | |
- name: Populate auth file with SFDX_URL secret | |
shell: bash | |
run: echo ${{ secrets.DEV_HUB_AUTH_URL}} > ./SFDX_URL_STORE.txt | |
- name: Authenticate against dev hub | |
run: sf org login sfdx-url --sfdx-url-file ./SFDX_URL_STORE.txt --alias=devhub --set-default-dev-hub | |
- name: Create scratch org | |
run: sf org create scratch --definition-file=config/dev.json --alias=scratch-org --set-default --duration-days=1 | |
- name: Push source | |
run: sf project deploy start | |
- name: Run tests | |
run: sf apex run test --code-coverage --result-format json -w 30 > test-results.json | |
- name: Check code coverage | |
run: | | |
COVERAGE=$(jq -r '.result.summary.testRunCoverage' test-results.json) | |
COVERAGE=${COVERAGE%\%} | |
echo "Code coverage: $COVERAGE%" | |
if (( $(echo "$COVERAGE < 90" | bc -l) )); then | |
echo "Code coverage is less than 90%, failing the build." | |
exit 1 | |
fi | |
- name: Clean up scratch org | |
run: sf org scratch delete --target-org=scratch-org --no-prompt |