-
Notifications
You must be signed in to change notification settings - Fork 9
89 lines (71 loc) · 2.6 KB
/
pull-request.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: CI
on:
pull_request:
branches: [main]
jobs:
formatting-and-linting:
runs-on: ubuntu-latest
steps:
- name: "Checkout source code"
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- name: Set environment variables
run: |
echo "SFDX_DISABLE_AUTOUPDATE=true" >> $GITHUB_ENV
echo "SFDX_DISABLE_TELEMETRY=true" >> $GITHUB_ENV
- name: Install SFDX CLI and Scanner
run: |
npm install sfdx-cli
node_modules/sfdx-cli/bin/run plugins:install @salesforce/sfdx-scanner
- name: "Install npm dependencies"
run: npm install
- name: "Code formatting verification with Prettier"
run: npm run prettier:verify
- name: "Apex static analysis"
uses: mitchspano/[email protected]
with:
pmdconfig: apex-ruleset.xml
severity-threshold: 4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ci-build:
runs-on: ubuntu-latest
steps:
- name: Set environment variables
run: |
echo "SFDX_DISABLE_AUTOUPDATE=true" >> $GITHUB_ENV
echo "SFDX_DISABLE_SOURCE_MEMBER_POLLING=true" >> $GITHUB_ENV
echo "SFDX_DISABLE_TELEMETRY=true" >> $GITHUB_ENV
- name: Install Salesforce CLI
run: |
wget https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-amd64.tar.xz
mkdir sfdx-cli
tar xJf sfdx-linux-amd64.tar.xz -C sfdx-cli --strip-components 1
./sfdx-cli/install
- name: Checkout
uses: actions/checkout@v3
- name: "Populate auth file with CI_URL secret"
shell: bash
run: "echo ${{ secrets.CI_URL}} > ./CI_URL.txt"
- name: "Authenticate CI Sandbox"
run: "sfdx force:auth:sfdxurl:store -f ./CI_URL.txt -a ci -d"
- name: 'Create scratch org'
run: 'sfdx force:org:create -f config/project-scratch-def.json -a scratch-org -s -d 1'
- name: 'Push source to scratch org'
run: 'sfdx force:source:push'
- name: 'Run Apex tests'
run: npm run test:coverage
- name: 'Upload code coverage for Apex to Codecov.io'
uses: codecov/[email protected]
with:
flags: Apex
- name: 'Delete scratch org'
if: always()
run: 'sfdx force:org:delete -p -u scratch-org'