Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Experimental] Enable git hooks for code validation and setup test suite #1171

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5466923
Add eslint jest plugin with conf that enforces good testing practices
lambdaclan Mar 29, 2021
714c8f4
Add eslint cache to gitignore
lambdaclan Mar 29, 2021
3cbda1f
Change trailing comma option from false to none (updated option)
lambdaclan Mar 29, 2021
b05b78a
Add/update dependencies needed to use Jest test framework with Vue
lambdaclan Mar 29, 2021
5ca9212
Add vue testing library for component testing and custom jest matchers
lambdaclan Mar 29, 2021
8acd560
Add spectron for e2e testing and lint-staged for git hook management
lambdaclan Mar 29, 2021
99eaeee
Add/update npm scripts with regards to testing, linting and formatting
lambdaclan Mar 29, 2021
2167107
Add modified package-lock.json
lambdaclan Mar 29, 2021
92f8247
Add jest configuration file
lambdaclan Mar 29, 2021
5a2673d
Add lint-staged configuration file with the hook lint and format tasks
lambdaclan Mar 29, 2021
bce8958
Add pre-commit (lint & format) and pre-push (tests) hook config
lambdaclan Mar 29, 2021
0f2a397
Change prettier local (git modified files) from shell script to npm lib
lambdaclan Mar 29, 2021
f978177
Format and add attributes to facilitate testing
lambdaclan Mar 29, 2021
8faa724
Add setup configuration for test suite
lambdaclan Mar 29, 2021
af47373
Add sample e2e test for main window during application launch
lambdaclan Mar 29, 2021
78b8915
Add sample component test for channel bubbles
lambdaclan Mar 29, 2021
250a61c
Add pretty quick for staged file formatting on demand
lambdaclan Mar 29, 2021
cdd3430
Add formatting via prettier CI workflow
lambdaclan Mar 29, 2021
9df2d01
Add testing via jest CI workflow
lambdaclan Mar 29, 2021
647d286
Change lockfile version back to 1
lambdaclan Apr 2, 2021
f101d5e
Remove prepare script since simple hooks has post install setup script
lambdaclan Apr 2, 2021
fb22a16
Use test and jest scripts interchangeably and display only relevant info
lambdaclan Apr 5, 2021
1604774
Use test script instead of jest for git push hook
lambdaclan Apr 5, 2021
5439a90
Update simple git hooks library
lambdaclan Apr 5, 2021
38552c8
Add import order checks to eslint
lambdaclan Apr 5, 2021
ac8bbe8
Enable headless test running for e2e tests via xvfb
lambdaclan Apr 6, 2021
cd69767
Consolidate linting, formatting and testing into a single workflow
lambdaclan Apr 6, 2021
3e80862
switch from "npm ci
ChunkyProgrammer Sep 25, 2021
cdade33
Resolve merge conflicts
ChunkyProgrammer Sep 25, 2021
7ee1c83
delete package-lock.json
ChunkyProgrammer Sep 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions .eslintrc.js
Expand Up @@ -25,11 +25,12 @@ module.exports = {
'prettier',
'eslint:recommended',
'plugin:vue/recommended',
'plugin:jest/recommended',
'standard'
],

// https://eslint.org/docs/user-guide/configuring#configuring-plugins
plugins: ['vue'],
plugins: ['vue', 'jest', 'simple-import-sort', 'import'],

rules: {
'space-before-function-paren': 0,
Expand All @@ -38,6 +39,11 @@ module.exports = {
'no-console': 0,
'no-unused-vars': 1,
'no-undef': 1,
'vue/no-template-key': 1
'vue/no-template-key': 1,
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-duplicates': 'error'
}
}
133 changes: 133 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,133 @@
name: ci

on:
pull_request:
branches:
- master
- development

env:
NODE_VERSIONS: [12.x]
ChunkyProgrammer marked this conversation as resolved.
Show resolved Hide resolved

jobs:
lint:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: ${{ env.NODE_VERSIONS }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json', '**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Node ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm ci
ChunkyProgrammer marked this conversation as resolved.
Show resolved Hide resolved

- name: Execute eslint checks
run: npm run lint

format:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: ${{ env.NODE_VERSIONS }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json', '**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Node ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm ci
ChunkyProgrammer marked this conversation as resolved.
Show resolved Hide resolved

- name: Execute prettier checks
run: npm run prettier

unittests:
runs-on: ubuntu-18.04
needs: [lint, format]

strategy:
matrix:
node-version: ${{ env.NODE_VERSIONS }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json', '**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Node ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm ci
ChunkyProgrammer marked this conversation as resolved.
Show resolved Hide resolved

- name: Execute unit tests
run: npm run test:unit

e2e:
runs-on: ubuntu-latest
needs: [lint, format, unittests]

strategy:
matrix:
node-version: ${{ env.NODE_VERSIONS }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json', '**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Node ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm ci
ChunkyProgrammer marked this conversation as resolved.
Show resolved Hide resolved

- name: Execute e2e tests
run: npm run test:e2e-headless
26 changes: 0 additions & 26 deletions .github/workflows/linter.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -15,6 +15,7 @@ data/tmp/
.tmp/
tmp/
.cache
.eslintcache
dist
coverage
__coverage__
Expand Down
4 changes: 4 additions & 0 deletions .lintstagedrc.json
@@ -0,0 +1,4 @@
{
"*.{js,ts,vue}": "eslint --cache",
"{src,_scripts}/**/*.{js,ts,vue}": "prettier --check"
}
2 changes: 1 addition & 1 deletion .prettierrc
Expand Up @@ -2,6 +2,6 @@
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": false,
"trailingComma": none,
"useTabs": false
}
4 changes: 4 additions & 0 deletions .simple-git-hooks.json
@@ -0,0 +1,4 @@
{
"pre-commit": "npx lint-staged",
"pre-push": "npm run test"
}
15 changes: 15 additions & 0 deletions jest.config.js
@@ -0,0 +1,15 @@
module.exports = {
verbose: true,
setupFiles: ['./tests/setup.js'],
moduleFileExtensions: ['js', 'json', 'vue'],
transform: {
'.*\\.(vue)$': 'vue-jest',
'^.+\\.js$': 'babel-jest'
},
collectCoverage: true,
collectCoverageFrom: [
'src/renderer/components/**/*.{js,ts,vue}',
'!**/node_modules/**'
],
coverageReporters: ['html', 'text-summary']
}