Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add CI to frontend (lint ,test, typecheck, build) #799

Merged
merged 7 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/frontend-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: frontend CI

on:
pull_request:
paths:
- "frontend/**"

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Install Node Dependencies
run: npm install
working-directory: ./frontend

- name: Test
run: npm test
working-directory: ./frontend
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Install Node Dependencies
run: npm install
working-directory: ./frontend

- name: Lint
run: npm run lint
working-directory: ./frontend
type-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Install Node Dependencies
run: npm install
working-directory: ./frontend

- name: Type Check
run: npm run type-check
working-directory: ./frontend
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Install Node Dependencies
run: npm install
working-directory: ./frontend

- name: Build
run: npm run build
working-directory: ./frontend
43 changes: 43 additions & 0 deletions frontend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module.exports = {
parser: '@typescript-eslint/parser',
env: {
es2021: true,
jest: true
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:@next/next/recommended',
'next/core-web-vitals',
'plugin:@typescript-eslint/recommended',
],
overrides: [
{
files: ['./src/**/*.js', './src/**/*.jsx'],
parser: 'espree',
rules: {
semi: ['error', 'always'],
'comma-dangle': ['error', 'only-multiline'],
'eol-last': ['error', 'always'],
'@typescript-eslint/no-empty-function': ['warn', { allow: ['methods'] }],
},
},
{
files: ['./src/**/*', './tests/**/*', './**/*.json'],
excludedFiles: ['./src/**/*.js', './src/**/*.jsx'],
parserOptions: {
project: './tsconfig.json',
},
extends: ['standard-with-typescript'],
rules: {
'@typescript-eslint/semi': ['error', 'always'],
'@typescript-eslint/comma-dangle': ['error', 'only-multiline'],
'@typescript-eslint/strict-boolean-expressions': 'off',
'eol-last': ['error', 'always'],
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-empty-function': ['warn', { allow: ['methods'] }],
},
},
],
};
35 changes: 0 additions & 35 deletions frontend/.eslintrc.json

This file was deleted.

9 changes: 9 additions & 0 deletions frontend/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
semi: true, // Add semicolons at the end of statements
singleQuote: true, // Use single quotes instead of double quotes
tabWidth: 2, // Set the tab width to 2 spaces
printWidth: 100, // Wrap lines that exceed 100 characters
trailingComma: 'all', // Use trailing commas wherever possible (multi-line objects and arrays)
arrowParens: 'always', // Always include parentheses around arrow function parameters
endOfLine: 'lf', // Use LF (line feed) as the line ending
};
16 changes: 6 additions & 10 deletions frontend/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json"],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
globals: {
'ts-jest': {
tsconfig: 'tsconfig.json',
},
'^.+\\.[tj]sx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
testPathIgnorePatterns: [
"/frontend/src/components/Editor/__tests__/Editor.test.js",
"/frontend/src/utils/formatters.test.js"
],
};
2 changes: 1 addition & 1 deletion frontend/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ const nextConfig = {
},
};

module.exports = nextConfig;
module.exports = nextConfig;
Loading
Loading