Skip to content

Commit

Permalink
feat: talisman, coverage, cypress (#12)
Browse files Browse the repository at this point in the history
* feat: add talisman and husky config

* feat: add coverage

* chore: cleanup

* feat: add cypress

* chore: add codecov

* feat: pre-commits workarounds (#13)

* feat: wip make pre-commit works with any git tool

* chore: revert

* fix: repare commit lint pre-hook

* fix: workaround tty not found

* chore: re-order pre-commit

---------

Co-authored-by: David Dela Cruz <david.dela.cruz@beta.gouv.fr>
Co-authored-by: Antoine Bigard <bigard.antoine@gmail.com>
  • Loading branch information
3 people authored Mar 27, 2023
1 parent d686e63 commit 3cd5d01
Show file tree
Hide file tree
Showing 15 changed files with 916 additions and 228 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/yarn-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@ jobs:
${{ runner.os }}-
- run: make ci

- run: make coverage

- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

[[ -n $HUSKY_BYPASS ]] || ./node_modules/.bin/commitlint --config ./.husky/commitlint.config.js --edit "$1"
File renamed without changes.
6 changes: 6 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged
./git-hooks/preventSensibleFilesCommit.sh
yarn node-talisman --githook pre-commit
5 changes: 5 additions & 0 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scopeconfig:
- scope: node
custom_patterns:
- (?s)[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}
version: "1.0"
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ lint:
test:
yarn --cwd server test

coverage:
yarn --cwd server test:coverage

clean:
docker-compose kill && docker system prune --force --volumes

Expand Down
6 changes: 6 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from "cypress";
export default defineConfig({
e2e: {
supportFile: false,
},
});
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
22 changes: 22 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
20 changes: 20 additions & 0 deletions cypress/support/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import "./commands";

// Alternatively you can use CommonJS syntax:
// require('./commands')
9 changes: 9 additions & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"noEmit": true,
"isolatedModules": false,
"types": ["cypress"]
},
"include": ["../node_modules/cypress", "./**/*.ts"],
"exclude": ["node_modules"]
}
2 changes: 1 addition & 1 deletion git-hooks/preventSensibleFilesCommit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# A hook script to verify that we don't commit files that could contain sensible data or credentials like json, csv, xls(x) or .env

sensible_files_pattern="\.(csv|xls|xls(x?)|json|env)$"
exception="(package.json|custom-environment-variables.json"
exception="(package.json|custom-environment-variables.json|example.json"
exception="$exception|manifest.json|settings.json|zapatosconfig.json"
exception="$exception|sample.json"
exception="$exception|eslintrc.json|app.json|tsconfig.json"
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,26 @@
"prettier:fix": "prettier --write ./ui ./server",
"prettier:check": "prettier --check ./ui ./server",
"npm:release": "semantic-release",
"npm:release:local": "CI=true LOCAL_RELEASE=true semantic-release"
"npm:release:local": "CI=true LOCAL_RELEASE=true semantic-release",
"prepare": "husky install",
"talisman:add-exception": "yarn node-talisman --githook pre-commit -i",
"e2e": "cypress open",
"e2e:headless": "cypress run"
},
"workspaces": [
"ui",
"server",
"shared"
],
"devDependencies": {
"@commitlint/cli": "16.2.4",
"@commitlint/config-conventional": "16.2.4",
"@commitlint/cli": "^17.5.0",
"@commitlint/config-conventional": "^17.4.4",
"@semantic-release/changelog": "6.0.1",
"@semantic-release/exec": "6.0.3",
"@semantic-release/git": "10.0.1",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0",
"cypress": "^12.8.1",
"eslint": "8.25.0",
"eslint-config-next": "13.0.1",
"eslint-import-resolver-typescript": "^3.5.2",
Expand All @@ -41,8 +46,9 @@
"eslint-plugin-node": "11.1.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
"husky": "4.3.8",
"husky": "^8.0.3",
"lint-staged": "11.2.6",
"node-talisman": "^1.29.9",
"prettier": "2.7.1",
"semantic-release": "19.0.2",
"semantic-release-slack-bot": "3.5.2",
Expand All @@ -54,12 +60,6 @@
"trailingComma": "es5",
"arrowParens": "always"
},
"husky": {
"hooks": {
"pre-commit": "./git-hooks/preventSensibleFilesCommit.sh && lint-staged",
"commit-msg": "[[ -n $HUSKY_BYPASS ]] || commitlint --config ./config/commitlint.config.js -E HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"*.{ts,js,tsx}": [
"eslint .",
Expand Down
3 changes: 2 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"cli": "ts-node -T src/modules/data/cli.ts ",
"cli-docker": "docker exec -it bal_server yarn cli",
"test": "yarn test:cmd 'tests/**/*.test.ts'",
"test:coverage": "c8 --check-coverage yarn test",
"test:coverage": "c8 --reporter lcov --reporter text yarn test",
"test:cmd": "cross-env NODE_ENV=test DOTENV_CONFIG_PATH=.env.test ts-mocha -n loader=ts-node/esm"
},
"dependencies": {
Expand Down Expand Up @@ -59,6 +59,7 @@
"@types/luxon": "^3.2.0",
"@types/mocha": "^10.0.1",
"@types/omit-deep": "^0.3.0",
"c8": "^7.13.0",
"chalk": "4.1.2",
"cross-env": "^7.0.3",
"mocha": "^10.2.0",
Expand Down
Loading

0 comments on commit 3cd5d01

Please sign in to comment.