Skip to content

Commit

Permalink
Merge pull request #72 from joshmu/feat_testing
Browse files Browse the repository at this point in the history
testing infra
  • Loading branch information
joshmu authored Dec 27, 2024
2 parents aa89b78 + d73f77c commit 4dd182e
Show file tree
Hide file tree
Showing 25 changed files with 1,569 additions and 101 deletions.
70 changes: 49 additions & 21 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,62 @@
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": true,
"tsconfigRootDir": "."
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"extends": ["airbnb-base", "plugin:@typescript-eslint/recommended", "prettier"],
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"],
"moduleDirectory": ["node_modules", "src/"]
}
}
},
"rules": {
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/naming-convention": [
"warn",
{
"selector": "default",
"format": ["camelCase"],
"filter": {
"regex": "^_type$",
"match": false
}
},
{
"selector": "variable",
"format": ["camelCase", "UPPER_CASE"]
},
{
"selector": "parameter",
"format": ["camelCase"],
"leadingUnderscore": "allow"
},
{
"selector": "memberLike",
"modifiers": ["private"],
"format": ["camelCase"],
"leadingUnderscore": "require"
},
{
"selector": "typeLike",
"format": ["PascalCase"]
},
{
"selector": "property",
"format": null,
"filter": {
"regex": "^_type$",
"match": true
}
},
{
"selector": "objectLiteralProperty",
"format": ["camelCase", "UPPER_CASE"],
"filter": {
"regex": "^(NODE_ENV|VSCODE_TEST)$",
"match": true
}
}
],
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
"import/prefer-default-export": "off",
"import/extensions": "off",
"import/no-unresolved": "off",
"max-len": ["warn", { "code": 120 }],
"no-console": "off",
"import/no-extraneous-dependencies": "off",
"no-use-before-define": "off",
"no-param-reassign": "off",
"no-underscore-dangle": "off"
"semi": "off"
},
"ignorePatterns": ["out", "dist", "**/*.d.ts"]
}
5 changes: 5 additions & 0 deletions .github/workflows/publish-vscode-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ on:
- master

jobs:
# Add test job dependency
test:
uses: ./.github/workflows/test.yml

semantic-release:
needs: test # Require tests to pass before release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Tests

on:
push:
branches: [main, master]
pull_request:
types: [opened, synchronize, reopened]
branches: [main, master]
# Add workflow_call to allow other workflows to depend on this
workflow_call:

jobs:
test:
name: Test (${{ matrix.os }})
strategy:
# Keep fail-fast true to ensure all tests must pass
fail-fast: true
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
node-version: [20.x]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout Repository
uses: actions/checkout@v4

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

- name: Install Dependencies
run: npm install
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Format code before testing
- name: Format Code
run: npm run lint:fix

# Linux requires xvfb to run vscode tests
- name: Install xvfb (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y xvfb
# Run tests based on platform
- name: Run Tests (Linux)
if: runner.os == 'Linux'
run: xvfb-run -a npm test

- name: Run Tests (macOS/Windows)
if: runner.os != 'Linux'
run: npm test

# Report test status on PR
- name: Update PR Status
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const { owner, repo, number } = context.issue;
const jobName = process.env.MATRIX_OS;
github.rest.issues.createComment({
owner,
repo,
issue_number: number,
body: `✅ Tests passed on ${jobName}`
});
env:
MATRIX_OS: ${{ matrix.os }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ dist
node_modules
.vscode-test/
*.vsix
.env.local
.env.local
.cursorrules
.clinerules
docs/
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"endOfLine": "lf",
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 2,
"printWidth": 120
"printWidth": 100
}
Loading

0 comments on commit 4dd182e

Please sign in to comment.