-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (101 loc) · 3.48 KB
/
ci.yml
File metadata and controls
114 lines (101 loc) · 3.48 KB
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: On Push
# Definition when the workflow should run
on:
workflow_dispatch:
push:
# paths-ignore:
# - 'sfdx-project.json'
# - 'README.md'
# - 'docs/**'
# - 'doc-assets/**'
# - '.vscode/**'
# - '.github/**'
paths:
- 'force-app/**'
- 'triggerhandler/**'
- 'unpackaged/**'
- 'pmd/**'
- 'config/**'
- '**/workflows/**'
- '.github/workflows/ci.yml'
# Jobs to be executed
jobs:
format-lint:
runs-on: ubuntu-latest
steps:
# Checkout the source code
- 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: npm ci
# Start local Apex parser server for Prettier
# - name: 'Start local Apex parser server for Prettier'
# run: npm run apex:local:start &
# Wait for Apex parser server startup
#- name: 'Wait for Apex parser server startup'
# run: timeout 30 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' 127.0.0.1 2117
# Prettier formatting
- name: 'Code formatting verification with Prettier'
run: npm run prettier:verify:apex
# Stop local Apex parser server for Prettier
#- name: 'Stop local Apex parser server for Prettier'
# if: always()
# run: npm run apex:local:stop
pmd-analysis:
runs-on: ubuntu-latest
needs: format-lint
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
# Checkout the source code
- name: 'Checkout source code'
uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
- name: 'Perform PMD scan with PMD action'
uses: pmd/pmd-github-action@v2
id: pmd-action
with:
version: 'latest'
sourcePath: 'force-app'
rulesets: 'pmd/deployRules.xml'
analyzeModifiedFilesOnly: false
createGitHubAnnotations: true
# Check for PMD violations
- name: 'Check for PMD violations'
if: steps.pmd-action.outputs.violations != 0
run: exit 1
pmd-analysis-download:
runs-on: ubuntu-latest
needs: format-lint
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
# Checkout the source code
- name: 'Checkout source code'
uses: actions/checkout@v4
# Install PMD
- name: 'Install PMD'
run: |
PMD_VERSION=$(curl -s https://api.github.com/repos/pmd/pmd/releases/latest | grep '.tag_name' | sed 's:.*/::' | sed 's:",::')
echo $PMD_VERSION
wget https://github.com/pmd/pmd/releases/download/pmd_releases%2F$PMD_VERSION/pmd-dist-$PMD_VERSION-bin.zip
unzip pmd-dist-$PMD_VERSION-bin.zip -d ~
mv ~/pmd-bin-$PMD_VERSION ~/pmd
~/pmd/bin/pmd --version
# Run PMD scan
- name: 'Run PMD scan'
run: ~/pmd/bin/pmd check --dir force-app --rulesets pmd/deployRules.xml --format text --cache .pmdCache --no-progress --minimum-priority "Medium Low"