Skip to content

Commit 8ba0c4f

Browse files
Merge pull request #1661 from forcedotcom/release-5.0.0-alpha.3
RELEASE @W-16879137@: Conducting v5.0.0 alpha.3 release
2 parents 6b5d516 + a904658 commit 8ba0c4f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1944
-1296
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"project": "./tsconfig.json"
1313
},
1414
"rules": {
15-
"@typescript-eslint/no-unused-vars": ["error", {"argsIgnorePattern": "^_"}]
15+
"@typescript-eslint/no-unused-vars": ["error", {"argsIgnorePattern": "^_"}],
16+
"@typescript-eslint/unbound-method": ["error", {"ignoreStatic": true}]
1617
},
1718
"plugins": [
1819
"@typescript-eslint",

.github/workflows/run-tests.yml

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,35 @@ jobs:
4646
path: |
4747
./reports
4848
./coverage
49+
50+
# The smoke tests should mimic a production setup as closely as possible. To that end, we'll spin up a tarball and
51+
# then upload it as an artifact, so the smoke test jobs can pull it down and install it.
52+
build-installable-tarball:
53+
runs-on: ubuntu-latest
54+
steps:
55+
# Obviously, we need to get the code first
56+
- uses: actions/checkout@v4
57+
with:
58+
ref: ${{ inputs.target-branch }}
59+
# Make sure we're on the right version of Node
60+
- uses: actions/setup-node@v4
61+
with:
62+
node-version: 'lts/*' # Always use Node LTS for building the tarball
63+
# Install/build dependencies
64+
- run: yarn
65+
- run: yarn build
66+
# Create the tarball
67+
- run: npm pack
68+
# Upload the tarball as an artifact
69+
- uses: actions/upload-artifact@v4
70+
with:
71+
name: smoke-test-tarball
72+
path: ./salesforce-plugin-code-analyzer-*.tgz
4973
# For now, the smoke tests are no-ops, so the job doesn't have to do anything exciting.
5074
# When smoke-tests stop being no-ops, we'll need a build-dependencies step to create a tarball artifact, and so forth.
5175
# We'll be able to use the v4 workflow as a template.
5276
smoke-tests:
77+
needs: build-installable-tarball
5378
strategy:
5479
# By default, if any job in a matrix fails, all other jobs are automatically cancelled. This makes the jobs run
5580
# to completion instead.
@@ -59,8 +84,47 @@ jobs:
5984
os: [{vm: ubuntu-latest, exe: .sh}, {vm: macos-latest, exe: .sh}, {vm: windows-latest, exe: .cmd}]
6085
runs-on: ${{ matrix.os.vm }}
6186
steps:
87+
# Check out the code
6288
- uses: actions/checkout@v4
6389
with:
6490
ref: ${{ inputs.target-branch }}
65-
- run: smoke-tests/smoke-test${{ matrix.os.exe }} sf
91+
# Set up Node and Java
92+
- uses: actions/setup-node@v4
93+
with:
94+
node-version: ${{ matrix.node.version }}
95+
- uses: actions/setup-java@v4
96+
with:
97+
distribution: 'temurin'
98+
java-version: '11'
99+
# Install SF CLI via NPM
100+
- run: npm install -g @salesforce/cli
101+
# Download and install the Tarball artifact
102+
- uses: actions/download-artifact@v4
103+
id: download
104+
with:
105+
name: smoke-test-tarball
106+
# Download the tarball to a subdirectory of HOME, to guarantee that it's somewhere the installation command
107+
# can see
108+
path: ~/downloads/tarball
109+
- name: Echo tarball download location
110+
run: echo ${{ steps.download.outputs.download-path }}
111+
- name: Install Tarball
112+
shell: bash
113+
run: |
114+
# We need to determine the Tarball's name first.
115+
TARBALL_NAME=$(ls ~/downloads/tarball | grep salesforce-plugin-code-analyzer-5\\.0\\.0-alpha\\.[0-9]*\\.tgz)
116+
# We need to determine the Tarball's location in an installable way.
117+
# Get the path to the download folder. Swap out backslashes for forward slashes to ensure Windows compatibility.
118+
RAW_TARBALL_PATH=`echo '${{ steps.download.outputs.download-path }}' | tr '\\' '/'`
119+
# If the path starts with "C:", that needs to be pulled off.
120+
ADJUSTED_TARBALL_PATH=`[[ $RAW_TARBALL_PATH = C* ]] && echo $RAW_TARBALL_PATH | cut -d':' -f 2 || echo $RAW_TARBALL_PATH`
121+
# Install the tarball, piping in a `y` to simulate agreeing to install an unsigned package. Use the URI of the file's full path.
122+
echo y | sf plugins install "file://${ADJUSTED_TARBALL_PATH}/${TARBALL_NAME}"
123+
- name: Run smoke tests
124+
run: smoke-tests/smoke-test${{ matrix.os.exe }} sf
125+
- uses: actions/upload-artifact@v4
126+
if: ${{always()}}
127+
with:
128+
name: smoke-test-results-${{ runner.os }}-node-${{ matrix.node.artifact }}
129+
path: smoke-test-results
66130

.images/vscodeScreenshot.png

-364 KB
Binary file not shown.

messages/action-summary-viewer.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# common.summary-header
2+
3+
Summary
4+
5+
# common.logfile-location
6+
7+
Additional log information written to:
8+
9+
# config-action.no-outfiles
10+
11+
No output file was specified.
12+
13+
# config-action.outfile-location
14+
15+
Configuration written to:

messages/config-model.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ Empty object used because rule selection returned no rules
1212

1313
# template.yaml.no-rules-selected
1414
Remove this empty object {} when you are ready to specify your first rule override
15+
16+
# template.common.end-of-config
17+
END OF CODE ANALYZER CONFIGURATION

messages/config-writer.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# error.unrecognized-file-format
22

33
The output file %s has an unsupported extension. Valid extensions include: .yaml/.yml.
4+
5+
# prompt.overwrite-existing-file
6+
7+
A file named %s already exists. Do you want to overwrite it?
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# selection-spinner.action
22
Selecting rules
33

4-
# selection-spinner.status
4+
# selection-spinner.in-progress-status
55
Eligible engines: %s; Completion: %d%; Elapsed time: %ds
66

7+
# selection-spinner.finished-status
8+
done. Selected rules from %s.
9+
710
# execution-spinner.action
811
Executing rules
912

@@ -13,6 +16,5 @@ Executing rules
1316
# execution-spinner.engine-status
1417
- %s at %d% completion.
1518

16-
# base-spinner.done
17-
done
18-
19+
# execution-spinner.finished-status
20+
done. Executed rules from %s.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
22
"name": "@salesforce/plugin-code-analyzer",
33
"description": "Static code scanner that applies quality and security rules to Apex code, and provides feedback.",
4-
"version": "5.0.0-alpha.2",
4+
"version": "5.0.0-alpha.3",
55
"author": "Salesforce Code Analyzer Team",
66
"bugs": "https://github.com/forcedotcom/sfdx-scanner/issues",
77
"dependencies": {
88
"@oclif/core": "^3.3.2",
9-
"@salesforce/code-analyzer-core": "^0.13.2",
10-
"@salesforce/code-analyzer-engine-api": "0.10.0",
11-
"@salesforce/code-analyzer-eslint-engine": "0.10.0",
12-
"@salesforce/code-analyzer-pmd-engine": "0.10.1",
13-
"@salesforce/code-analyzer-regex-engine": "0.10.0",
14-
"@salesforce/code-analyzer-retirejs-engine": "0.10.0",
9+
"@salesforce/code-analyzer-core": "0.14.1",
10+
"@salesforce/code-analyzer-engine-api": "0.11.1",
11+
"@salesforce/code-analyzer-eslint-engine": "0.11.1",
12+
"@salesforce/code-analyzer-pmd-engine": "0.11.1",
13+
"@salesforce/code-analyzer-regex-engine": "0.11.1",
14+
"@salesforce/code-analyzer-retirejs-engine": "0.11.1",
1515
"@salesforce/core": "^5",
1616
"@salesforce/sf-plugins-core": "^5.0.4",
1717
"@salesforce/ts-types": "^2.0.9",

smoke-tests/smoke-test-generator.js

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const fs = require('fs');
2+
const path = require('path');
23

34
console.log('Switching to smoke test directory');
45
process.chdir(__dirname);
@@ -13,7 +14,7 @@ function generateScriptHeader(isBash) {
1314

1415
// All scripts should start with the same boilerplate disclaimer.
1516
header += `${cmt} Auto-generated on ${new Date(Date.now()).toDateString()}
16-
${cmt} This script WILL EVENTUALLY run a smoke test of the entire plugin by running a series of commands that collectively
17+
${cmt} This script performs a smoke test of the entire plugin by running a series of commands that collectively
1718
${cmt} hit a vertical slice of all major features. If they all succeed, then we can reasonably assume that the plugin is
1819
${cmt} approximately stable.
1920
${cmt} DO NOT EDIT THIS SCRIPT DIRECTLY! INSTEAD, MAKE CHANGES IN ./smoke-tests/smoke-test-generator.js AND RERUN THAT
@@ -31,11 +32,87 @@ ${cmt} SCRIPT FROM THE PROJECT ROOT!\n`;
3132
}
3233

3334
function generateScriptBody(isBash, delim) {
35+
const exeName = isBash ? '$EXE_NAME' : '%EXE_NAME%';
36+
37+
3438
const commands = [
35-
// Log an explainer that since we're in the Alpha stage, we don't have a fully fleshed out smoke test.
36-
`echo "At this point in the alpha, the smoke tests are no-ops and it is fine."`
37-
]
39+
// Log a header.
40+
`echo "====== SETUP FOR SMOKE TESTS ======"`,
41+
// Delete the smoke test result directory if it already exists
42+
`echo "====== Delete a a pre-existing smoke-test-results directory ======"`,
43+
isBash ? 'rm -rf smoke-test-results' : 'if exist smoke-test-results rmdir /s /q smoke-test-results || exit /b 1',
44+
// Create the output directory
45+
`echo "====== Create smoke-test-results directory ======"`,
46+
isBash ? 'mkdir -p smoke-test-results' : 'if not exist smoke-test-results mkdir smoke-test-results || exit /b 1',
47+
`\n`,
48+
`echo "====== SMOKE TESTS FOR CONFIG COMMAND ======"`,
49+
// Show the default configuration for all engines
50+
`echo "====== Show default config for all engines ======"`,
51+
`${exeName} code-analyzer config`,
52+
// Show the default configuration for only one engine
53+
`echo "====== Show default config for PMD only ======"`,
54+
`${exeName} code-analyzer config -r pmd`,
55+
// Write the default config for PMD to a file
56+
`echo "====== Write PMD's default config to a file ======"`,
57+
`${exeName} code-analyzer config -r pmd -f ${path.join('.', 'smoke-test-results', 'pmd-only-config.yml')}`,
58+
// Show the configuration from the config file we just created
59+
`echo "====== Show configuration from last step's output file ======"`,
60+
`${exeName} code-analyzer config -c ${path.join('.', 'smoke-test-results', 'pmd-only-config.yml')}`,
61+
`echo "====== Show configuration from pre-existing config file ======"`,
62+
`${exeName} code-analyzer config -c ${path.join('.', 'smoke-tests', 'test-data', 'config-files', 'existing-config.yml')}`,
63+
`\n`,
64+
`echo "====== SMOKE TESTS FOR RULES COMMAND ======"`,
65+
// List all rules
66+
`echo "====== List all rules ======"`,
67+
`${exeName} code-analyzer rules`,
68+
// List only rules from ESLint
69+
`echo "====== List ESLint rules only ======"`,
70+
`${exeName} code-analyzer rules -r eslint`,
71+
// List only rules from RetireJS
72+
`echo "====== List RetireJS rules only ======"`,
73+
`${exeName} code-analyzer rules -r retire-js`,
74+
// List only rules that are relevant to a provided workspace
75+
`echo "====== List rules relevant to apex-only workspace ======"`,
76+
`${exeName} code-analyzer rules -w ${path.join('.', 'smoke-tests', 'test-data', 'workspace-with-apex-files')}`,
77+
// List only rules that match nonsensical selector (i.e., list no rules)
78+
`echo "====== List rules matching a nonsensical selector (i.e. list no rules) ======"`,
79+
`${exeName} code-analyzer rules -r asdfasdfasdf`,
80+
// List one rule using a config with overrides
81+
`echo "====== List rule overridden in config file ======"`,
82+
`${exeName} code-analyzer rules -r no-unsafe-assignment -c ${path.join('.', 'smoke-tests', 'test-data', 'config-files', 'existing-config.yml')}`,
83+
'\n',
84+
`echo "====== SMOKE TESTS FOR RUN COMMAND ======"`,
85+
// Run all rules against a folder
86+
`echo "====== Run all rules against a folder ======"`,
87+
`${exeName} code-analyzer run -w ${path.join('.', 'smoke-tests', 'test-data', 'workspace-with-mixed-files')}`,
88+
// Run all rules against a file
89+
`echo "====== Run all rules against a file ======"`,
90+
`${exeName} code-analyzer run -w ${path.join('.', 'smoke-tests', 'test-data', 'workspace-with-mixed-files', 'my-script.ts')}`,
91+
// Run all rules against a folder and write the output to some files
92+
`echo "====== Run all rules against a folder and write to outfiles ======"`,
93+
`${exeName} code-analyzer run -w ${path.join('.', 'smoke-tests', 'test-data', 'workspace-with-apex-files')} -f ${path.join('.', 'smoke-test-results', 'outfile.json')} -f ${path.join('.', 'smoke-test-results', 'outfile.html')}`,
94+
// Run a selection of rules against a folder
95+
`echo "====== Run a selection of rules against a folder ======"`,
96+
`${exeName} code-analyzer run -r regex -w ${path.join('.', 'smoke-tests', 'test-data', 'workspace-with-mixed-files')}`,
97+
// Run rules using a config file with overrides
98+
`echo "====== Run rules using a config file with overrides ======"`,
99+
`${exeName} code-analyzer run -c ${path.join('.', 'smoke-tests', 'test-data', 'config-files', 'existing-config.yml')} -w ${path.join('.', 'smoke-tests', 'test-data', 'workspace-with-mixed-files')}`,
100+
'\n',
101+
`echo "====== CONCLUSION ======"`,
102+
`echo "If you are seeing this message, the smoke tests ran successfully, and all is (approximately) well"`
103+
];
104+
105+
// In a cmd script, you need to prepend plugin commands with "call" in order to make sure that the script continues,
106+
// and you need to postfix it with another snippet to make it actually exist when an error is encountered.
107+
if (!isBash) {
108+
for (let i = 0; i < commands.length; i++) {
109+
if (commands[i].startsWith(exeName)) {
110+
commands[i] = `call ${commands[i]} || exit /b 1`
111+
}
112+
}
113+
}
38114

115+
// Combine the commands and return the script body.
39116
return commands.join('\n');
40117
}
41118

smoke-tests/smoke-test.cmd

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,58 @@
11
@echo off
2-
REM Auto-generated on Tue Aug 27 2024
3-
REM This script WILL EVENTUALLY run a smoke test of the entire plugin by running a series of commands that collectively
2+
REM Auto-generated on Fri Oct 18 2024
3+
REM This script performs a smoke test of the entire plugin by running a series of commands that collectively
44
REM hit a vertical slice of all major features. If they all succeed, then we can reasonably assume that the plugin is
55
REM approximately stable.
66
REM DO NOT EDIT THIS SCRIPT DIRECTLY! INSTEAD, MAKE CHANGES IN ./smoke-tests/smoke-test-generator.js AND RERUN THAT
77
REM SCRIPT FROM THE PROJECT ROOT!
88
SET EXE_NAME=%1
9-
echo "At this point in the alpha, the smoke tests are no-ops and it is fine."
9+
echo "====== SETUP FOR SMOKE TESTS ======"
10+
echo "====== Delete a a pre-existing smoke-test-results directory ======"
11+
if exist smoke-test-results rmdir /s /q smoke-test-results || exit /b 1
12+
echo "====== Create smoke-test-results directory ======"
13+
if not exist smoke-test-results mkdir smoke-test-results || exit /b 1
14+
15+
16+
echo "====== SMOKE TESTS FOR CONFIG COMMAND ======"
17+
echo "====== Show default config for all engines ======"
18+
call %EXE_NAME% code-analyzer config || exit /b 1
19+
echo "====== Show default config for PMD only ======"
20+
call %EXE_NAME% code-analyzer config -r pmd || exit /b 1
21+
echo "====== Write PMD's default config to a file ======"
22+
call %EXE_NAME% code-analyzer config -r pmd -f smoke-test-results/pmd-only-config.yml || exit /b 1
23+
echo "====== Show configuration from last step's output file ======"
24+
call %EXE_NAME% code-analyzer config -c smoke-test-results/pmd-only-config.yml || exit /b 1
25+
echo "====== Show configuration from pre-existing config file ======"
26+
call %EXE_NAME% code-analyzer config -c smoke-tests/test-data/config-files/existing-config.yml || exit /b 1
27+
28+
29+
echo "====== SMOKE TESTS FOR RULES COMMAND ======"
30+
echo "====== List all rules ======"
31+
call %EXE_NAME% code-analyzer rules || exit /b 1
32+
echo "====== List ESLint rules only ======"
33+
call %EXE_NAME% code-analyzer rules -r eslint || exit /b 1
34+
echo "====== List RetireJS rules only ======"
35+
call %EXE_NAME% code-analyzer rules -r retire-js || exit /b 1
36+
echo "====== List rules relevant to apex-only workspace ======"
37+
call %EXE_NAME% code-analyzer rules -w smoke-tests/test-data/workspace-with-apex-files || exit /b 1
38+
echo "====== List rules matching a nonsensical selector (i.e. list no rules) ======"
39+
call %EXE_NAME% code-analyzer rules -r asdfasdfasdf || exit /b 1
40+
echo "====== List rule overridden in config file ======"
41+
call %EXE_NAME% code-analyzer rules -r no-unsafe-assignment -c smoke-tests/test-data/config-files/existing-config.yml || exit /b 1
42+
43+
44+
echo "====== SMOKE TESTS FOR RUN COMMAND ======"
45+
echo "====== Run all rules against a folder ======"
46+
call %EXE_NAME% code-analyzer run -w smoke-tests/test-data/workspace-with-mixed-files || exit /b 1
47+
echo "====== Run all rules against a file ======"
48+
call %EXE_NAME% code-analyzer run -w smoke-tests/test-data/workspace-with-mixed-files/my-script.ts || exit /b 1
49+
echo "====== Run all rules against a folder and write to outfiles ======"
50+
call %EXE_NAME% code-analyzer run -w smoke-tests/test-data/workspace-with-apex-files -f smoke-test-results/outfile.json -f smoke-test-results/outfile.html || exit /b 1
51+
echo "====== Run a selection of rules against a folder ======"
52+
call %EXE_NAME% code-analyzer run -r regex -w smoke-tests/test-data/workspace-with-mixed-files || exit /b 1
53+
echo "====== Run rules using a config file with overrides ======"
54+
call %EXE_NAME% code-analyzer run -c smoke-tests/test-data/config-files/existing-config.yml -w smoke-tests/test-data/workspace-with-mixed-files || exit /b 1
55+
56+
57+
echo "====== CONCLUSION ======"
58+
echo "If you are seeing this message, the smoke tests ran successfully, and all is (approximately) well"

0 commit comments

Comments
 (0)