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

ci(backend): setup lint workflow #43

Merged
merged 9 commits into from
Mar 2, 2024
31 changes: 31 additions & 0 deletions .github/workflows/backend-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Backend Lint

on:
push:
branches: ["dev"]
paths: ["backend/"]
pull_request:
branches: ["dev"]

defaults:
run:
working-directory: "backend/"

jobs:
run-backend-lint:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Install dependencies
run: npm i
- name: Lint with Eslint
RickyC0626 marked this conversation as resolved.
Show resolved Hide resolved
run: npm run lint
10 changes: 5 additions & 5 deletions backend/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"useTabs": false,
"singleQuote": true,
"trailingComma": "none",
"semi": true,
"tabWidth": 2
"useTabs": false,
"singleQuote": true,
"trailingComma": "none",
"semi": true,
"tabWidth": 2
}
8 changes: 4 additions & 4 deletions backend/app.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use strict";
'use strict';

//Import requirement modules
const express = require("express");
const express = require('express');
const app = express();
const port = 3000;

app.get("/", (req, res) => {
res.send("Hello Parking User");
app.get('/', (req, res) => {
res.send('Hello Parking User');
});

// Start the server
Expand Down
8 changes: 4 additions & 4 deletions backend/database/firebase-conn.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"use strict";
'use strict';

const admin = require("firebase-admin");
const admin = require('firebase-admin');
// const serviceKey = require('./serviceKey.json'); // need fb service key

admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
credential: admin.credential.cert(serviceAccount)
});

const firestore = admin.firestore();
const settings = {
timestampsInSnapshots: true,
timestampsInSnapshots: true
};
firestore.settings(settings);

Expand Down
13 changes: 6 additions & 7 deletions backend/tests/app.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const request = require("supertest");
const express = require("express");
const app = require("../app");
const request = require('supertest');
const app = require('../app');

describe("Test the root path", () => {
test("It should respond with the GET method", async () => {
const response = await request(app).get("/");
describe('Test the root path', () => {
test('It should respond with the GET method', async () => {
const response = await request(app).get('/');
expect(response.statusCode).toBe(200);
expect(response.text).toEqual("Hello Parking User");
expect(response.text).toEqual('Hello Parking User');
});
});