diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..1122e13 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,4 @@ +codecov: + require_ci_to_pass: true +comment: + require_changes: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd130e3..d166e59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: contents: read steps: - - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python 3.10 uses: actions/setup-python@v4 @@ -56,7 +56,7 @@ jobs: steps: - - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Start containers run: | @@ -99,7 +99,7 @@ jobs: - lint steps: - - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python 3.10 uses: actions/setup-python@v4 @@ -133,7 +133,7 @@ jobs: - test steps: - - uses: actions/checkout@v3 + uses: actions/checkout@v4 - uses: actions/download-artifact@v3 with: @@ -175,4 +175,4 @@ jobs: path: dist - name: Publish build to PyPI - uses: pypa/gh-action-pypi-publish@v1.8.8 + uses: pypa/gh-action-pypi-publish@v1.8.10 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..b8c211d --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,88 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: + - "main" + - "develop" + - "feature/**" + - "fix/**" + pull_request: + # The branches below must be a subset of the branches above + branches: + - "main" + - "develop" + schedule: + - cron: '43 10 * * 1' + +jobs: + analyze: + name: Analyze + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners + # Consider using larger runners for possible analysis time improvements. + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'python' ] + # CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ] + # Use only 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff --git a/CHANGELOG.md b/CHANGELOG.md index a94e2e9..de445a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.0] - 2023-10-16 + +### Added + +- CodeQL scanning via GitHub +- Codecov.io coverage shield + +### Changed + +- Updated pypa/gh-action-pypi-publish from 1.8.8 to 1.8.10 +- Updated actions/checkout from 3 to 4 +- Mis-spelled `gotenerg_url` for a `Client` is now `host` and no longer keyword only + ## [0.1.0] - 2023-10-15 ### Added diff --git a/README.md b/README.md index 832da62..60ecbde 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![PyPI - Version](https://img.shields.io/pypi/v/gotenberg-client.svg)](https://pypi.org/project/gotenberg-client) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/gotenberg-client.svg)](https://pypi.org/project/gotenberg-client) +[![codecov](https://codecov.io/gh/stumpylog/gotenberg-client/graph/badge.svg?token=PH25G91Q6J)](https://codecov.io/gh/stumpylog/gotenberg-client) --- diff --git a/pyproject.toml b/pyproject.toml index f62dba5..b11e949 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,6 +65,7 @@ dependencies = [ [tool.hatch.envs.default.scripts] version = "python3 --version" +pip-list = "pip list" test = "pytest --pythonwarnings=all {args:tests}" test-cov = "coverage run -m pytest --pythonwarnings=all {args:tests}" cov-clear = "coverage erase" @@ -76,13 +77,13 @@ cov-html = "coverage html" cov-json = "coverage json" cov = [ "version", + "pip-list", "cov-clear", "test-cov", "cov-report", "cov-json", "cov-html" ] -pip-list = "pip list" [[tool.hatch.envs.all.matrix]] python = ["3.8", "3.9", "3.10", "3.11", "3.12"] diff --git a/src/gotenberg_client/__about__.py b/src/gotenberg_client/__about__.py index ec4f41e..69bbe97 100644 --- a/src/gotenberg_client/__about__.py +++ b/src/gotenberg_client/__about__.py @@ -1,4 +1,4 @@ # SPDX-FileCopyrightText: 2023-present Trenton H # # SPDX-License-Identifier: MPL-2.0 -__version__ = "0.1.0" +__version__ = "0.2.0" diff --git a/src/gotenberg_client/_client.py b/src/gotenberg_client/_client.py index e384d29..6a8ce84 100644 --- a/src/gotenberg_client/_client.py +++ b/src/gotenberg_client/_client.py @@ -24,14 +24,14 @@ class GotenbergClient: def __init__( self, + host: str, *, - gotenerg_url: str, timeout: float = 30.0, log_level: int = logging.ERROR, http2: bool = True, ): # Configure the client - self._client = Client(base_url=gotenerg_url, timeout=timeout, http2=http2) + self._client = Client(base_url=host, timeout=timeout, http2=http2) # Set the log level logging.getLogger("httpx").setLevel(log_level) diff --git a/tests/conftest.py b/tests/conftest.py index a8ff35c..e394eec 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -20,5 +20,5 @@ @pytest.fixture() def client() -> GotenbergClient: - with GotenbergClient(gotenerg_url=GOTENBERG_URL, log_level=logging.INFO) as client: + with GotenbergClient(host=GOTENBERG_URL, log_level=logging.INFO) as client: yield client diff --git a/tests/test_merge.py b/tests/test_merge.py index 7ccc1f6..fc869fc 100644 --- a/tests/test_merge.py +++ b/tests/test_merge.py @@ -12,6 +12,7 @@ from tests.conftest import SAMPLE_DIR from tests.conftest import SAVE_DIR from tests.conftest import SAVE_OUTPUTS +from tests.utils import call_run_with_server_error_handling @pytest.fixture() @@ -41,7 +42,7 @@ def test_merge_files_pdf_a( pike_format: str, ): with client.merge.merge() as route: - resp = route.merge(create_files).pdf_format(gt_format).run() + resp = call_run_with_server_error_handling(route.merge(create_files).pdf_format(gt_format)) assert resp.status_code == codes.OK assert "Content-Type" in resp.headers @@ -63,7 +64,7 @@ def test_pdf_a_multiple_file( create_files: List[Path], ): with client.merge.merge() as route: - resp = route.merge(create_files).run() + resp = call_run_with_server_error_handling(route.merge(create_files)) assert resp.status_code == codes.OK assert "Content-Type" in resp.headers