Skip to content

Commit d28b2f0

Browse files
Create project using Next with TypeScript, with Prisma as the ORM with PostgreSQL v15 as the datasource, with unit and E2E tests and documentation for usage locally or with Codespaces
0 parents  commit d28b2f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+23271
-0
lines changed

.babelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": [
3+
"next/babel"
4+
],
5+
"plugins": [
6+
"istanbul"
7+
]
8+
}

.devcontainer/devcontainer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "image": "mcr.microsoft.com/devcontainers/universal:2" }

.env

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
####################################################################################################
2+
# Database
3+
####################################################################################################
4+
5+
POSTGRES_USER="user"
6+
POSTGRES_PASSWORD="pwd"
7+
POSTGRES_DB="db"
8+
9+
####################################################################################################
10+
# Prisma
11+
####################################################################################################
12+
13+
DATABASE_URL="postgresql://user:pwd@localhost:5432/db?schema=public"

.env-local

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
####################################################################################################
2+
# Database
3+
####################################################################################################
4+
5+
POSTGRES_USER="user"
6+
POSTGRES_PASSWORD="pwd"
7+
POSTGRES_DB="db"
8+
9+
####################################################################################################
10+
# Prisma
11+
####################################################################################################
12+
13+
DATABASE_URL="postgresql://user:pwd@localhost:5432/db?schema=public"

.eslintrc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "next/core-web-vitals",
3+
"plugins": [
4+
"@typescript-eslint"
5+
],
6+
"rules": {
7+
"@typescript-eslint/no-unused-vars": [
8+
"warn",
9+
{
10+
"argsIgnorePattern": "^_"
11+
}
12+
]
13+
}
14+
}

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://help.github.com/articles/about-codeowners/
2+
3+
* @juancarlosjr97

.github/workflows/development.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: Development
3+
on:
4+
push:
5+
branches:
6+
- "*"
7+
8+
jobs:
9+
install-dependencies:
10+
uses: ./.github/workflows/install-dependencies.yml
11+
12+
tests:
13+
needs: install-dependencies
14+
uses: ./.github/workflows/tests.yml
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
name: Install Dependencies
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
install-dependencies:
8+
name: Install Dependencies Workflow
9+
if: "!contains(github.event.head_commit.message, '[skip-ci]')"
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 10
12+
strategy:
13+
matrix:
14+
node-version: [18.12.1]
15+
16+
steps:
17+
- name: Checkout Code 🛎️
18+
uses: actions/checkout@v3
19+
with:
20+
persist-credentials: false
21+
22+
- name: Setup Node
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
27+
- name: Use Node.js Caching ${{ matrix.node-version }}
28+
id: node-cache
29+
uses: actions/cache@v3
30+
with:
31+
path: node_modules
32+
key: node-modules-${{ hashFiles('package-lock.json') }}
33+
34+
- name: Install Dependencies
35+
if: steps.node-cache.outputs.cache-hit != 'true'
36+
run: npm ci

.github/workflows/tests.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
name: Tests
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
tests:
8+
name: Tests Workflow
9+
runs-on: ubuntu-latest
10+
timeout-minutes: 30
11+
strategy:
12+
matrix:
13+
node-version: [18.12.1]
14+
15+
steps:
16+
- name: Checkout Code 🛎️
17+
uses: actions/checkout@v3
18+
with:
19+
persist-credentials: false
20+
21+
- name: Setup Node
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
26+
- name: Use Node.js Caching ${{ matrix.node-version }}
27+
id: node-cache
28+
uses: actions/cache@v3
29+
with:
30+
path: node_modules
31+
key: node-modules-${{ hashFiles('package-lock.json') }}
32+
33+
- name: Install Dependencies
34+
if: steps.node-cache.outputs.cache-hit != 'true'
35+
run: npm ci
36+
37+
- name: Setup test environmental variables
38+
run: |
39+
cp .env-local .env
40+
41+
- name: Start docker container
42+
run: npm run docker:ci
43+
44+
- name: Build and start web app in the background
45+
run: npm run build:start
46+
env:
47+
ENVIRONMENT: ci
48+
NODE_ENV: ci
49+
50+
- name: Sleep 30 seconds
51+
run: sleep 30
52+
53+
- name: Run prisma db migrations
54+
run: npm run prisma:deploy
55+
56+
- name: Run jest unit tests
57+
run: npm run test:jest:ci
58+
59+
- name: Upload coverage jest
60+
uses: actions/upload-artifact@v3
61+
if: always()
62+
with:
63+
name: jest-coverage
64+
path: coverage
65+
retention-days: 7
66+
67+
- name: Install Cypress
68+
run: npx cypress install
69+
70+
- name: Run Cypress E2E tests
71+
uses: cypress-io/github-action@v5
72+
with:
73+
install: false
74+
browser: chrome
75+
headed: true
76+
wait-on: http://localhost:3000
77+
78+
- name: Video Cypress
79+
uses: actions/upload-artifact@v3
80+
if: always()
81+
with:
82+
name: videos-cypress
83+
path: cypress/videos
84+
retention-days: 7
85+
86+
- name: Screenshots Cypress
87+
uses: actions/upload-artifact@v3
88+
if: failure()
89+
with:
90+
name: screenshots-cypress
91+
path: cypress/screenshots
92+
retention-days: 7
93+
94+
- name: Run coverage check
95+
run: npm run test:coverage:check
96+
97+
- name: Coverage
98+
uses: actions/upload-artifact@v3
99+
if: always()
100+
with:
101+
name: merged-coverage
102+
path: coverage/merged
103+
retention-days: 7
104+
105+
- name: Exit on failure
106+
if: failure()
107+
run: |
108+
echo "Error running tests job"
109+
exit 1

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
.pnpm-debug.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts
37+
38+
# vs code
39+
.history
40+
41+
# cypress
42+
cypress/screenshots/**
43+
cypress/videos/**
44+
45+
# nyc test coverage
46+
.nyc_output

0 commit comments

Comments
 (0)