Add github actions - Linting and Unit Tests

Add GitHub actions more testing and linting
This commit is contained in:
Sirin Puenggun 2023-09-05 20:39:23 +07:00 committed by GitHub
commit 4853f8d4fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 76 additions and 1 deletions

38
.github/workflows/django.yml vendored Normal file
View File

@ -0,0 +1,38 @@
name: Unit Tests
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.11.4]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Create and Activate Python Virtual Environment
run: |
python -m venv venv
source venv/bin/activate
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Tests
run: |
python manage.py test

36
.github/workflows/flake8-lint.yml vendored Normal file
View File

@ -0,0 +1,36 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Lint with Flake8
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11.4
uses: actions/setup-python@v3
with:
python-version: "3.11.4"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

View File

@ -1,4 +1,5 @@
## KU Polls: Online Survey Questions
[![Unit Tests](https://github.com/Sosokker/ku-polls/actions/workflows/django.yml/badge.svg)](https://github.com/Sosokker/ku-polls/actions/workflows/django.yml)
An application to conduct online polls and surveys based
on the [Django Tutorial project](https://docs.djangoproject.com/en/4.2/intro/tutorial01/), with additional features.
@ -67,4 +68,4 @@ All project documents are in the [Project Wiki](https://github.com/Sosokker/ku-p
- [Vision Statement](https://github.com/Sosokker/ku-polls/wiki/Vision-Statement)
- [Requirements](https://github.com/Sosokker/ku-polls/wiki/Requirements)
[django-tutorial](https://docs.djangoproject.com/en/4.2/intro/tutorial01/)
[django-tutorial](https://docs.djangoproject.com/en/4.2/intro/tutorial01/)