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 authored Jul 24, 2023
1 parent 9926c08 commit 3145e45
Show file tree
Hide file tree
Showing 17 changed files with 2,133 additions and 2,187 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',
]
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
68 changes: 68 additions & 0 deletions .github/workflows/on-main-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,71 @@ jobs:
run: |
yarn
yarn test:e2e
perf:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
path: ./plugin

- name: Checkout sources
uses: actions/checkout@v3
with:
ref: 'e2e/head'
fetch-depth: 0
path: ./sgd-e2e

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

- name: Get yarn cache directory path
working-directory: ./plugin
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
working-directory: ./plugin
run: yarn install --immutable --check-cache

- name: Build plugin
working-directory: ./plugin
run: yarn pack

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

- name: Install plugin
working-directory: ./plugin
run: |
yarn set version classic
sfdx plugins:link .
sfdx plugins
- name: Run benchmark
working-directory: ./plugin
run: yarn test:perf

- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: Benchmark.js Benchmark
tool: 'benchmarkjs'
output-file-path: ./plugin/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
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.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ 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 ../sgd-e2e/expected --generate-delta --repo ../sgd-e2e',
{
ensureExitCode: 0,
}
)
})
.on('cycle', event => {
console.log(String(event.target))
})
.run()
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 <[email protected]>",
"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.6",
"@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.2",
"@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"
}
2 changes: 0 additions & 2 deletions stryker.conf.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-check
/** @type {import('@stryker-mutator/api/core').PartialStrykerOptions} */
const config = {
packageManager: 'yarn',
reporters: ['html', 'clear-text', 'progress'],
Expand Down
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 3145e45

Please sign in to comment.