Skip to content

Commit 0b6d92e

Browse files
authored
Merge pull request #210 from Visual-Regression-Tracker/update-github-actions-one-time
Update GitHub Actions tool versions and keep them consistent
2 parents 9ea3a5c + 3821ff0 commit 0b6d92e

File tree

10 files changed

+124
-64
lines changed

10 files changed

+124
-64
lines changed

.github/workflows/workflow.yml

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,49 @@
1-
# This is a basic workflow to help you get started with Actions
2-
31
name: CI
42

5-
on:
6-
push:
7-
branches: [master]
8-
pull_request:
9-
branches: [master]
3+
on: [push]
104

115
jobs:
126
build:
7+
# https://github.com/actions/runner-images#available-images
138
runs-on: ubuntu-20.04
149

1510
steps:
16-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v3
1712

1813
- name: Setup Node.js environment
19-
uses: actions/setup-node@v1.4.4
14+
uses: actions/setup-node@v3
2015
with:
2116
node-version: '14.16.1'
2217

2318
- name: Install npm dependencies
2419
run: npm ci
2520

21+
- name: Prisma generate
22+
run: npm run prisma:generate
23+
2624
- name: Unit tests
2725
run: npm run test:cov
2826

29-
- name: Codacy Coverage Reporter
30-
uses: codacy/[email protected]
31-
with:
32-
project-token: ${{ secrets.CODACY_TOKEN }}
33-
34-
- name: Setup PostgreSQL
35-
uses: Harmon758/[email protected]
36-
with:
37-
postgresql db: vrt_db_dev
38-
postgresql user: postgres
39-
postgresql password: postgres
27+
- name: Build and run containers
28+
run: docker-compose up --build -d
4029

41-
- name: Wait untill DB started (workaround of https://github.com/Harmon758/postgresql-action/issues/7)
42-
uses: jakejarvis/[email protected]
30+
# FIXME: This action is unmaintained.
31+
- name: Wait untill service started (replace with health status check)
32+
uses: jakejarvis/[email protected]
4333
with:
44-
time: '5s'
34+
time: '10s'
4535

46-
- name: Apply Manual DB migrations
47-
run: npx ts-node ./prisma/manual_migrations.ts
48-
49-
- name: Apply DB migrations
50-
run: npx prisma migrate up -c --experimental
51-
52-
- name: Seed DB data
53-
run: npx ts-node ./prisma/seed.ts
36+
- name: Run acceptance tests
37+
run: npm run test:acceptance
5438

5539
- name: Run e2e tests
5640
run: npm run test:e2e
41+
42+
- name: Stop containers
43+
if: always()
44+
run: docker-compose down
45+
46+
- name: Codacy Coverage Reporter
47+
uses: codacy/codacy-coverage-reporter-action@v1
48+
with:
49+
project-token: ${{ secrets.CODACY_TOKEN }}

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Using LTS version https://github.com/nodejs/release#release-schedule
2-
FROM node:lts-alpine AS builder
1+
# https://github.com/Visual-Regression-Tracker/Visual-Regression-Tracker/issues/137
2+
FROM node:14-alpine3.17 AS builder
33

44
# Create app directory
55
WORKDIR /app
@@ -19,7 +19,8 @@ COPY src ./src
1919

2020
RUN npm run build
2121

22-
FROM node:lts-alpine
22+
# https://github.com/Visual-Regression-Tracker/Visual-Regression-Tracker/issues/137
23+
FROM node:14-alpine3.17
2324
COPY --from=builder /app/node_modules ./node_modules
2425
COPY --from=builder /app/package*.json ./
2526
COPY --from=builder /app/dist ./dist

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
## Local setup
77

8+
- Install Node `14`
89
- clone repo
910
- Update `.env` and `prisma/.env`
1011
- Make sure Postgres is up and running

docker-compose.yml

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
version: "3.7"
22
services:
3-
# api:
4-
# build:
5-
# context: .
6-
# dockerfile: Dockerfile
7-
# environment:
8-
# DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
9-
# JWT_SECRET: ${JWT_SECRET}
10-
# JWT_LIFE_TIME: ${JWT_LIFE_TIME}
11-
# BODY_PARSER_JSON_LIMIT: ${BODY_PARSER_JSON_LIMIT}
12-
# APP_FRONTEND_URL: ${APP_FRONTEND_URL}
13-
# ports:
14-
# - "${APP_PORT}:3000"
15-
# expose:
16-
# - "${APP_PORT}"
17-
# depends_on:
18-
# - postgres
3+
api:
4+
container_name: vrt_api
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
environment:
9+
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
10+
JWT_SECRET: ${JWT_SECRET}
11+
JWT_LIFE_TIME: ${JWT_LIFE_TIME}
12+
BODY_PARSER_JSON_LIMIT: ${BODY_PARSER_JSON_LIMIT}
13+
APP_FRONTEND_URL: ${APP_FRONTEND_URL}
14+
ports:
15+
- "${APP_PORT}:3000"
16+
expose:
17+
- "${APP_PORT}"
18+
depends_on:
19+
- postgres
20+
migration:
21+
container_name: vrt_migration
22+
build:
23+
context: prisma
24+
dockerfile: Dockerfile
25+
environment:
26+
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
27+
depends_on:
28+
- postgres
1929
postgres:
20-
image: postgres:12
30+
container_name: postgres
31+
image: postgres:12-alpine3.18
2132
restart: always
2233
environment:
2334
POSTGRES_USER: ${POSTGRES_USER}
@@ -29,13 +40,16 @@ services:
2940
- "${POSTGRES_PORT}"
3041
volumes:
3142
- postgres:/var/lib/postgresql/data
32-
# migration:
33-
# build:
34-
# context: prisma
35-
# dockerfile: Dockerfile
36-
# environment:
37-
# DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
38-
# depends_on:
39-
# - postgres
43+
pgadmin:
44+
container_name: pgadmin4
45+
image: dpage/pgadmin4
46+
restart: always
47+
environment:
48+
PGADMIN_DEFAULT_EMAIL: [email protected]
49+
PGADMIN_DEFAULT_PASSWORD: root
50+
ports:
51+
- "5050:80"
52+
depends_on:
53+
- postgres
4054
volumes:
4155
postgres:

jest.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
/** @returns {Promise<import('jest').Config>} */
22
module.exports = async () => {
33
return {
4-
projects: ['./test/jest.config.ts', './src/jest.config.ts'],
4+
projects: [
5+
'./src/jest.config.ts',
6+
'./test/jest.config.ts',
7+
'./test_acceptance/jest.config.ts'
8+
],
59
roots: ['./'],
610
testTimeout: 30000,
711
};

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
"start:dev": "nest start --watch",
1414
"start:debug": "nest start --debug --watch",
1515
"start:prod": "node dist/main",
16+
"prisma:generate": "prisma generate",
1617
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
1718
"test": "jest --projects src",
1819
"test:watch": "jest --projects src --watch",
1920
"test:cov": "jest --projects src --coverage",
2021
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --projects src --runInBand",
21-
"test:e2e": "jest --projects test"
22+
"test:e2e": "jest --projects test",
23+
"test:acceptance": "jest --projects test_acceptance"
2224
},
2325
"dependencies": {
2426
"@nestjs/common": "^8.4.1",

prisma/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Using LTS version https://github.com/nodejs/release#release-schedule
2-
FROM node:lts-alpine
1+
# https://github.com/Visual-Regression-Tracker/Visual-Regression-Tracker/issues/137
2+
FROM node:14-alpine3.17
33

44
RUN apk add --no-cache bash
55

test_acceptance/acceptance.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { User } from '@prisma/client';
2+
import axios from 'axios'
3+
import { UserLoginRequestDto } from 'src/users/dto/user-login-request.dto';
4+
import { UserLoginResponseDto } from 'src/users/dto/user-login-response.dto';
5+
import uuidAPIKey from 'uuid-apikey';
6+
7+
axios.defaults.baseURL = 'http://localhost:4200';
8+
9+
let user: Partial<User> = {
10+
email: `${uuidAPIKey.create().uuid}@example.com`,
11+
password: '123456',
12+
firstName: 'fName',
13+
lastName: 'lName',
14+
};
15+
const loginData: UserLoginRequestDto = {
16+
email: user.email,
17+
password: user.password,
18+
}
19+
20+
describe('Acceptance', () => {
21+
22+
test('Register and login', async () => {
23+
await axios.post<User>('/users/register', user);
24+
25+
const response = await axios.post<UserLoginResponseDto>('/users/login', loginData)
26+
27+
expect(response.status).toBe(201)
28+
expect(response.data.token).toBeDefined()
29+
})
30+
})

test_acceptance/jest.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/** @returns {Promise<import('jest').Config>} */
2+
module.exports = async () => {
3+
return {
4+
name: 'Acceptance',
5+
displayName: 'Acceptance',
6+
roots: ['./'],
7+
testTimeout: 30000,
8+
testRegex: '.spec.ts$',
9+
moduleFileExtensions: ['js', 'json', 'ts'],
10+
transform: {
11+
'^.+\\.(t|j)s$': 'ts-jest',
12+
},
13+
testEnvironment: 'node',
14+
};
15+
};

0 commit comments

Comments
 (0)