Skip to content

Commit

Permalink
Release worflow changes (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-castro authored Nov 10, 2024
2 parents d53270a + a11d2da commit a690815
Show file tree
Hide file tree
Showing 35 changed files with 407 additions and 399 deletions.
41 changes: 41 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs.
# More information at https://editorconfig.org

root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,ts,jsx,tsx,html,css,scss,json,yml,yaml,md}]
charset = utf-8

# 4 space indentation for TypeScript files
[*.ts]
indent_size = 4

# 2 space indentation for YAML files
[*.{yml,yaml}]
indent_size = 2
# 2 space indentation for JSON files
[*.json]
indent_size = 2

# 2 space indentation for Markdown files
[*.md]
indent_size = 2

# 2 space indentation for HTML files
[*.html]
indent_size = 2

# 2 space indentation for CSS and SCSS files
[*.{css,scss}]
indent_size = 2
9 changes: 6 additions & 3 deletions .env.exemple → .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Docker image tag
TAG=local

GATEWAY_PORT=8012

JWT_SECRET_KEY=defaultvalue

# The service name in docker-compose
DATABASE_HOST_PROD=db
DATABASE_HOST_DEV=db

DATABASE_HOST=db
DATABASE_PORT=5432
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=password
Expand Down
39 changes: 39 additions & 0 deletions .github/actions/build-and-push/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and push
description: Build and push Docker images to Docker Hub

inputs:
environment:
description: "Environment to build images for"
required: true
service:
description: "Service to build and push"
required: true
dockerhub_username:
description: "Docker Hub username"
required: true
dockerhub_token:
description: "Docker Hub token"
required: true

runs:
using: "composite"
steps:
- name: Check inputs
shell: bash
if: ${{ inputs.environment != 'dev' && inputs.environment != 'prod' }}
run: echo "Wrong environment. Expected 'dev' or 'prod', got '${{ inputs.environment }}'" && exit 1

- name: Checkout repository
uses: actions/checkout@v2

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ inputs.dockerhub_username }}
password: ${{ inputs.dockerhub_token }}

- name: Build and push backend image
shell: bash
run: |
docker build -t pierrecastro/healthcheck-${{ matrix.service }}:${{ inputs.environment }} ${{ matrix.service }}
docker push pierrecastro/healthcheck-${{ matrix.service }}:${{ inputs.environment }}
26 changes: 26 additions & 0 deletions .github/workflows/build-and-push-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Compile and push dev images

on:
push:
branches: ["develop"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
service: [frontend, backend]
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Build and push dev images
uses: ./.github/actions/build-and-push
with:
environment: "dev"
service: ${{ matrix.service }}
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
27 changes: 27 additions & 0 deletions .github/workflows/build-and-push-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Compile and push prod images

on:
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
service: [frontend, backend]
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Build and push prod images
uses: ./.github/actions/build-and-push
with:
environment: "prod"
service: ${{ matrix.service }}
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}

14 changes: 0 additions & 14 deletions .github/workflows/healtcheck-backend-tests.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/workflows/healthcheck-tests.yml

This file was deleted.

55 changes: 55 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Tests

on:
pull_request:
branches:
- main
- develop
types:
- opened
- synchronize
- reopened

jobs:
backend_integration:
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend/tests/integration
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Run backend, APIgateway and database services in a dedicated container
run: docker compose -f docker-compose.yml up -d
- name: Install dependencies
run: npm i
- name: Run backend tests
run: npm run test

fontend_unit:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Install dependencies
run: npm i
- name: Run frontend tests
run: npm run test

e2e:
runs-on: ubuntu-latest
defaults:
run:
working-directory: e2e
if: false # Disable e2e tests, deprecated at the moment
timeout-minutes: 2
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Run backend, frontend, APIgateway and database services in a dedicated container
run: docker compose -f docker-compose.yml up -d
- name: Run e2e tests
run: docker compose exec playwright npx playwright test
44 changes: 0 additions & 44 deletions .github/workflows/staging-backend.dev.yml

This file was deleted.

44 changes: 0 additions & 44 deletions .github/workflows/staging-backend.yml

This file was deleted.

44 changes: 0 additions & 44 deletions .github/workflows/staging-frontend.dev.yml

This file was deleted.

Loading

0 comments on commit a690815

Please sign in to comment.