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

fix: Github Actions error fixed #19

Merged
merged 8 commits into from
Nov 19, 2023
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
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Continuous Integration

on:
pull_request:
branches:
- main
- dev

jobs:
testing:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: techstart-fashion
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h localhost -uroot -proot"
--health-interval=10s
--health-timeout=5s
--health-retries=5

env:
DATABASE_URL: mysql://root:root@localhost:3306/techstart-fashion

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

- name: Install dependencies
run: cd backend && npm install

- name: Wait for database
run: |
until nc -z localhost 3306; do
echo "Waiting for MySQL to be ready..."
sleep 2
done
echo "MySQL is ready."

- name: Test
run: cd backend && npm run test
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ♻️ Fashion

[![Continuous Integration](https://github.com/techstartucalgary/fashion/actions/workflows/ci.yml/badge.svg)](https://github.com/techstartucalgary/fashion/actions/workflows/ci.yml)

## 📖 Table of Contents

- [📝 Contributors](#-contributors)
Expand Down
21 changes: 0 additions & 21 deletions backend/.github/workflows/ci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"start": "NODE_ENV=PROD node dist/src/index.js",
"predev": "npx prisma migrate dev --name init && npx prisma generate",
"dev": "NODE_ENV=DEV nodemon -e ts --exec \"npm run build && node dist/src/index.js\"",
"pretest": "npx prisma migrate deploy && npx prisma generate",
"pretest": "npx prisma migrate dev --name init && npx prisma generate",
"test": "NODE_ENV=TEST npm run build && mocha \"dist/test/**/*.test.js\""
},
"keywords": [],
Expand Down
3 changes: 0 additions & 3 deletions backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import algorithmRouter from "./routers/algorithm.router.js";
import authenticationRouter from "./routers/authentication.router.js";
import errorHandler from "./middlewares/error.middleware.js";
import { PORT } from "./config/config.js";
import { PrismaClient } from "@prisma/client";

export const app: Express = express();

export const prisma = new PrismaClient();

app.use(cors());

app.use(express.json());
Expand Down
4 changes: 3 additions & 1 deletion backend/src/routers/authentication.router.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Router } from "express";
import { prisma } from "../index.js";
import { PrismaClient } from "@prisma/client";
import UserRepository from "../repositories/user.repository.js";
import AuthenticationService from "../services/authentication.service.js";
import AuthenticationController from "../controllers/authentication.controller.js";
Expand All @@ -11,6 +11,8 @@ import {

const authenticationRouter = Router();

const prisma = new PrismaClient();

const userRepository: UserRepositoryInterface = new UserRepository(prisma);

const authenticationService: AuthenticationServiceInterface =
Expand Down