Skip to content

Commit

Permalink
ci: add performance testing (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
scolladon committed Jul 24, 2023
1 parent 9926c08 commit 0f8a869
Show file tree
Hide file tree
Showing 22 changed files with 2,150 additions and 2,197 deletions.
8 changes: 8 additions & 0 deletions .depcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ignores: [
'@commitlint/*',
'@salesforce/*',
'@stryker-mutator/*',
'lint-staged',
'chai',
'sinon',
]
9 changes: 8 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ Happy linting! 💖
*/
module.exports = {
extends: ['eslint:recommended', 'plugin:prettier/recommended', 'prettier'],
ignorePatterns: ['lib/**/*', 'node_modules', '.next', 'output', 'reports'],
ignorePatterns: [
'lib/**/*',
'node_modules',
'.next',
'output',
'reports',
'e2e',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
Expand Down
3 changes: 1 addition & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# These are supported funding model platforms

---
github: [scolladon]
4 changes: 2 additions & 2 deletions .github/linters/.cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"Cherfaoui",
"Colladon",
"Commitlint",
"Corepack",
"corepack",
"depcheckrc",
"FORCEIGNORE",
"FORCEINCLUDE",
"FULLNAME",
Expand Down Expand Up @@ -48,6 +47,7 @@
"authprovider",
"authproviders",
"behaviour",
"benchmarkjs",
"brqh",
"codeclimate",
"codecov",
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/on-main-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,68 @@ jobs:
run: |
yarn
yarn test:e2e
perf:
needs: prepare-release
runs-on: ubuntu-latest
if: needs.prepare-release.outputs.release_created != 'true'
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "yarn-cache=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
shell: bash

- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.yarn-cache }}
key: ${{ runner.os }}-16-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn install --immutable --check-cache

- name: Build plugin
run: yarn pack

- name: Install sfdx-cli
run: npm install -g sfdx-cli

- name: Install plugin
run: |
yarn set version classic
sfdx plugins:link .
sfdx plugins
- name: Checkout e2e sources
uses: actions/checkout@v3
with:
ref: 'e2e/head'
fetch-depth: 0
path: ./e2e

- name: Run benchmark
run: |
git config --local core.hooksPath /dev/null
git checkout -f main
yarn test:perf
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: Benchmark.js Benchmark
tool: 'benchmarkjs'
output-file-path: ./perf-result.txt
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
alert-threshold: '130%'
comment-on-alert: true
fail-on-alert: true
summary-always: true
alert-comment-cc-users: '@scolladon'
2 changes: 1 addition & 1 deletion .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ jobs:

- name: Check unused dependencies
run: yarn lint:dependencies
continue-on-error: true

- name: Audit dependencies
run: yarn npm audit
Expand Down Expand Up @@ -112,6 +111,7 @@ jobs:
uses: ./.github/actions/install

- name: Build plugin

run: yarn pack

- name: Mutation test
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
uses: ./.github/actions/install

- name: Build plugin

run: yarn pack

- name: Unit test
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/e2e
/node_modules
/reports
/lib
Expand All @@ -10,6 +11,7 @@ sfdx-git-delta-*.tgz
package.tgz
stderr*.txt
stdout*.txt
perf-result.txt
# stryker temp files
.stryker-tmp

Expand Down
3 changes: 3 additions & 0 deletions .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

git diff HEAD^ HEAD --exit-code -- ./yarn.lock || yarn
3 changes: 3 additions & 0 deletions .husky/post-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

git diff HEAD^ HEAD --exit-code -- ./yarn.lock || yarn
3 changes: 3 additions & 0 deletions .husky/post-rewrite
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

git diff HEAD^ HEAD --exit-code -- ./yarn.lock || yarn
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ yarn lint
yarn pack
yarn test:unit:coverage
yarn test:nut
yarn analysis force-app
yarn analysis src
npm outdated || true
yarn npm audit || true
yarn lint:dependencies || true
4 changes: 0 additions & 4 deletions .knip.json

This file was deleted.

403 changes: 202 additions & 201 deletions .yarn/releases/yarn-3.5.1.cjs → .yarn/releases/yarn-3.6.0.cjs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
nodeLinker: node-modules

npmPublishRegistry: "https://registry.npmjs.org/"

npmRegistryServer: "https://registry.npmjs.org/"

yarnPath: .yarn/releases/yarn-3.5.1.cjs
yarnPath: .yarn/releases/yarn-3.6.0.cjs
18 changes: 18 additions & 0 deletions __tests__/perf/bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'
const { execCmd } = require('@salesforce/cli-plugins-testkit')
const Benchmark = require('benchmark')
const suite = new Benchmark.Suite()

suite
.add('e2e-test', () => {
execCmd(
'sgd:source:delta --from "origin/e2e/base" --to "origin/e2e/head" --output e2e/expected --generate-delta --repo e2e',
{
ensureExitCode: 0,
}
)
})
.on('cycle', event => {
console.log(String(event.target))
})
.run()
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ module.exports = {
'/node_modules/',
'/__tests__/__utils__/',
'/reports/',
'/e2e',
],

// The regexp pattern or array of patterns that Jest uses to detect test files
Expand Down
50 changes: 25 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"author": "Sebastien Colladon <colladonsebastien@gmail.com>",
"dependencies": {
"@salesforce/command": "^5.3.9",
"fast-xml-parser": "^4.2.4",
"fast-xml-parser": "^4.2.6",
"fs-extra": "^11.1.1",
"ignore": "^5.2.4",
"lodash": "^4.17.21",
Expand All @@ -40,16 +40,16 @@
"homepage": "https://github.com/scolladon/sfdx-git-delta#readme",
"scripts": {
"analysis": "codeclimate analyze",
"clean": "shx rm -rf lib 'reports/*' .nyc_output oclif.manifest.json package.tgz 'sfdx-git-delta-v*.tgz' 'stderr*.txt' 'stdout*.txt' '.stryker-tmp/*'",
"commit": "commit",
"clean": "shx rm -rf lib 'reports/*' .nyc_output oclif.manifest.json package.tgz 'sfdx-git-delta-v*.tgz' 'stderr*.txt' 'stdout*.txt' '.stryker-tmp/*' perf-result.txt",
"increment:apiversion": "bash ./tooling/incrementApiVersion.sh",
"lint": "eslint src/",
"lint:dependencies": "knip",
"lint:dependencies": "depcheck",
"lint:fix": "eslint --fix src/",
"test": "yarn test:unit && yarn test:nut",
"test:build:local": "yarn clean ; shx rm -rf .yarn/cache node_modules ; yarn && yarn pack && yarn test",
"test:mutation": "stryker run",
"test:nut": "nyc mocha **/*.nut.ts",
"test:perf": "node __tests__/perf/bench.js | tee perf-result.txt",
"test:unit": "jest",
"test:unit:clear:cache": "jest --clearCache",
"test:unit:coverage": "jest --coverage",
Expand All @@ -61,38 +61,38 @@
"prebuild": "yarn clean",
"prepack": "yarn build && oclif-dev manifest && oclif-dev readme",
"prepare": "husky install",
"upgrade:dependencies": "yarn-upgrade-all ; yarn-audit-fix"
"upgrade:dependencies": "shx rm -rf yarn.lock ; shx touch yarn.lock ; yarn-upgrade-all ; yarn-audit-fix"
},
"devDependencies": {
"@commitlint/cli": "^17.6.5",
"@commitlint/config-conventional": "^17.6.5",
"@commitlint/prompt-cli": "^17.6.5",
"@commitlint/cli": "^17.6.7",
"@commitlint/config-conventional": "^17.6.7",
"@oclif/dev-cli": "^1.26.10",
"@salesforce/cli-plugins-testkit": "^3.4.0",
"@salesforce/cli-plugins-testkit": "^4.2.7",
"@salesforce/dev-config": "^4.0.1",
"@salesforce/ts-sinon": "^1.4.7",
"@stryker-mutator/core": "^6.4.2",
"@stryker-mutator/jest-runner": "^6.4.2",
"@swc/core": "^1.3.61",
"@salesforce/ts-sinon": "^1.4.12",
"@stryker-mutator/core": "^7.1.1",
"@stryker-mutator/jest-runner": "^7.1.1",
"@swc/core": "^1.3.70",
"@types/mocha": "^10.0.1",
"@types/node": "^20.2.5",
"@typescript-eslint/parser": "^5.59.8",
"@types/node": "^20.4.4",
"@typescript-eslint/parser": "^6.1.0",
"benchmark": "^2.1.4",
"chai": "^4.3.7",
"eslint": "^8.41.0",
"depcheck": "^1.4.3",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-prettier": "^5.0.0",
"husky": "^8.0.3",
"jest": "^29.5.0",
"knip": "^2.13.0",
"lint-staged": "^13.2.2",
"jest": "^29.6.1",
"lint-staged": "^13.2.3",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"prettier": "^2.8.8",
"prettier": "^3.0.0",
"shx": "^0.3.4",
"sinon": "^15.1.0",
"sinon": "^15.2.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.4",
"yarn-audit-fix": "^9.3.10",
"typescript": "^5.1.6",
"yarn-audit-fix": "^9.3.12",
"yarn-upgrade-all": "^0.7.2"
},
"oclif": {
Expand All @@ -105,5 +105,5 @@
"publishConfig": {
"access": "public"
},
"packageManager": "yarn@3.5.1"
"packageManager": "yarn@3.6.0"
}
4 changes: 1 addition & 3 deletions stryker.conf.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// @ts-check
/** @type {import('@stryker-mutator/api/core').PartialStrykerOptions} */
const config = {
packageManager: 'yarn',
reporters: ['html', 'clear-text', 'progress'],
testRunner: 'jest',
coverageAnalysis: 'perTest',
ignoreStatic: true,
ignorePatterns: ['lib/', 'reports/', 'bin/'],
ignorePatterns: ['lib/', 'reports/', 'bin/', 'e2e'],
mutate: ['src/**/*.js'],
}
export default config
6 changes: 3 additions & 3 deletions tooling/incrementApiVersion.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

filename=`find src/metadata -type f -name "v*.json" | sort | tail -1`
version=`echo "$filename" | tr -d -c 0-9`
filename=$(find src/metadata -type f -name "v*.json" | sort | tail -1)
version=$(echo "$filename" | tr -d -c 0-9)
((version++))
targetname="src/metadata/v${version}.json"
\cp "$filename" "$targetname"
\cp "$filename" "$targetname"
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"outDir": "./lib",
"importHelpers": true,
"allowJs": true,
"resolveJsonModule": true
"resolveJsonModule": true,
"skipLibCheck": true
},
"include": [
"./src/**/*",
Expand Down
Loading

0 comments on commit 0f8a869

Please sign in to comment.