-
-
Save andrzejsliwa/b6a4732ae07cefa5493c6103a4197265 to your computer and use it in GitHub Desktop.
An example Github Actions for Python + Pipenv + Postgres + Pyright
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .github/workflows/app.yaml | |
name: My Python Project | |
on: push | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
services: | |
db_service: | |
image: postgres | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_DB: postgres | |
POSTGRES_PASSWORD: postgres | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
# Maps tcp port 5432 on service container to the host | |
- 5432:5432 | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v2 | |
# Setup Python (faster than using Python container) | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.7" | |
- name: Install pipenv | |
run: | | |
python -m pip install --upgrade pipenv wheel | |
- id: cache-pipenv | |
uses: actions/cache@v1 | |
with: | |
path: ~/.local/share/virtualenvs | |
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }} | |
- name: Install dependencies | |
if: steps.cache-pipenv.outputs.cache-hit != 'true' | |
run: | | |
pipenv install --deploy --dev | |
- name: Run test suite | |
run: | | |
pipenv run test -svvv | |
env: | |
TEST_DB_HOST: localhost | |
TEST_DB_NAME: postgres | |
TEST_DB_PASS: postgres | |
TEST_DB_PORT: 5432 | |
TEST_DB_USER: postgres | |
- name: Run linter | |
run: | | |
pipenv run lint | |
- name: Run formatting check | |
run: | | |
pipenv run format --check | |
- name: Setup node.js (for pyright) | |
uses: actions/setup-node@v1 | |
with: | |
node-version: "12" | |
- name: Run type checking | |
run: | | |
npm install -g pyright | |
pipenv run typecheck |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment