ci: action upgrades (#50) #112
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: CI | |
# Definition when the workflow should run | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
# Jobs to be executed | |
jobs: | |
formatting-and-lwc-tests: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the code in the pull request | |
- name: 'Checkout source code' | |
uses: actions/checkout@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: HUSKY=0 npm ci | |
# Prettier formatting | |
- name: 'Code formatting' | |
run: npm run prettier:verify | |
# ESlint | |
- name: 'Linting' | |
run: npm run lint | |
# LWC unit tests | |
- name: 'LWC unit tests' | |
run: npm run test:coverage | |
# Upload LWC code coverage data | |
- name: 'Upload code coverage for LWC to Codecov.io' | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
flags: LWC | |
scratch-org-tests: | |
runs-on: ubuntu-latest | |
needs: formatting-and-lwc-tests | |
steps: | |
# Install Salesforce CLI | |
- name: 'Install Salesforce CLI' | |
run: | | |
npm install --location=global @salesforce/cli | |
sf -v | |
# Checkout the code in the pull request | |
- name: 'Checkout source code' | |
uses: actions/checkout@v4 | |
# 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' | |
# Authenticate dev hub | |
- name: 'Authenticate Dev Hub' | |
run: 'sf org login sfdx-url -f ./DEVHUB_SFDX_URL.txt -a devhub -d' | |
# Create scratch org | |
- name: 'Create scratch org' | |
run: 'sf org create scratch -f config/project-scratch-def.json -a streaming-ci -d -y 1' | |
# Deploy source to scratch org | |
- name: 'Push source' | |
run: 'sf project deploy start' | |
# Assign permission set | |
- name: 'Assign permission set' | |
run: 'sf org assign permset -n Streaming_Monitor' | |
# Run Apex tests in scratch org | |
- name: 'Run Apex tests' | |
run: 'sf apex test run -c -r human -d ./tests/apex -w 20' | |
# 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 Apex code coverage data | |
- name: 'Upload code coverage for Apex to Codecov.io' | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
flags: Apex | |
# Housekeeping | |
- name: 'Delete scratch org' | |
if: always() | |
run: 'sf org delete scratch -p -o streaming-ci' |