Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
I've still got a bit of work to do before publishing v1.0.0. I need to
add tests based on the mbland/tomcat-servlet-testing-example project
from whence this came, add more documentation, and refactor. I plan to
finish this by 2024-01-05.
  • Loading branch information
mbland committed Jan 1, 2024
0 parents commit ad044d0
Show file tree
Hide file tree
Showing 14 changed files with 3,318 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
**/vendor/
build/
coverage/
dist/
jsdoc/
node_modules/
out/
tmp/
54 changes: 54 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"env" : {
"node": true,
"es2023" : true
},
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@stylistic/js",
"vitest",
"jsdoc"
],
"extends": [
"eslint:recommended",
"plugin:jsdoc/recommended"
],
"overrides": [
{
"files": ["**/*.test.js"],
"plugins": ["vitest"],
"extends": [
"plugin:vitest/recommended"
]
}
],
"rules" : {
"@stylistic/js/comma-dangle": [
"error", "never"
],
"@stylistic/js/indent": [
"error", 2, { "VariableDeclarator": 2 }
],
"@stylistic/js/keyword-spacing": [
"error"
],
"@stylistic/js/max-len": [
"error", 80, 2, { "ignoreUrls": true }
],
"@stylistic/js/quotes": [
"error", "single"
],
"@stylistic/js/semi": [
"error", "never"
],
"camelcase": [
"error", { "properties": "always" }
],
"no-console": [
"error", { "allow": [ "warn", "error" ]}
]
}
}
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ensure line endings remain LF on Windows, instead of getting
# translated to CRLF. Otherwise, Bash chokes on \r characters.
# - https://help.github.com/articles/dealing-with-line-endings/
# - https://stackoverflow.com/a/47187309
* text eol=lf
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This enables automatic code review requests per:
# - https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
# - https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule
* @mbland
45 changes: 45 additions & 0 deletions .github/workflows/publish-test-results.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Per the advice from:
# - https://octopus.com/blog/githubactions-running-unit-tests
# - https://github.com/marketplace/actions/test-reporter

name: Publish Test Results

on:
workflow_run:
workflows: ['Run Tests']
types:
- completed

permissions:
contents: read
actions: read
checks: write

jobs:
report:
runs-on: ubuntu-latest
steps:
# dorny/test-reporter has an `artifact:` attribute that will check out the
# repo and download test results automatically. However,
# dorny/test-reporter@v1 wasn't compatible with the bump to
# actions/upload-artifact@v4 in run-tests.yaml. So we manually check
# out the repo and download the results to avoid the rev lock.
- name: Check out repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_commit.id }}

- name: Download test results
uses: actions/download-artifact@v4
with:
name: test-results
github-token: ${{ github.token }}
run-id: ${{ github.event.workflow_run.id }}

- name: Post test report
uses: dorny/test-reporter@v1
with:
name: Test Results
path: 'TESTS-TestSuites.xml'
reporter: java-junit
fail-on-error: true
50 changes: 50 additions & 0 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Run Tests

on:
push:
branches: [ "main" ]
paths-ignore: [ "**.md", "**.txt" ]
pull_request:
branches: [ "main" ]
paths-ignore: [ "**.md", "**.txt" ]
workflow_dispatch:

jobs:
build-test:
name: "Run Tests"
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
cache-dependency-path: 'pnpm-lock.yaml'

- name: Install dependencies
run: "pnpm install"

- name: Build and test
run: "pnpm test:ci"

# Per the advice from:
# - https://github.com/marketplace/actions/test-reporter
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: 'TESTS-TestSuites.xml'

- name: Send test coverage to Coveralls.io
uses: coverallsapp/github-action@v2
with:
file: 'coverage/lcov.info'
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
.idea/
.vscode/
TESTS-*.xml
build/
coverage/
dist/
jsdoc/
node_modules/
out/
pnpm-debug.log
tmp/
*.log
Loading

0 comments on commit ad044d0

Please sign in to comment.