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 build and linter for front

closes #24
  • Loading branch information
fokaaas committed Jun 5, 2024
1 parent aac1297 commit d42780e
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 124 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.13.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
24 changes: 24 additions & 0 deletions .github/workflows/front-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Frontend Actions
on:
push:
paths:
- 'apps/web/**'
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 web
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
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
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

0 comments on commit d42780e

Please sign in to comment.