Skip to content

Add GitHub Actions Workflows for Django Testing, Pylint, and Black #9687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
24 changes: 24 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Black

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5

- name: Install dependencies
run: |
python -m venv .venv
source .vevn/bin/activate
python -m pip install --upgrade pip
pip install black

- name: Check code format with black
run: |
source .vevn/bin/activate
black --check .
42 changes: 42 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Django CI

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5

- name: Install Dependencies
run: |
python -m venv .venv
source .vevn/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

- name: Create a Django project and configure settings
run: |
source .vevn/bin/activate
python -m django startproject mysite
mv rest_framework mysite
cd mysite
echo "INSTALLED_APPS += ['rest_framework']" >> mysite/settings.py
echo "from django.urls import include" >> mysite/urls.py
echo "urlpatterns += [path('', include('rest_framework.urls'))]" >> mysite/urls.py

- name: Run Migrations, System checks and test
run: |
source .vevn/bin/activate
cd mysite
python manage.py migrate
python manage.py check
python manage.py test
24 changes: 24 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Pylint

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5

- name: Install dependencies
run: |
python -m venv .venv
source .vevn/bin/activate
python -m pip install --upgrade pip
pip install pylint

- name: Analysing the code with pylint
run: |
source .vevn/bin/activate
pylint .
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# [Django REST framework][docs]

[![build-status-image]][build-status]
[![django-ci-status-image]][django-ci-status]
[![pylint-status-image]][pylint-status]
[![black-status-image]][black-status]
[![coverage-status-image]][codecov]
[![pypi-version]][pypi]

Expand Down Expand Up @@ -181,6 +184,12 @@ Please see the [security policy][security-policy].
[build-status]: https://github.com/encode/django-rest-framework/actions/workflows/main.yml
[coverage-status-image]: https://img.shields.io/codecov/c/github/encode/django-rest-framework/master.svg
[codecov]: https://codecov.io/github/encode/django-rest-framework?branch=master
[django-ci-status-image]: https://github.com/encode/django-rest-framework/actions/workflows/django.yml/badge.svg
[django-ci-status]: https://github.com/encode/django-rest-framework/actions/workflows/django.yml
[pylint-status-image]: https://github.com/encode/django-rest-framework/actions/workflows/pylint.yml/badge.svg
[pylint-status]: https://github.com/encode/django-rest-framework/actions/workflows/pylint.yml
[black-status-image]: https://github.com/encode/django-rest-framework/actions/workflows/black.yml/badge.svg
[black-status]: https://github.com/encode/django-rest-framework/actions/workflows/black.yml
[pypi-version]: https://img.shields.io/pypi/v/djangorestframework.svg
[pypi]: https://pypi.org/project/djangorestframework/
[group]: https://groups.google.com/forum/?fromgroups#!forum/django-rest-framework
Expand Down
Loading