Skip to content

Commit

Permalink
Setup Test Framework (#50)
Browse files Browse the repository at this point in the history
- Setup testing using `wdio-vscode-service`, with coverage via istanbul
- Add CI badges

Includes some additional linting/style revisions of the source code.
  • Loading branch information
haberdashPI authored Sep 15, 2024
1 parent 21d57bf commit 386a933
Show file tree
Hide file tree
Showing 24 changed files with 13,866 additions and 3,868 deletions.
135 changes: 80 additions & 55 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,62 +1,87 @@
{
"extends": "./node_modules/gts/",
"rules": {
"indent": 4,
"extends": "./node_modules/gts/",
"rules": {
// "max-len": [
// "error",
// {
// "code": 92,
// "tabWidth": 4
// }
// ],
// Google Style doesn't allow `_` to denote unused variables; here I make an
// exception, as I find this a super useful option
"@typescript-eslint/no-unused-vars": [
"error",
{
"args": "all",
"argsIgnorePattern": "^_",
"caughtErrors": "all",
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"ignoreRestSiblings": true
}
// TODO: there are likely some other overrides to use here but we'll wait to copy
// those over from Master Key when we find issues
],

"n/no-unpublished-require": [
"error",
"error",
{
"args": "all",
"argsIgnorePattern": "^_",
"caughtErrors": "all",
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"ignoreRestSiblings": true
}
// TODO: there are likely some other overrides to use here but we'll wait to copy
// those over from Master Key when we find issues
],
"n/no-unpublished-require": [
"error",
{
"allowModules": [
"webpack"
]
}
],
"n/no-unpublished-import": [
"error",
{
"allowModules": [
"lodash",
"wdio-vscode-service"
]
}
],
"n/no-extraneous-import": [
"error",
{
"allowModules": ["vscode-uri", "@wdio/globals", "webdriverio", "@wdio/types"]
}
]
},
"overrides": [
{
"allowModules": ["webpack"]
// GTS doesn't allow for *.mts files, but they will be part of testing
"files": [
"**/*.mts"
],
"parser": "@typescript-eslint/parser",
"extends": [
"plugin:@typescript-eslint/recommended"
],
"rules": {
// copied from gts eslintrc.json
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-warning-comments": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/camelcase": "off",
"n/no-missing-import": "off",
"n/no-empty-function": "off",
"n/no-unsupported-features/es-syntax": "off",
"n/no-missing-require": "off",
"n/shebang": "off",
"no-dupe-class-members": "off",
"require-atomic-updates": "off"
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
}
}
]
},
"overrides": [{
// GTS doesn't allow for *.mts files, but they will be part of testing
"files": ["**/*.mts"],
"parser": "@typescript-eslint/parser",
"extends": [
"plugin:@typescript-eslint/recommended"
],
"rules": {
// copied from gts eslintrc.json
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-warning-comments": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/camelcase": "off",
"n/no-missing-import": "off",
"n/no-empty-function": "off",
"n/no-unsupported-features/es-syntax": "off",
"n/no-missing-require": "off",
"n/shebang": "off",
"no-dupe-class-members": "off",
"require-atomic-updates": "off"
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
}
}]

]
}
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI
on:
push:
branches:
- main
tags:
- v[0-9]+.[0-9]+.[0-9]+*
pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize', 'ready_for_review']
workflow_dispatch:
inputs:
node_version:
description: 'Node.js version'
required: true
default: '20'
type: choice
options:
- 18
- 20

jobs:
build:
if: '! github.event.pull_request.draft'
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node_version || 20 }}
- name: Install Dependencies
run: npm ci
env:
DETECT_CHROMEDRIVER_VERSION: true
- name: Run Tests
uses: coactions/setup-xvfb@v1
with:
run: npm run ci
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
54 changes: 0 additions & 54 deletions .github/workflows/generate-docs.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ dist/*
.DS_Store
.cache/
.parcel-cache
wdio.conf.mts
.wdio-vscode-service
wdio.log
coverage/**
4 changes: 3 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module.exports = {
...require('gts/.prettierrc.json')
...require('gts/.prettierrc.json'),
"tabWidth": 4,
"printWidth": 92,
}
5 changes: 5 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ vsc-extension-quickstart.md
**/*.map
**/*.ts
node_modules
wdio.conf.mts
test/**
.wdio-vscode-service
wdio.log
coverage/**
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Selection Utilities

[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://img.shields.io/badge/Project%20Status-Active-green)](https://www.repostatus.org/#active)
[![CI](https://github.com/haberdashPI/vscode-selection-utilities/actions/workflows/ci.yml/badge.svg)](https://github.com/haberdashPI/vscode-selection-utilities/actions/workflows/ci.yml)
[![Code Style: Google](https://img.shields.io/badge/code%20style-google-blueviolet)](https://github.com/google/gts)

> [!WARNING] 🚧 under construction 🚧
Expand Down
5 changes: 5 additions & 0 deletions environments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"wdio": {
"main": "./dist/desktop/extension.js"
}
}
Loading

0 comments on commit 386a933

Please sign in to comment.