From 4dc6edccec5aeed660a9da0dca2178e772ea3789 Mon Sep 17 00:00:00 2001 From: Sam Cranford Date: Fri, 23 May 2025 17:49:51 +0000 Subject: [PATCH 1/3] Add workflows and adjust configuration --- .github/workflows/github-python-workflow.yml | 35 ++++++++++++++++++++ .pre-commit-config.yaml | 7 ++++ pyproject.toml | 1 + 3 files changed, 43 insertions(+) create mode 100644 .github/workflows/github-python-workflow.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/github-python-workflow.yml b/.github/workflows/github-python-workflow.yml new file mode 100644 index 0000000..3c708ef --- /dev/null +++ b/.github/workflows/github-python-workflow.yml @@ -0,0 +1,35 @@ +# 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 Workflow + +on: + push: + branches: [main, develop] + pull_request: + branches: [main, develop] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.11 + uses: actions/setup-python@v3 + with: + python-version: "3.11" + - name: Install dependencies + run: | + pip install --upgrade pip setuptools && pip install .[dev] + - name: Run flake8 lint checks + 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=120 --statistics + - name: Run black format checks + run: black --check --diff ogc example || true # For now pass even if files need formatting + - name: Run pytest with coverage + run: | + pytest -v --cov=ogc diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..08cb765 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,7 @@ +repos: +- repo: https://github.com/ambv/black + rev: stable + hooks: + - id: black + language_version: python3 + files: (^ogc|^example) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 0145581..3411a4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,6 +57,7 @@ dev = [ # FORMATTING "pre_commit", "black", + "flake8", ] [tool.setuptools.packages.find] From 22ab88229f1a8ac564a431ad0bc1fd750b8d9352 Mon Sep 17 00:00:00 2001 From: Sam Cranford Date: Fri, 23 May 2025 18:40:01 +0000 Subject: [PATCH 2/3] Change setuptools version --- .github/workflows/github-python-workflow.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-python-workflow.yml b/.github/workflows/github-python-workflow.yml index 3c708ef..f433b8d 100644 --- a/.github/workflows/github-python-workflow.yml +++ b/.github/workflows/github-python-workflow.yml @@ -21,7 +21,9 @@ jobs: python-version: "3.11" - name: Install dependencies run: | - pip install --upgrade pip setuptools && pip install .[dev] + python -m pip install --upgrade pip + pip install setuptools==65.5.0 + pip install .[dev] - name: Run flake8 lint checks run: | # stop the build if there are Python syntax errors or undefined names From 93e303f718b8c940f861bc44d09848fe04cc1ec5 Mon Sep 17 00:00:00 2001 From: Sam Cranford Date: Fri, 23 May 2025 19:45:20 +0000 Subject: [PATCH 3/3] Fix versioning in workflow --- .github/workflows/github-python-workflow.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-python-workflow.yml b/.github/workflows/github-python-workflow.yml index f433b8d..b9056a1 100644 --- a/.github/workflows/github-python-workflow.yml +++ b/.github/workflows/github-python-workflow.yml @@ -15,15 +15,16 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true - name: Set up Python 3.11 uses: actions/setup-python@v3 with: python-version: "3.11" - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install setuptools==65.5.0 - pip install .[dev] + pip install --upgrade pip setuptools && pip install .[dev] - name: Run flake8 lint checks run: | # stop the build if there are Python syntax errors or undefined names