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

Initial files for auto cd/ci #306

Merged
merged 15 commits into from
Jul 31, 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
66 changes: 66 additions & 0 deletions .github/workflows/ci-backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: CI Backend

on:
workflow_dispatch:

push:
trev-dev marked this conversation as resolved.
Show resolved Hide resolved
branches:
- main
- 'feature/**'
- 'Feature/**'
- 'fix/*'
- 'Fix/*'
- 'ofmcc-*'
paths:
- 'backend/src/**'
pull_request:
branches: [main]
paths:
- 'backend/src/**'

jobs:
test:
name: Run ESLint
runs-on: ubuntu-24.04
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.16.x'
- run: npm ci
- run: npm run lint
env:
NODE_ENV: 'test'

# TODO: Uncomment after project is set up in sonar
# sonarcloud:
# name: Build (Sonar Cloud)
# runs-on: ubuntu-24.04
# steps:
# - uses: actions/checkout@v4
# with:
# # Disabling shallow clone is recommended for improving relevancy of reporting
# fetch-depth: 0
# - uses: actions/setup-node@v3
# with:
# node-version: '14.x'
# - name: SonarCloud Scan
# uses: sonarsource/sonarcloud-github-action@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
#with:
#args: >
#-Dsonar.exclusions=**/test/**,.github/**/*,*.md
#-Dsonar.organization=bcgov-sonarcloud
#-Dsonar.javascript.lcov.reportPaths=backend/coverage/lcov.info
#-Dsonar.project.monorepo.enabled=true
#-Dsonar.projectKey=${{ github.event.repository.name }}
#-Dsonar.sources=backend
#-Dsonar.tests=backend/tests
66 changes: 66 additions & 0 deletions .github/workflows/ci-frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: CI Frontend

on:
workflow_dispatch:
push:
branches:
- main
- 'feature/**'
- 'Feature/**'
- 'fix/*'
- 'Fix/*'
- 'ofmcc-*'
paths:
- 'frontend/src/**'
pull_request:
branches: [main]
paths:
- 'frontend/src/**'
trev-dev marked this conversation as resolved.
Show resolved Hide resolved
- 'frontend/src/**'

jobs:
test:
name: Run ESLint
runs-on: ubuntu-24.04

defaults:
run:
working-directory: frontend

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.16.x'
- run: npm ci
- run: npm run lint

# TODO: Uncomment after project is set up in sonar
# sonarcloud:
# name: Build (Sonar Cloud)
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# # Disabling shallow clone is recommended for improving relevancy of reporting
# fetch-depth: 0
# - uses: actions/setup-node@v3
# with:
# node-version: '14.x'
# - name: SonarCloud Scan
# uses: sonarsource/sonarcloud-github-action@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
#with:
#args: >
#-Dsonar.exclusions=**/test/**,.github/**/*,*.md
#-Dsonar.organization=bcgov-sonarcloud
#-Dsonar.javascript.lcov.reportPaths=frontend/coverage/lcov.info
#-Dsonar.project.monorepo.enabled=true
#-Dsonar.projectKey=${{ github.event.repository.name }}
#-Dsonar.sources=frontend
#-Dsonar.tests=frontend/tests
13 changes: 0 additions & 13 deletions backend/.eslintrc.cjs

This file was deleted.

14 changes: 14 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ This project was built using the EDUC-CCOF project as a template.

**`Step 6`** Open http://localhost:8080/api/health to verify that the app is running.

### Lint with [ESLint](https://eslint.org/)

With NPM:

```sh
npm run lint
```

To fix issues:

```sh
npm run lint:fix
```

### Unit Tests

Run `npm run test` in command line from backend folder, to execute unit tests.
Expand Down
29 changes: 29 additions & 0 deletions backend/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import js from '@eslint/js'
import eslintPluginPrettier from 'eslint-plugin-prettier/recommended'

const globals = import('globals')

export default [
js.configs.recommended,
eslintPluginPrettier,
{
files: ['**/*.js'],
languageOptions: {
sourceType: 'commonjs',
globals: {
// This doesn't seem to be working as expected hence the user-defined globals
...globals.node,
__dirname: 'readonly',
process: 'readonly',
setTimeout: 'readonly',
},
},
rules: {
semi: 'off',
'eol-last': ['error', 'always'],
indent: ['error', 2, { SwitchCase: 1 }],
quotes: ['error', 'single', { avoidEscape: true }],
'no-unused-vars': ['error', { args: 'after-used', argsIgnorePattern: '^_', caughtErrors: 'all', caughtErrorsIgnorePattern: '^ignore' }],
},
},
]
Loading
Loading