Skip to content

approve_edit

approve_edit #485

Workflow file for this run

# Github Actions CI/CD
name: Checks
on: [push]
jobs:
build:
runs-on: ubuntu-latest
env:
RDS_HOSTNAME: ${{ secrets.RDS_HOSTNAME }}
RDS_DB_NAME: ${{ secrets.RDS_DB_NAME }}
RDS_USERNAME: ${{ secrets.RDS_USERNAME }}
RDS_PASSWORD: ${{ secrets.RDS_PASSWORD }}
RDS_DB_PORT: ${{ secrets.RDS_DB_PORT }}
steps:
- uses: actions/checkout@v3
- name: Create .env file
run: |
echo "RDS_HOSTNAME=${RDS_HOSTNAME}" >> .env
echo "RDS_DB_NAME=${RDS_DB_NAME}" >> .env
echo "RDS_USERNAME=${RDS_USERNAME}" >> .env
echo "RDS_PASSWORD=${RDS_PASSWORD}" >> .env
echo "RDS_DB_PORT=${RDS_DB_PORT}" >> .env
echo "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" >> .env
echo "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" >> .env
echo "AWS_STORAGE_BUCKET_NAME=${AWS_STORAGE_BUCKET_NAME}" >> .env
echo "AWS_S3_REGION_NAME=${AWS_S3_REGION_NAME}" >> .env
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: Drop existing test database
env:
PGPASSWORD: ${{ secrets.RDS_PASSWORD }}
run: |
psql -h ${{ secrets.RDS_HOSTNAME }} -U ${{ secrets.RDS_USERNAME }} -d ${{ secrets.RDS_DB_NAME }} -p ${{ secrets.RDS_DB_PORT }} -c "DROP DATABASE IF EXISTS test_postgres;"
- name: Create new test database
env:
PGPASSWORD: ${{ secrets.RDS_PASSWORD }}
run: |
psql -h ${{ secrets.RDS_HOSTNAME }} -U ${{ secrets.RDS_USERNAME }} -d ${{ secrets.RDS_DB_NAME }} -p ${{ secrets.RDS_DB_PORT }} -c "CREATE DATABASE test_postgres;"
- name: Build and run Docker containers
run: |
docker-compose build
docker-compose up -d
- name: Run tests with coverage and generate report
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_STORAGE_BUCKET_NAME: ${{ secrets.AWS_STORAGE_BUCKET_NAME }}
AWS_S3_REGION_NAME: ${{ secrets.AWS_S3_REGION_NAME }}
run: |
docker-compose run --rm app sh -c "coverage run --data-file=/tmp/.coverage manage.py test --noinput && coverage report --data-file=/tmp/.coverage"
# - name: Run security checks
# run: docker-compose run --rm app safety check
# safety 설치해야 함
- name: Tear down Docker containers
run: docker-compose down