Skip to content

Commit

Permalink
ci: added github workflows to the project
Browse files Browse the repository at this point in the history
- added build
- added build, linter and tests for back
- added linter for front

closes #24
  • Loading branch information
fokaaas committed Jun 5, 2024
1 parent aac1297 commit feff4b1
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 129 deletions.
18 changes: 18 additions & 0 deletions .github/actions/install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'Install Node.js and dependencies'

description: 'Set up Node and dependencies'
runs:
using: composite
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18.17.0
- name: Install pnpm
shell: bash
run: npm install -g pnpm
- name: Install dependencies
shell: bash
run: pnpm install
33 changes: 33 additions & 0 deletions .github/workflows/back-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Backend Actions
on:
push:
paths:
- 'apps/api/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Node and dependencies
uses: ./.github/actions/install
- name: Run build
run: pnpm dlx nx build api
linter:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Node and dependencies
uses: ./.github/actions/install
- name: Run lint
run: pnpm dlx nx lint api
integration-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Node and dependencies
uses: ./.github/actions/install
- name: Run integration tests
run: pnpm dlx nx test:integration api
15 changes: 15 additions & 0 deletions .github/workflows/front-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Frontend Actions
on:
push:
paths:
- 'apps/web/**'
jobs:
linter:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Node and dependencies
uses: ./.github/actions/install
- name: Run lint
run: pnpm dlx nx lint web
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test:integration": "dotenv -f .testing.env -- jest -c jest-integration.config.json -i",
"test:integration": "docker compose up -d && dotenv -e .testing.env -- jest -c jest-integration.config.json -i && docker compose down",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
Expand Down
60 changes: 60 additions & 0 deletions apps/api/src/api/auction/auction.service.ispec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { Test } from '@nestjs/testing';
import { MessageModule } from '../message/message.module';
import { BidModule } from '../bid/bid.module';
import { FileModule } from '../../file/file.module';
import { AuctionGateway } from './gateways/auction.gateway';
import { AuctionService } from './auction.service';
import { AuctionMapper } from './auction.mapper';
import { messageProviders } from '../../database/providers/message.provider';
import { bidProviders } from '../../database/providers/bid.provider';
import { auctionProviders } from '../../database/providers/auction.provider';
import { photoProviders } from '../../database/providers/photo.provider';
import { DatabaseModule } from '../../database/database.module';
import { Auction } from '../../database/entities/auction.entity';

describe('Auction integration test', () => {
let auctionService: AuctionService;
let auction;
beforeAll(async () => {
const moduleRef = await Test.createTestingModule({
providers: [
AuctionGateway,
AuctionService,
AuctionMapper,
...messageProviders,
...bidProviders,
...auctionProviders,
...photoProviders,
],
imports: [MessageModule, BidModule, FileModule, DatabaseModule],
}).compile();
auctionService = moduleRef.get<AuctionService>(AuctionService);

auction = await auctionService.createAuction({
name: 'Vintage Painting Auction',
startPrice: 100,
stepPrice: 10,
currentPrice: 100,
endDate: '2024-12-31T23:59:59Z',
description: 'A vintage painting from the 19th century.',
} as Auction);
});

it('should return auction', async () => {
const gottenAuction = await auctionService.get(auction.id);

expect(gottenAuction.dataValues).toEqual({
id: auction.id,
userId: null,
name: 'Vintage Painting Auction',
startPrice: 100,
stepPrice: 10,
currentPrice: 100,
endDate: auction.endDate,
description: 'A vintage painting from the 19th century.',
createdAt: auction.createdAt,
updatedAt: auction.updatedAt,
photos: [],
});
});
});
118 changes: 0 additions & 118 deletions apps/api/src/api/auction/tests/auctions.ispec.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/api/src/api/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { LoginDto } from './dto/login.dto';
@Controller('auth')
export class AuthController {
constructor (
private authService: AuthService
private authService: AuthService,
) {}

@Post('/register')
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/api/bid/responses/bids.resposne.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { ApiProperty } from '@nestjs/swagger';

class ShortUserResponse {
@ApiProperty({ description: 'User id' })
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/api/photo/photo.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { PhotoResponse } from '../auction/responses/auctions.resposne';
@Controller('/photos')
export class PhotoController {
constructor (
private readonly photoService: PhotoService
private readonly photoService: PhotoService,
) {}

@Post('/:index')
Expand Down
1 change: 1 addition & 0 deletions apps/web/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_API_URL=http://localhost:3001
1 change: 0 additions & 1 deletion apps/web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ yarn-error.log*

# local env files
# do not commit any .env files to git, except for the .env.example file. https://create.t3.gg/en/usage/env-variables#using-environment-variables
.env
.env*.local

# vercel
Expand Down
3 changes: 0 additions & 3 deletions apps/web/src/app/providers.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// In Next.js, this file would be called: app/providers.jsx
"use client";

// We can not useState or useRef in a server component, which is why we are
// extracting this part out into it's own file with 'use client' on top
import { useState } from "react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/ui/command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Command = React.forwardRef<
))
Command.displayName = CommandPrimitive.displayName

interface CommandDialogProps extends DialogProps {}
type CommandDialogProps = DialogProps

const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
return (
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/components/ui/textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import * as React from "react"

import { cn } from "@/lib/utils"

export interface TextareaProps
extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
export type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>

const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
({ className, ...props }, ref) => {
Expand Down

0 comments on commit feff4b1

Please sign in to comment.