Skip to content

Instantly share code, notes, and snippets.

@ridwanray
Created August 15, 2022 08:08
Show Gist options
  • Select an option

  • Save ridwanray/5a5ba31aafef9340cd9c73a6dfe5f9f2 to your computer and use it in GitHub Desktop.

Select an option

Save ridwanray/5a5ba31aafef9340cd9c73a6dfe5f9f2 to your computer and use it in GitHub Desktop.
github actions for postgres and redis for python app
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: mysite-app
on:
push:
branches: [ test-workflow ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: github_actions
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: psycopg2 prerequisites
run: sudo apt-get install python-dev libpq-dev
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r devreq.txt
- name: Run migrations
run: python manage.py migrate --settings=mysite.dev
- name: Test with pytest
run: pytest
env:
REDIS_HOST: localhost
REDIS_PORT: 6379
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment