From f8ea83e51dab39e02c56698695e8a3d64da6206f Mon Sep 17 00:00:00 2001 From: Maruan Biasi Date: Tue, 11 Mar 2025 00:04:33 -0300 Subject: [PATCH 1/6] Create python-app.yml --- .github/workflows/python-app.yml | 58 ++++++++++++++++++++++++++++++++ 1 file changed, 58 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..4c12644 --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,58 @@ +name: Python application + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + python-version: [3.8, 3.9, 3.10, 3.11] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Cache pip on Linux + if: runner.os == 'Linux' + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Cache pip on Windows + if: runner.os == 'Windows' + uses: actions/cache@v3 + with: + path: C:\Users\runneradmin\AppData\Local\pip\Cache + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install dependencies + shell: bash + 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 + shell: bash + 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 coverage + shell: bash + run: | + coverage run -m pytest + coverage report From 6681531813ecb9f4294937fda2966de243f059b8 Mon Sep 17 00:00:00 2001 From: Maruan Biasi Date: Tue, 11 Mar 2025 00:07:15 -0300 Subject: [PATCH 2/6] remove coverage report --- .github/workflows/python-app.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 4c12644..8f5fbeb 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -42,7 +42,7 @@ jobs: shell: bash 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 shell: bash @@ -51,8 +51,7 @@ jobs: 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 coverage + - name: Test with pytest shell: bash run: | - coverage run -m pytest - coverage report + pytest From 906c6cc2c5fc4264243e6ac42aae2e8c10b062ba Mon Sep 17 00:00:00 2001 From: Maruan Biasi Date: Tue, 11 Mar 2025 00:10:14 -0300 Subject: [PATCH 3/6] fix python version name --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 8f5fbeb..968c85c 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -49,7 +49,7 @@ jobs: 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. + # Exit-zero treats all errors as warnings. flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest shell: bash From b12aff9f21784c660d0a1e8cb1bbc2d06ae143a2 Mon Sep 17 00:00:00 2001 From: Maruan Biasi Date: Tue, 11 Mar 2025 00:11:47 -0300 Subject: [PATCH 4/6] please work --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 968c85c..50905d2 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - python-version: [3.8, 3.9, 3.10, 3.11] + python-version: [3.10] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} From e952638a57a9f1a58ac5f895fd2caadb6b983e45 Mon Sep 17 00:00:00 2001 From: Maruan Biasi Date: Tue, 11 Mar 2025 00:12:33 -0300 Subject: [PATCH 5/6] fix workflow --- .github/workflows/python-app.yml | 68 ++++++++++++-------------------- 1 file changed, 25 insertions(+), 43 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 50905d2..1168bd9 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -1,3 +1,6 @@ +# 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: Python application on: @@ -11,47 +14,26 @@ permissions: jobs: build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest] - python-version: [3.10] + + runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - name: Cache pip on Linux - if: runner.os == 'Linux' - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - name: Cache pip on Windows - if: runner.os == 'Windows' - uses: actions/cache@v3 - with: - path: C:\Users\runneradmin\AppData\Local\pip\Cache - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - name: Install dependencies - shell: bash - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - shell: bash - 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. - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - shell: bash - run: | - pytest + - uses: actions/checkout@v4 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + 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 From d106951a895410f69790051b7dd53e944bfdc6bc Mon Sep 17 00:00:00 2001 From: Maruan Biasi Date: Tue, 11 Mar 2025 00:13:52 -0300 Subject: [PATCH 6/6] add windows to workflow --- .github/workflows/python-app.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 1168bd9..d493ad1 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -1,4 +1,4 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python +# This workflow will install Python dependencies 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: Python application @@ -14,9 +14,11 @@ permissions: jobs: build: - - runs-on: ubuntu-latest - + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + steps: - uses: actions/checkout@v4 - name: Set up Python 3.10 @@ -26,14 +28,13 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest + pip install flake8 if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + shell: bash - 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 + shell: bash