Skip to content

Commit 6dce2a5

Browse files
Add build and test workflow
1 parent 35f7d05 commit 6dce2a5

File tree

11 files changed

+5966
-0
lines changed

11 files changed

+5966
-0
lines changed

.eslintrc.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"parserOptions": {
4+
"ecmaVersion": 2020,
5+
"sourceType": "module",
6+
"project": "./tsconfig.eslint.json"
7+
},
8+
"extends": [
9+
"eslint:recommended",
10+
"plugin:@typescript-eslint/recommended"
11+
],
12+
"plugins": [
13+
"@typescript-eslint"
14+
],
15+
"env": {
16+
"node": true,
17+
"es6": true,
18+
"jest": true
19+
},
20+
"rules": {
21+
"@typescript-eslint/no-unused-vars": "error",
22+
"@typescript-eslint/explicit-function-return-type": "warn",
23+
"@typescript-eslint/no-explicit-any": "warn"
24+
},
25+
"ignorePatterns": [
26+
"dist/**/*",
27+
"*.js"
28+
]
29+
}
30+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build and Test
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
name: Build and test
13+
permissions:
14+
contents: read
15+
actions: write
16+
checks: write
17+
statuses: write
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Setup node 24
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: 24
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Build
30+
run: npm run build
31+
32+
- name: Lint
33+
run: npm run lint
34+
35+
- name: Test
36+
run: npm run test
37+
38+
- name: Create test report
39+
uses: phoenix-actions/test-reporting@v12
40+
if: success() || failure() # run this step even if previous step failed
41+
with:
42+
name: Tests # Name of the check run which will be created
43+
path: test-results/jest-*.xml # Path to test results
44+
reporter: jest-junit # Format of test results
45+
output-to: step-summary
46+
47+
- name: Compare the expected and actual dist/ directories
48+
run: |
49+
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
50+
echo "Detected uncommitted changes after build. See status below:"
51+
git diff
52+
exit 1
53+
fi
54+
id: diff
55+
56+
# If index.js was different from expected, upload the expected version as an artifact
57+
- name: Upload dist as artifact if differences detected
58+
uses: actions/upload-artifact@v4
59+
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
60+
with:
61+
name: dist
62+
path: dist/

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
node_modules/
2+
dist/
3+
coverage/
4+
test-results/
5+
*.log
6+
.env
7+
.DS_Store
8+
*.js.map
9+
*.d.ts.map
10+
.idea/

.prettierrc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": true,
5+
"printWidth": 100,
6+
"tabWidth": 2,
7+
"useTabs": false
8+
}
9+

jest.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
collectCoverage: true,
5+
collectCoverageFrom: [
6+
'src/**/*.ts',
7+
'!src/**/*.test.ts',
8+
'!src/**/*.d.ts'
9+
],
10+
coverageDirectory: 'coverage',
11+
coverageReporters: ['text', 'lcov', 'html'],
12+
testMatch: ['**/*.test.ts'],
13+
moduleFileExtensions: ['ts', 'js', 'json'],
14+
verbose: true,
15+
reporters: [
16+
'default',
17+
['jest-junit', {
18+
outputDirectory: 'test-results',
19+
outputName: 'jest-junit.xml',
20+
}]
21+
]
22+
};

0 commit comments

Comments
 (0)