Skip to content

update

update #100

Workflow file for this run

name: ci-cd-pipeline
on:
push:
branches:
- dev
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: echo envs
env:
GITHUB_ACTIONS: false
run: |
echo $DATABASE_CONNECTION
echo $DATABASE_HOST
echo $DATABASE_PORT
echo $DATABASE_USERNAME
echo $DATABASE_PASSWORD
echo $DATABASE_NAME
echo $GITHUB_ACTIONS
ls -al
- name: migrate database
run: npm run migration:run
- name: run e2e tests
# env:
# GITHUB_ACTIONS: true # TODO: 너무 지저분하다.. Github Actions의 postgres는 ssl을 사용하는듯
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 }}