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

Add linting step within GitHub Actions workflow #196

Closed
wants to merge 5 commits into from
Closed
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
84 changes: 47 additions & 37 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,69 +1,79 @@
name: Unit Tests
name: CI

on: [pull_request]

jobs:
test:
server-unit-tests:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [21.x]

steps:
- name: Checkout repository
- name: Checkout code
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm ci
run: npm install
working-directory: server/

- name: Create subdirectory for service account JSON
run: |
mkdir private_key
working-directory: server/src

- name: Create service account JSON
id: create-service-account-json
uses: jsdaniell/[email protected]
with:
name: "private.json"
json: ${{ secrets.SERVICE_ACCOUNT_SECRET }}
dir: 'server/src/private_key/'

- name: Compile TypeScript files
run: npx tsc
working-directory: server/

- name: Start index.ts in background
run: npm start &
- name: Run server tests
run: npm test
working-directory: server/

- name: Wait for server to start
run: sleep 5 # Adjust sleep time as needed to allow the server to start
timeout-minutes: 1
lint-server:
runs-on: ubuntu-latest

- name: Run tests
run: npm test
strategy:
matrix:
node-version: [21.x]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
run: npm install
working-directory: server/

- name: Lint server-side code
run: npm run lint:fix
working-directory: server/

file_existence:
lint-client:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [21.x]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Check for private.json and .env files
run: |
if [ -e "server/firebase-secret.json" ] || [ -e ".env"]; then
echo "Error: Found .env or firebase-secret.json in the pull request. Please remove them before merging.";
exit 1;
fi

- name: Install dependencies
run: npm install
working-directory: client/

- name: Lint client-side code
run: npm run lint:fix
working-directory: client/

file-existence-check:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Check for sensitive files
run: |
if [ -e ".env" ] || [ -e "firebase-secret.json" ]; then
echo "Error: Found .env or firebase-secret.json in the pull request. Please remove them before merging.";
exit 1;
fi
32 changes: 32 additions & 0 deletions client/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
"env": {
"browser": true,
"es2021": true
},
"extends": [
"standard-with-typescript",
"plugin:react/recommended"
],
"overrides": [
{
"env": {
"node": true
},
"files": [
".eslintrc.{js,cjs}"
],
"parserOptions": {
"sourceType": "script"
}
}
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
}
}
Loading
Loading