From 5b53944673b5fde0357621e008752659874c40e3 Mon Sep 17 00:00:00 2001 From: Jack H Date: Tue, 19 Nov 2024 22:54:33 -0600 Subject: [PATCH 1/2] Create python-app.yml --- .github/workflows/python-app.yml | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/python-app.yml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 0000000..347d0d2 --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,54 @@ +name: Python application + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: [3.8, 3.9, 3.10] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache pip dependencies + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest coverage + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Lint with flake8 + run: | + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + - name: Test with pytest + run: | + pytest + + - name: Generate coverage report + run: | + coverage run -m pytest + coverage report From b0b9e46b49afd2097586d6ec4489570247cd3db2 Mon Sep 17 00:00:00 2001 From: Jack H Date: Tue, 19 Nov 2024 22:56:36 -0600 Subject: [PATCH 2/2] Update python-app.yml --- .github/workflows/python-app.yml | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 347d0d2..ca58a19 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -11,44 +11,26 @@ permissions: jobs: build: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.8, 3.9, 3.10] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - - name: Set up Python + - name: Set up Python 3.10 uses: actions/setup-python@v3 with: - python-version: ${{ matrix.python-version }} - - - name: Cache pip dependencies - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - + python-version: "3.10" - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest coverage + pip install flake8 pytest 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 - - name: Test with pytest run: | pytest - - - name: Generate coverage report - run: | - coverage run -m pytest - coverage report