From 34b565e9d830d363c30cd1b170c958f28cec62fc Mon Sep 17 00:00:00 2001 From: Sirin Puenggun Date: Tue, 5 Sep 2023 20:23:41 +0700 Subject: [PATCH 1/5] Add github workflow more testing and linting --- .github/workflows/django.yml | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/django.yml diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml new file mode 100644 index 0000000..ddb53b5 --- /dev/null +++ b/.github/workflows/django.yml @@ -0,0 +1,42 @@ +name: Django Unit Tests and Linting + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.9, 3.10, 3.11] + + 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: Linting with flake8 + run: | + flake8 . + + - name: Run Tests + run: | + python manage.py test From 495b1a5aae4f4575cb78aab775b6e3a423e5bcc5 Mon Sep 17 00:00:00 2001 From: Sirin Puenggun Date: Tue, 5 Sep 2023 20:25:21 +0700 Subject: [PATCH 2/5] Update python version --- .github/workflows/django.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index ddb53b5..6a76b89 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -13,7 +13,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3.9, 3.10, 3.11] + python-version: [3.11.4] steps: - uses: actions/checkout@v3 From 7d568e9417020b966cc403e48f76cec6d68a5d1b Mon Sep 17 00:00:00 2001 From: Sirin Puenggun Date: Tue, 5 Sep 2023 20:28:45 +0700 Subject: [PATCH 3/5] Update django.yml --- .github/workflows/django.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 6a76b89..8b103a8 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -1,4 +1,4 @@ -name: Django Unit Tests and Linting +name: Unit Tests on: push: @@ -33,10 +33,6 @@ jobs: python -m pip install --upgrade pip pip install -r requirements.txt - - name: Linting with flake8 - run: | - flake8 . - - name: Run Tests run: | python manage.py test From 4b63eee439aa8d8eea792aa127c13b61e19f5fc8 Mon Sep 17 00:00:00 2001 From: Sirin Puenggun Date: Tue, 5 Sep 2023 20:33:10 +0700 Subject: [PATCH 4/5] Create flake8-lint.yml --- .github/workflows/flake8-lint.yml | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/flake8-lint.yml 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 From 92fb71bac9257586cb709c6ffbfa60be36932121 Mon Sep 17 00:00:00 2001 From: Sirin Puenggun Date: Tue, 5 Sep 2023 20:36:28 +0700 Subject: [PATCH 5/5] Add testing status badge to README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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/)