diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a71df2ae..fd601444 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,7 +1,7 @@ # These owners will be the default owners for everything in # the repo. Unless a later match takes precedence they # will be requested for review when someone opens a pull request. -* @tektronix/tm-devices-maintainers +* @tektronix/tm-devices-admin # Protect the configuration files .github/ @tektronix/tm-devices-admin diff --git a/.github/auto_assign.yml b/.github/auto_assign.yml new file mode 100644 index 00000000..e420d015 --- /dev/null +++ b/.github/auto_assign.yml @@ -0,0 +1,8 @@ +--- +addReviewers: true +addAssignees: author +reviewers: + - tektronix/tm-devices-maintainers +# Number of reviewers has no impact on GitHub teams +# Set 0 to add all the reviewers (default: 0) +numberOfReviewers: 0 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 5f4e37fe..94e30626 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -10,7 +10,6 @@ on: - cron: 17 16 * * 4 release: jobs: -# REMEMBER TO CHECK `LANGUAGE` MATRIX FOR CORRECT LANGUAGE SETTINGS analyze: name: Analyze runs-on: ubuntu-latest @@ -22,22 +21,14 @@ jobs: fail-fast: false matrix: language: [python] - # 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. - - # 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 + queries: security-extended,security-and-quality - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 with: diff --git a/.github/workflows/package-build.yml b/.github/workflows/package-build.yml index a80e0c9f..fc9fa1e8 100644 --- a/.github/workflows/package-build.yml +++ b/.github/workflows/package-build.yml @@ -1,5 +1,5 @@ --- -name: Package build & Upload +name: Package Build & Upload on: push: branches: [main] @@ -25,47 +25,50 @@ jobs: with: fetch-depth: 0 - uses: hynek/build-and-inspect-python-package@v1.5 -# # Upload to Test PyPI on every push to main -# test-pypi: -# name: Publish package to test.pypi.org -# environment: -# name: test-pypi -# url: https://test.pypi.org/p/tm_devices -# if: github.repository == 'tektronix/tm_devices' && github.event_name == 'push' && github.ref == 'refs/heads/main' -# runs-on: ubuntu-latest -# needs: build-package -# steps: -# - name: Download built package -# uses: actions/download-artifact@v3 -# with: -# name: Package -# path: dist -# - name: Upload package to Test PyPI -# uses: pypa/gh-action-pypi-publish@v1.8.8 -# with: -# repository-url: https://test.pypi.org/legacy/ -# -# # Upload to PyPI and create a tag in the repo after a GitHub Release is published -# pypi: -# name: Publish released package to pypi.org and create new tag in repo -# environment: -# name: pypi -# url: https://pypi.org/p/tm_devices -# if: github.repository == 'tektronix/tm_devices' && github.event.action == 'published' -# runs-on: ubuntu-latest -# needs: build-package -# permissions: -# contents: write -# steps: -# - uses: actions/checkout@v3 -# - name: Download built package -# uses: actions/download-artifact@v3 -# with: -# name: Package -# path: dist -# - name: Upload package to PyPI -# uses: pypa/gh-action-pypi-publish@v1.8.8 -# - name: Create and push tag -# run: |- -# git tag --annotate v${{ github.event.release.tag_name }} --message="${{ github.event.release.name }}" -# git push --tags + + # Upload to Test PyPI on every push to main + test-pypi: + name: Publish package to test.pypi.org + environment: + name: test-pypi + url: https://test.pypi.org/p/tm_devices + if: github.repository == 'tektronix/tm_devices' && github.event_name == 'push' + && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + needs: build-package + steps: + - name: Download built package + uses: actions/download-artifact@v3 + with: + name: Package + path: dist + - name: Upload package to Test PyPI + uses: pypa/gh-action-pypi-publish@v1.8.8 + with: + repository-url: https://test.pypi.org/legacy/ + + # Upload to PyPI and create a tag in the repo after a GitHub Release is published + pypi: + name: Publish released package to pypi.org and create new tag in repo + environment: + name: pypi + url: https://pypi.org/p/tm_devices + if: github.repository == 'tektronix/tm_devices' && github.event_name == 'release' + && github.event.action == 'published' + runs-on: ubuntu-latest + needs: build-package + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + - name: Download built package + uses: actions/download-artifact@v3 + with: + name: Package + path: dist + - name: Upload package to PyPI + uses: pypa/gh-action-pypi-publish@v1.8.8 + - name: Create and push tag + run: |- + git tag --annotate v${{ github.event.release.tag_name }} --message="${{ github.event.release.name }}" + git push --tags diff --git a/.github/workflows/test-code.yml b/.github/workflows/test-code.yml index b30ee019..5f48e9fb 100644 --- a/.github/workflows/test-code.yml +++ b/.github/workflows/test-code.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - platform: [ubuntu-latest, windows-latest] # TODO: add "macos-latest" back to the platform list + platform: [ubuntu-latest, windows-latest, macos-latest] python-version: ['3.8', '3.9', '3.10', '3.11'] steps: - uses: actions/checkout@v3 @@ -44,7 +44,7 @@ jobs: strategy: fail-fast: false matrix: - os_name: [ubuntu, windows] # TODO: add "macos" back to the os_name list + os_name: [ubuntu, windows, macos] steps: - uses: actions/checkout@v3 - name: Set up Python @@ -64,12 +64,12 @@ jobs: name: artifact_${{ matrix.os_name }}_tests path: .results_*/** # TODO: look into using https://github.com/mikepenz/action-junit-report for a junit report -# - name: Upload coverage to Codecov -# uses: codecov/codecov-action@v3 -# with: -# files: ./.coverage.tests -# name: codecov-${{ matrix.os_name }} -# fail_ci_if_error: true + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + files: ./.coverage.tests + name: codecov-${{ matrix.os_name }} + fail_ci_if_error: true # Check that all jobs passed check-tests-passed: if: always() diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 72d135a6..2c748d4b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,6 +4,13 @@ default_stages: [pre-commit] ci: autofix_prs: false autoupdate_schedule: quarterly + skip: + - check-poetry + - toml-sort + - pylint + - pyright + - pyright-verifytypes + - pyroma repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 @@ -34,7 +41,7 @@ repos: - id: check-github-actions - id: check-github-workflows - repo: https://github.com/commitizen-tools/commitizen - rev: 3.7.0 + rev: 3.9.0 hooks: - id: commitizen stages: [commit-msg] @@ -114,12 +121,12 @@ repos: always_run: true args: [., --min=10] - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.287 + rev: v0.0.290 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 23.9.1 hooks: - id: black - repo: https://github.com/PyCQA/docformatter diff --git a/README.md b/README.md index 8e4103c4..fdb73482 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@

-Code testing status -Docs testing status -Package build status -Coverage status -CodeQL status +Code testing status +Docs testing status +Package build status +Coverage status +CodeQL status pre-commit enabled pre-commit status Documentation status diff --git a/src/tm_devices/__init__.py b/src/tm_devices/__init__.py index 45ab0fc9..f18ca098 100644 --- a/src/tm_devices/__init__.py +++ b/src/tm_devices/__init__.py @@ -4,12 +4,11 @@ Examples: >>> from tm_devices import DeviceManager - >>> with DeviceManager() as dm: # doctest: +ELLIPSIS + >>> with DeviceManager() as dm: # doctest: +SKIP ... print(dm.is_open) - 2... - Opening DeviceManager + 2023-09-21 01:50:16.031 - Opening DeviceManager True - - 2... - DeviceManager Closed + 2023-09-21 01:50:16.031 - DeviceManager Closed """ from importlib.metadata import version diff --git a/src/tm_devices/device_manager.py b/src/tm_devices/device_manager.py index a4a37a7b..edace027 100644 --- a/src/tm_devices/device_manager.py +++ b/src/tm_devices/device_manager.py @@ -117,6 +117,7 @@ from tm_devices.drivers.pi.pi_device import PIDevice from tm_devices.helpers import ( AliasDict, + check_for_update, ConnectionTypes, create_visa_connection, detect_visa_resource_expression, @@ -272,7 +273,7 @@ def __init__( (updates the current configuration options). external_device_drivers: An optional dict for passing in additional device drivers. """ - # TODO: # check_for_update() # import and uncomment this helper once the package is on PyPI + check_for_update() self._suppress_protection = False # Set up the DeviceManager self.__is_open = False diff --git a/src/tm_devices/drivers/api/rest_api/rest_api_device.py b/src/tm_devices/drivers/api/rest_api/rest_api_device.py index 9d160929..0f583bb0 100644 --- a/src/tm_devices/drivers/api/rest_api/rest_api_device.py +++ b/src/tm_devices/drivers/api/rest_api/rest_api_device.py @@ -412,7 +412,9 @@ def _send_request( # noqa: PLR0913,PLR0912,C901 status_code = response.status_code except AttributeError: try: - status_code = error.response.status_code + status_code = ( + error.response.status_code # pyright: ignore[reportOptionalMemberAccess] + ) except AttributeError: status_code = 503 return False, retval, status_code, error diff --git a/tests/test_docs.py b/tests/test_docs.py index 75b40696..e3f8de70 100644 --- a/tests/test_docs.py +++ b/tests/test_docs.py @@ -41,7 +41,6 @@ def test_docs_html(self) -> None: """Test creating html documentation.""" subprocess.check_call(shlex.split("make html")) # noqa: S603 - @pytest.mark.xfail(reason="tm_devices GitHub links don't work currently") @pytest.mark.order(2) def test_docs_linkcheck(self) -> None: """Run the linkcheck test for the documentation."""