-
Notifications
You must be signed in to change notification settings - Fork 5
114 lines (96 loc) · 3.8 KB
/
scratch-org.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# Unique name for this workflow
name: Scratch Org
# Definition when the workflow should run
on:
push:
branches:
- master
paths-ignore:
- 'sfdx-project.json'
- 'README.md'
- '**/versionNumber.js'
- .github/**
# 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@v2
# Cache node_modules to speed up the process
- 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-
# Install npm dependencies for Prettier and Jest
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: 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:unit:coverage
# Upload LWC code coverage data
- name: 'Upload code coverage for LWC to Codecov.io'
uses: codecov/codecov-action@v1
with:
flags: LWC
scratch-org-tests:
runs-on: ubuntu-latest
needs: formatting-and-lwc-tests
steps:
# Install Salesforce CLI
- 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
# Checkout the code in the pull request
- name: 'Checkout source code'
uses: actions/checkout@v2
# 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: 'sfdx force:auth:sfdxurl:store -f ./DEVHUB_SFDX_URL.txt -a devhub -d'
# Remove auth file
- name: Remove auth file
run: rm -f ./DEVHUB_SFDX_URL.txt
# Create scratch org
- name: 'Create scratch org'
run: 'sfdx force:org:create -f config/project-scratch-def.json -a planning-poker -s -d 1'
# Deploy source to scratch org
- name: 'Push source'
run: 'sfdx force:source:push'
# Assign permission set
- name: 'Assign permission set'
run: 'sfdx force:user:permset:assign -n Planning_Poker_Host'
# Create Push Topics
- name: 'Create Push Topics'
run: sfdx force:apex:execute -f scripts/apex/createPushTopics.apex
# Run Apex tests in scratch org
- name: 'Run Apex tests'
run: 'sfdx force:apex:test:run -c -r human -d ./tests/apex -w 20'
# Upload Apex code coverage data
- name: 'Upload code coverage for Apex to Codecov.io'
uses: codecov/codecov-action@v1
with:
flags: Apex
# Housekeeping
- name: 'Delete scratch org'
if: always()
run: 'sfdx force:org:delete -p -u planning-poker'