Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardomrcruz committed Nov 8, 2024
0 parents commit c87ddee
Show file tree
Hide file tree
Showing 232 changed files with 37,245 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
12 changes: 12 additions & 0 deletions .env.dev.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
DB_USER=postgres
DB_PASS=postgres
JWT_PRIVATE_KEY=your-jwt-private-key
NODE_ENV="production"
GATEWAY_PORT=8000
CORS_ALLOWED_ORIGINS=http://localhost:8000
SMTP_HOST=in-v3.mailjet.com
SMTP_PORT=465
SMTP_USER=changeme
SMTP_PASS=changeme
[email protected]
FRONTEND_URL=http://localhost:8000
12 changes: 12 additions & 0 deletions .env.production.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
DB_USER=postgres
DB_PASS=postgres
JWT_PRIVATE_KEY=your-jwt-private-key
NODE_ENV="production"
GATEWAY_PORT=8000
CORS_ALLOWED_ORIGINS=http://localhost:8000
SMTP_HOST=in-v3.mailjet.com
SMTP_PORT=465
SMTP_USER=changeme
SMTP_PASS=changeme
[email protected]
FRONTEND_URL=http://localhost:8000
36 changes: 36 additions & 0 deletions .github/workflows/build-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: build and push production server to dockerhub

on:
workflow_call:
inputs:
image_name:
type: string
required: true
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true

jobs:
build-and-push-server:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
context: "{{defaultContext}}:backend"
file: "Dockerfile.production"
tags: ${{ inputs.image_name }}
cache-from: type=gha
cache-to: type=gha,mode=max
35 changes: 35 additions & 0 deletions .github/workflows/build-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: build and push production client to dockerhub

on:
workflow_call:
inputs:
image_name:
type: string
required: true
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true

jobs:
build-and-push-client:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
context: "{{defaultContext}}:frontend"
file: "Dockerfile.production"
tags: ${{ inputs.image_name }}
cache-from: type=gha
49 changes: 49 additions & 0 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Test, compile and push client and server to production

on:
push:
branches: ["dev"]
workflow_dispatch:

jobs:
test-client:
uses: WildCodeSchool/2023-11-wns-bleu-g3/.github/workflows/tests-front.yml@dev

e2e-tests:
uses: WildCodeSchool/2023-11-wns-bleu-g3/.github/workflows/e2e.yml@dev

integration-tests:
uses: WildCodeSchool/2023-11-wns-bleu-g3/.github/workflows/integration-tests.yml@dev

build-and-push-server:
needs:
- integration-tests
- e2e-tests
uses: WildCodeSchool/2023-11-wns-bleu-g3/.github/workflows/build-backend.yml@dev
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
with:
image_name: greenfoot/greenfoot-back-dev

build-and-push-client:
needs:
- test-client
- e2e-tests
uses: WildCodeSchool/2023-11-wns-bleu-g3/.github/workflows/build-frontend.yml@dev
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
with:
image_name: greenfoot/greenfoot-front-dev

notify-vps:
needs:
- build-and-push-client
- build-and-push-server
runs-on: ubuntu-latest
steps:
- name: Call VPS webhook to update dev
uses: wei/curl@master
with:
args: https://ops.1123-bleu-3.wns.wilders.dev/hooks/update-dev
49 changes: 49 additions & 0 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Test, compile and push client and server to production

on:
push:
branches: ["main"]
workflow_dispatch:

jobs:
test-client:
uses: WildCodeSchool/2023-11-wns-bleu-g3/.github/workflows/tests-front.yml@main

e2e-tests:
uses: WildCodeSchool/2023-11-wns-bleu-g3/.github/workflows/e2e.yml@main

integration-tests:
uses: WildCodeSchool/2023-11-wns-bleu-g3/.github/workflows/integration-tests.yml@main

build-and-push-server:
needs:
- integration-tests
- e2e-tests
uses: WildCodeSchool/2023-11-wns-bleu-g3/.github/workflows/build-backend.yml@main
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
with:
image_name: greenfoot/greenfoot-back

build-and-push-client:
needs:
- test-client
- e2e-tests
uses: WildCodeSchool/2023-11-wns-bleu-g3/.github/workflows/build-frontend.yml@main
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
with:
image_name: greenfoot/greenfoot-front

notify-vps:
needs:
- build-and-push-client
- build-and-push-server
runs-on: ubuntu-latest
steps:
- name: Call VPS webhook to update production
uses: wei/curl@master
with:
args: https://ops.1123-bleu-3.wns.wilders.dev/hooks/update-production
56 changes: 56 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: e2e-tests

on:
pull_request:
workflow_call:

jobs:
e2e-tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./e2e-tests
steps:
- uses: actions/checkout@v4
# https://github.com/satackey/action-docker-layer-caching
# - uses: satackey/[email protected]
# # Ignore the failure of a step and avoid terminating the job.
# continue-on-error: true
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Dependencies
run: npm ci
- name: Install backend dependencies
run: cd ../backend && npm ci
# https://github.com/microsoft/playwright/issues/7249#issuecomment-1385567519
- name: Store Playwright's Version
run: |
PLAYWRIGHT_VERSION=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//')
echo "Playwright's Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: Cache Playwright Browsers for Playwright's Version
id: cache-playwright-browsers
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}
- name: Setup Playwright
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
- name: Make envfiles
run: |
cp .env.dev .env
cd ../backend/ && cp .env.dev .env
cd ../frontend/ && cp .env.dev .env && cp next-env.d.ts.dev next-env.d.ts
- name: Start app
run: npm run app:start
- name: Run Playwright tests
run: npm run test
- name: Store Artifacts from Failed Tests
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-results
path: e2e-tests/test-results/
retention-days: 7
27 changes: 27 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "integration-tests"

on:
pull_request:
workflow_call:

jobs:
integration-tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- name: Get the code
uses: actions/checkout@v4
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version: 20
- name: Make envfile
run: cp .env.dev .env
- name: Install deps
run: npm ci
- name: Start test DB
run: npm run testDB:wait
- name: Run tests
run: npm test
23 changes: 23 additions & 0 deletions .github/workflows/tests-front.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "test-frontend"

on:
pull_request:
workflow_call:

jobs:
test-client:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
steps:
- name: Get the code
uses: actions/checkout@v4
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install deps
run: npm ci
- name: Run tests
run: npm test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env.production
.env.dev
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Welcome to GreenFoot - From Les Pattes Carbone



Règles :

- le nom de la branche doit correspondre à la feature (ex: fix/nomDuFix ou feature/nomDeLaFeature)
- le reviewer gère sa review mais ne merge pas la PR et ne supprime pas la branche
- avant de push, récupérer la dernière version de dev pour éviter les conflits
- merger dev sur main en fin de sprint
- commits explicites
2 changes: 2 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.env
17 changes: 17 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:20.9.0-alpine3.17

RUN apk --no-cache add curl
RUN apk add make g++ python3 git
RUN npm i -g node-pre-gyp

WORKDIR /app

COPY package*.json ./

RUN npm i

COPY .env ./.env
COPY src ./src
COPY tsconfig.json ./tsconfig.json

CMD npm start
14 changes: 14 additions & 0 deletions backend/Dockerfile.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:20.9.0-alpine3.17

WORKDIR /app

COPY package*.json ./

RUN npm i

COPY src ./src
COPY tsconfig.json ./tsconfig.json

RUN npm run build

CMD npm run start:prod
3 changes: 3 additions & 0 deletions backend/__mocks__/nodemailer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const nodemailer = require('nodemailer');
const nodemailermock = require('nodemailer-mock').getMockFor(nodemailer);
module.exports = nodemailermock;
Loading

0 comments on commit c87ddee

Please sign in to comment.