Upgrade sfdx to sf #11
Workflow file for this run
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
name: Scratch Test | |
on: | |
workflow_dispatch: | |
# Push and PR on main are enabled to keep Codecove reports up to date | |
push: | |
branches: | |
- main | |
- dev | |
paths: | |
- 'src/**' | |
- 'scripts/**' | |
pull_request: | |
branches: | |
- main | |
- dev | |
paths: | |
- 'src/**' | |
- 'scripts/**' | |
env: | |
SF_CLI_URL: https://developer.salesforce.com/media/salesforce-cli/sf/channels/stable/sf-linux-x64.tar.xz | |
DEVHUB_ALIAS: devhub | |
SCRATCH_ALIAS: scratch-org | |
CODE_COVERAGE_DIR_PATH: ./coverage/apex | |
CODE_COVERAGE_FILE_PATH: ./coverage/apex/test-result-codecoverage.json | |
jobs: | |
formatting: | |
name: 'Verify source code formatting' | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout source code' | |
uses: actions/checkout@v3 | |
- name: 'Restore node_modules cache' | |
id: cache-npm | |
uses: actions/cache@v1 | |
with: | |
path: node_modules | |
key: npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
npm-${{ env.cache-name }}- | |
npm- | |
- name: 'Install npm dependencies' | |
if: steps.cache-npm.outputs.cache-hit != 'true' | |
run: npm i | |
- name: 'Verify formatting' | |
run: npm run prettier:verify ./ | |
scratch-testing: | |
name: 'Create a new scratch org and run Unit Tests' | |
runs-on: ubuntu-latest | |
needs: formatting | |
steps: | |
- name: 'Install Salesforce CLI' | |
run: | | |
wget ${{ env.SF_CLI_URL }} | |
mkdir ~/sf | |
tar xJf sf-linux-x64.tar.xz -C ~/sf --strip-components 1 | |
echo "$HOME/sf/bin" >> $GITHUB_PATH | |
~/sf/bin/sf version | |
- name: 'Checkout source code' | |
uses: actions/checkout@v3 | |
- name: 'Authenticate Dev Hub' | |
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 | |
sf org:login:sfdx-url -f ./DEVHUB_SFDX_URL.txt -a ${{ env.DEVHUB_ALIAS }} -d | |
- name: 'Create a scratch org' | |
run: sh ./scripts/pkg-from-scratch.sh ${{ env.DEVHUB_ALIAS }} ${{ env.SCRATCH_ALIAS }} | |
- name: 'Run Apex Tests' | |
run: sf apex:run:test -c -r human -d ${{ env.CODE_COVERAGE_DIR_PATH }} -w 20 -o ${{ env.SCRATCH_ALIAS }} | |
- name: 'Upload Test Coverage' | |
uses: codecov/codecov-action@v2 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ${{ env.CODE_COVERAGE_FILE_PATH }} | |
fail_ci_if_error: true | |
flags: Apex,unittests | |
verbose: true | |
- name: 'Delete scratch org' | |
if: always() | |
run: sf org:delete:scratch -p -o ${{ env.SCRATCH_ALIAS }} |