diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml new file mode 100644 index 0000000..8b103a8 --- /dev/null +++ b/.github/workflows/django.yml @@ -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 diff --git a/.github/workflows/flake8-lint.yml b/.github/workflows/flake8-lint.yml new file mode 100644 index 0000000..a8a2655 --- /dev/null +++ b/.github/workflows/flake8-lint.yml @@ -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 diff --git a/README.md b/README.md index 03dd60e..26841a6 100644 --- a/README.md +++ b/README.md @@ -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/) \ No newline at end of file +[django-tutorial](https://docs.djangoproject.com/en/4.2/intro/tutorial01/)