Skip to content

Commit

Permalink
Set up automated testing in Github Actions (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
sannidhishukla authored Feb 13, 2025
1 parent 5a15076 commit ee4ac21
Show file tree
Hide file tree
Showing 97 changed files with 3,253 additions and 2,914 deletions.
Empty file.
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code, and run tests
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Automated testing

on:
push:
branches: [nj-stable-dev, nj-stable]
pull_request:
branches: [nj-stable-dev, nj-stable]

jobs:
build-and-test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend

steps:
- uses: actions/checkout@v4
- name: Read .nvmrc
run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_OUTPUT
id: nvm
- name: Use Node.js ${{ steps.nvm.outputs.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: "${{ steps.nvm.outputs.NODE_VERSION }}"
- name: Install dependencies
run: npm ci
- name: Check for critical vulnerabilities
run: npm audit --audit-level=critical
- name: Run ESLint check
run: npm run lint
- name: Run prettier check
run: npm run prettier
- name: Set maximum memory size for build + run build
run: NODE_OPTIONS=--max_old_space_size=8192 npm run build --if-present
- name: Run frontend tests
run: npm run test:react
- name: Run API tests
run: npm run test:api
34 changes: 0 additions & 34 deletions .github/workflows/node.js.yml

This file was deleted.

6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,3 @@ frontend/node_modules
__pycache__/
.ipynb_checkpoints/
.DS_Store
/static/assets/*

# allow files matching paths specified, needed for build
!/static/assets/index-*.js
!/static/assets/index-*.js.map
!/static/assets/index-*.css
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.x
26 changes: 7 additions & 19 deletions frontend/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,23 @@
"jest": true
},
"rules": {
// "prettier/prettier": "error",
"prettier/prettier": [
"error",
{},
{
"usePrettierrc": false
"usePrettierrc": true
}
],
"quote-props": [2, "as-needed"],
"comma-dangle": "error",
"no-console": ["warn", { "allow": ["warn", "error"] }],
"no-debugger": "error",
"react/prop-types": 0,
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
"object-curly-newline": [
"error",
{
"ObjectExpression": "always",
"ObjectPattern": { "multiline": "as-needed" },
"ImportDeclaration": "never",
"ExportDeclaration": { "multiline": true, "minProperties": 3 }
}
],
"object-curly-spacing": ["error", "as-needed", { "objectsInObjects": true }],
"no-underscore-dangle": 0,
"jsx-a11y/click-events-have-key-events": 0,
"jsx-a11y/anchor-is-valid": 0,
"no-await-in-loop": 0,
"no-unused-expressions": ["error", { "allowShortCircuit": true, "allowTernary": true }],
"arrow-parens": ["error", "as-needed"],
"no-unused-vars": "off", // Turn off the base rule and use @typescript-eslint/no-unused-vars
"@typescript-eslint/no-unused-vars": [
"error",
Expand All @@ -65,10 +52,7 @@
"spaced-comment": 0,
"react/react-in-jsx-scope": 0,
"react/jsx-filename-extension": 0,
"indent": ["error", 2],
"react/jsx-indent": ["error", 2],
"react/jsx-indent-props": ["error", 2],
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-explicit-any": "off",
"simple-import-sort/exports": "error",
"simple-import-sort/imports": [
"error",
Expand All @@ -90,5 +74,9 @@
}
]
},
"ignorePatterns": ["node_modules/", "build/", "dist/", "public/", "*.config.ts"]
// Ignore files related to ChatHistory until this feature is
// enabled + we have a deeper understanding of how to handle
// lint errors and warnings here

"ignorePatterns": ["node_modules/", "build/", "dist/", "public/", "*.config.ts", "src/components/ChatHistory/"]
}
19 changes: 7 additions & 12 deletions frontend/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
{
"semi": false,
"singleQuote": true,
"arrowParens": "avoid",
"trailingComma": "none",
"endOfLine": "auto",
"tabWidth": 2,
"printWidth": 120,
"bracketSpacing": true,
"bracketSameLine": true,
"jsxSingleQuote": false,
"quoteProps": "as-needed"
}
"arrowParens": "always",
"endOfLine": "lf",
"printWidth": 100,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false
}
4 changes: 2 additions & 2 deletions frontend/__mocks__/fileMock.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const mock = 'test-file-stub'
export default mock
const mock = "test-file-stub";
export default mock;
74 changes: 41 additions & 33 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vitejs/plugin-react": "^3.1.0",
"eslint": "^8.57.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
Expand All @@ -75,7 +75,7 @@
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"prettier": "^3.5.0",
"react-test-renderer": "^18.2.0",
"string.prototype.replaceall": "^1.0.10",
"ts-jest": "^29.1.2",
Expand Down
4 changes: 2 additions & 2 deletions frontend/polyfills.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const replaceAllInserter = require('string.prototype.replaceall')
const replaceAllInserter = require("string.prototype.replaceall");

replaceAllInserter.shim()
replaceAllInserter.shim();
Loading

0 comments on commit ee4ac21

Please sign in to comment.