diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..57c514d --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,43 @@ +--- + +name: checks +on: [push] +jobs: + test: + name: unit tests + runs-on: ubuntu-20.04 + services: + db: + image: postgres:15-alpine + env: + POSTGRES_DB: ${{ secrets.DB_NAME }} + POSTGRES_USER: ${{ secrets.DB_USER }} + POSTGRES_PASSWORD: ${{ secrets.DB_PASSWORD }} + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 + + + steps: + - name: Login with actions + uses: docker/login-action@v1 + with: + username: ${{secrets.DOCKERHUB_USER}} + password: ${{secrets.DOCKERHUB_TOKEN}} + + - name: check out + uses: actions/checkout@v2 + + - name: Set up project secrets + env: + SECRET_KEY: ${{ secrets.SECRET_KEY }} + DB_USER: ${{ secrets.DB_USER }} + DB_PASSWORD: ${{ secrets.DB_PASSWORD }} + DB_NAME: ${{ secrets.DB_NAME }} + run: | + echo "SECRET_KEY=${SECRET_KEY}" >> $GITHUB_ENV + echo "DB_USER=${DB_USER}" >> $GITHUB_ENV + echo "DB_PASSWORD=${DB_PASSWORD}" >> $GITHUB_ENV + echo "DB_NAME=${DB_NAME}" >> $GITHUB_ENV + - name: Test + run: docker compose run --rm ab sh -c "python3 manage.py test" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 670001b..01cdbbb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,13 +15,13 @@ services: - DB_HOST=${DB_HOST} - DB_PASSWORD=${DB_PASSWORD} - DB_PORT=${DB_PORT} - - DEBUG=${DEBUG} command: > sh -c "python manage.py makemigrations && python manage.py migrate && gunicorn gap.wsgi:application --bind 0.0.0.0:8000 --reload" depends_on: - db + tty: true db: image: postgres:15-alpine volumes: diff --git a/src/gap/settings/dev.py b/src/gap/settings/dev.py index 1be2eb5..1067ae9 100644 --- a/src/gap/settings/dev.py +++ b/src/gap/settings/dev.py @@ -1,4 +1,3 @@ from .base import * - - +ALLOWED_HOSTS = ["0.0.0.0", "localhost"] DEBUG=True \ No newline at end of file diff --git a/src/gap/settings/production.py b/src/gap/settings/production.py index 760a65a..64c9e2d 100644 --- a/src/gap/settings/production.py +++ b/src/gap/settings/production.py @@ -1,4 +1,4 @@ from .base import * -ALLOWED_HOSTS = ["127.0.0.1:8000"] +ALLOWED_HOSTS = ["localhost"] DEBUG=False \ No newline at end of file