Skip to content

Merge branch 'dev' of https://github.com/HangHae-plus-2-9/TDD into dev #132

Merge branch 'dev' of https://github.com/HangHae-plus-2-9/TDD into dev

Merge branch 'dev' of https://github.com/HangHae-plus-2-9/TDD into dev #132

Workflow file for this run

name: ci-cd-pipeline
on:
push:
branches:
- dev
paths-ignore:
- 'docs/**'
- 'README.md'
- 'artillery/**'
permissions:
id-token: write
contents: read
env:
SHA: ${{ github.sha }}
ECR_REPOSITORY_NESTJS: 'hh-nestjs'
JWT_SECRET: ${{ secrets.JWT_SECRET }}
JWT_EXPIRES_IN: ${{ secrets.JWT_EXPIRES_IN }}
DATABASE_CONNECTION: 'postgres'
DATABASE_HOST: 'localhost'
DATABASE_PORT: '5432'
DATABASE_USERNAME: 'postgres'
DATABASE_PASSWORD: 'postgres'
DATABASE_NAME: 'postgres'
GITHUB_ACTIONS: false
jobs:
test:
name: test nestjs
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup node
uses: actions/[email protected]
with:
node-version: '18'
cache: 'npm'
- name: Cache node modules
uses: actions/[email protected]
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm install
- name: Run lint
run: npm run lint
- name: Check database state
run: |
sudo apt-get install -y postgresql-client
PGPASSWORD=postgres psql -h localhost -U postgres -d postgres -c "\dt"
- name: Run tests
run: npm run test
- name: Migrate database
run: npm run migration:run
- name: Run e2e tests
run: npm run test:e2e
- name: Notify Slack on Failure
if: failure()
uses: 8398a7/[email protected]
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
author_name: ${{ github.actor }}
channel: ${{ secrets.SLACK_CHANNEL }}
username: ${{ secrets.SLACK_USERNAME }}
text: 'Tests failed! :x:'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Notify Slack on Success
if: success()
uses: 8398a7/[email protected]
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
author_name: ${{ github.actor }}
channel: ${{ secrets.SLACK_CHANNEL }}
username: ${{ secrets.SLACK_USERNAME }}
text: 'Tests passed! :white_check_mark:'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}