From d7229f9bfc3191b1df505f06afc3c86893885f4f Mon Sep 17 00:00:00 2001 From: Daniel Dugovic Date: Thu, 21 Nov 2024 03:11:35 -0600 Subject: [PATCH] Create python-app.yml and dependabot.yml --- .github/dependabot.yml | 9 ++++ .github/workflows/dependabot-merge.yml | 22 ++++++++++ .github/workflows/python-app.yml | 61 ++++++++++++++++++++++++++ Lichess.spec | 34 ++++++++++++++ Makefile | 3 ++ pytest.ini | 5 +++ tests/test_helper.py | 4 ++ 7 files changed, 138 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/dependabot-merge.yml create mode 100644 .github/workflows/python-app.yml create mode 100644 Lichess.spec create mode 100644 Makefile create mode 100644 pytest.ini create mode 100644 tests/test_helper.py diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5d2b291 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 +updates: +- package-ecosystem: pip + directory: "/" + schedule: + interval: daily + time: "00:00" + timezone: America/Chicago + open-pull-requests-limit: 10 diff --git a/.github/workflows/dependabot-merge.yml b/.github/workflows/dependabot-merge.yml new file mode 100644 index 0000000..3a1cf2b --- /dev/null +++ b/.github/workflows/dependabot-merge.yml @@ -0,0 +1,22 @@ +name: Dependabot auto-merge +on: pull_request + +permissions: + pull-requests: write + contents: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v1.1.1 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + - name: Enable auto-merge for Dependabot PRs + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 0000000..c8edc9c --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,61 @@ +# 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: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: "Get pip cache dir" + id: pip-cache + run: | + echo "::set-output name=dir::$(pip cache dir)" + - uses: "actions/cache@v4" + with: + path: ${{ steps.pip-cache.outputs.dir }} + 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 pytest-cov + 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: | + make test + + - name: Package Application + uses: Alcance-Innovation-Consulting/pyinstaller-action-windows@main + with: + path: . + spec: Lichess.spec + + - uses: actions/upload-artifact@v4 + with: + name: Lichess + path: dist/windows diff --git a/Lichess.spec b/Lichess.spec new file mode 100644 index 0000000..53a1be6 --- /dev/null +++ b/Lichess.spec @@ -0,0 +1,34 @@ +# -*- mode: python ; coding: utf-8 -*- + + +block_cipher = None + + +a = Analysis(['main.py'], + pathex=['/home/lichess/Lichess'], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=True, + cipher=block_cipher, + noarchive=False) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) +exe = EXE(pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='Lichess', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True ) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d6dac60 --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +.PHONY: test +test: + PYTHONPATH=. pytest diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..9d3405c --- /dev/null +++ b/pytest.ini @@ -0,0 +1,5 @@ +[pytest] +minversion = 6.0 +addopts = -vvv --cov-config .coveragerc --cov-report term --cov=. -rx -s +testpaths = + tests diff --git a/tests/test_helper.py b/tests/test_helper.py new file mode 100644 index 0000000..165aac0 --- /dev/null +++ b/tests/test_helper.py @@ -0,0 +1,4 @@ +from helper import * + +def test_euclidean_distance(): + assert euclidean_distance([0, 3], [4, 0]) == 5