ci: add eslint, vitest coverage, improved CI and deploy workflows
This commit is contained in:
20
.eslintrc.cjs
Normal file
20
.eslintrc.cjs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
module.exports = {
|
||||||
|
root: true,
|
||||||
|
env: { browser: true, es2020: true },
|
||||||
|
extends: [
|
||||||
|
'eslint:recommended',
|
||||||
|
'plugin:react/recommended',
|
||||||
|
'plugin:react/jsx-runtime',
|
||||||
|
'plugin:react-hooks/recommended',
|
||||||
|
],
|
||||||
|
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
||||||
|
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
|
||||||
|
settings: { react: { version: '18.2' } },
|
||||||
|
plugins: ['react-refresh'],
|
||||||
|
rules: {
|
||||||
|
'react-refresh/only-export-components': [
|
||||||
|
'warn',
|
||||||
|
{ allowConstantExport: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -2,10 +2,12 @@ name: CI
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [dev]
|
branches-ignore: [main]
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
lint-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -18,10 +20,12 @@ jobs:
|
|||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: npx eslint src/ --ext .js,.jsx,.ts,.tsx --max-warnings 0 || true
|
run: npx eslint src/ --max-warnings 0
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: npx vitest run --reporter=verbose
|
run: npx vitest run --coverage --reporter=verbose
|
||||||
|
|
||||||
- name: Build
|
- name: Coverage Check
|
||||||
run: npm run build
|
run: |
|
||||||
|
npx vitest run --coverage 2>&1 | tee coverage-output.txt
|
||||||
|
echo "Coverage report generated"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name: Deploy Production
|
name: Deploy
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -8,14 +8,18 @@ jobs:
|
|||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Deploy pulse-web
|
||||||
|
run: |
|
||||||
- uses: actions/setup-node@v4
|
cd /opt/digital-home/pulse-web
|
||||||
with:
|
docker compose pull
|
||||||
node-version: '20'
|
docker compose up -d --build
|
||||||
|
echo "Waiting for container..."
|
||||||
- name: Install dependencies
|
sleep 5
|
||||||
run: npm ci
|
STATUS=$(docker inspect --format='{{.State.Status}}' pulse-web 2>/dev/null || echo "unknown")
|
||||||
|
echo "Container status: $STATUS"
|
||||||
- name: Build
|
if [ "$STATUS" != "running" ]; then
|
||||||
run: npm run build
|
echo "::error::Container is not running after deploy"
|
||||||
|
docker logs pulse-web --tail=20
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Deploy successful!"
|
||||||
|
|||||||
3572
package-lock.json
generated
3572
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -35,7 +35,12 @@
|
|||||||
"@types/react": "^18.2.48",
|
"@types/react": "^18.2.48",
|
||||||
"@types/react-dom": "^18.2.18",
|
"@types/react-dom": "^18.2.18",
|
||||||
"@vitejs/plugin-react": "^4.2.1",
|
"@vitejs/plugin-react": "^4.2.1",
|
||||||
|
"@vitest/coverage-v8": "^4.1.2",
|
||||||
"autoprefixer": "^10.4.17",
|
"autoprefixer": "^10.4.17",
|
||||||
|
"eslint": "^9.39.4",
|
||||||
|
"eslint-plugin-react": "^7.37.5",
|
||||||
|
"eslint-plugin-react-hooks": "^7.0.1",
|
||||||
|
"eslint-plugin-react-refresh": "^0.5.2",
|
||||||
"jsdom": "^28.1.0",
|
"jsdom": "^28.1.0",
|
||||||
"postcss": "^8.4.33",
|
"postcss": "^8.4.33",
|
||||||
"storybook": "^8.5.0",
|
"storybook": "^8.5.0",
|
||||||
|
|||||||
@@ -7,5 +7,23 @@ export default defineConfig({
|
|||||||
environment: 'jsdom',
|
environment: 'jsdom',
|
||||||
globals: true,
|
globals: true,
|
||||||
setupFiles: './src/__tests__/setup.js',
|
setupFiles: './src/__tests__/setup.js',
|
||||||
|
coverage: {
|
||||||
|
provider: 'v8',
|
||||||
|
reporter: ['text', 'lcov'],
|
||||||
|
exclude: [
|
||||||
|
'node_modules/**',
|
||||||
|
'src/main.jsx',
|
||||||
|
'**/*.stories.*',
|
||||||
|
'.storybook/**',
|
||||||
|
'coverage/**',
|
||||||
|
'dist/**',
|
||||||
|
],
|
||||||
|
thresholds: {
|
||||||
|
lines: 75,
|
||||||
|
branches: 70,
|
||||||
|
functions: 75,
|
||||||
|
statements: 75
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user