From b28a4f3f2be36e2455591413b776fac69a75bacb Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Tue, 27 Aug 2024 11:23:33 -0700 Subject: [PATCH 1/2] ci: Set current version to v0.0.1 --- .github/workflows/_reusable-package-release.yml | 4 ++-- .github/workflows/_reusable-package-testpypi.yml | 2 +- .../_reusable-update-python-and-pre-commit-dependencies.yml | 2 +- actions/create_unique_testpypi_version/readme.md | 2 +- actions/find_unreleased_changelog_items/readme.md | 2 +- actions/update_development_dependencies/readme.md | 2 +- pyproject.toml | 2 +- scripts/bump_version_in_files.py | 6 +++++- workflows/check-api-for-breaking-changes.md | 2 +- workflows/codeql-analysis.md | 2 +- workflows/enforce-community-standards.md | 2 +- workflows/package-build.md | 2 +- workflows/package-release.md | 2 +- workflows/package-testpypi.md | 2 +- workflows/publish-api-comparison.md | 2 +- workflows/publish-test-results.md | 2 +- workflows/sbom-scan.md | 2 +- workflows/test-code.md | 2 +- workflows/test-docs.md | 2 +- workflows/update-python-and-pre-commit-dependencies.md | 2 +- 20 files changed, 25 insertions(+), 21 deletions(-) diff --git a/.github/workflows/_reusable-package-release.yml b/.github/workflows/_reusable-package-release.yml index 8154464a..23d4306e 100644 --- a/.github/workflows/_reusable-package-release.yml +++ b/.github/workflows/_reusable-package-release.yml @@ -96,7 +96,7 @@ jobs: previous-changelog-filepath: ${{ inputs.previous-changelog-filepath }} previous-release-notes-filepath: ${{ inputs.previous-release-notes-filepath }} - if: ${{ !endsWith(github.repository, '/python-package-ci-cd') }} # Run the public action when this is run outside the python-package-ci-cd repository - uses: tektronix/python-package-ci-cd/actions/find_unreleased_changelog_items@v0.0.0 + uses: tektronix/python-package-ci-cd/actions/find_unreleased_changelog_items@v0.0.1 with: release-level: ${{ inputs.release-level }} previous-changelog-filepath: ${{ inputs.previous-changelog-filepath }} @@ -126,7 +126,7 @@ jobs: previous-changelog-filepath: ${{ inputs.previous-changelog-filepath }} previous-release-notes-filepath: ${{ inputs.previous-release-notes-filepath }} - if: ${{ !endsWith(github.repository, '/python-package-ci-cd') }} # Run the public action when this is run outside the python-package-ci-cd repository - uses: tektronix/python-package-ci-cd/actions/find_unreleased_changelog_items@v0.0.0 + uses: tektronix/python-package-ci-cd/actions/find_unreleased_changelog_items@v0.0.1 with: previous-changelog-filepath: ${{ inputs.previous-changelog-filepath }} previous-release-notes-filepath: ${{ inputs.previous-release-notes-filepath }} diff --git a/.github/workflows/_reusable-package-testpypi.yml b/.github/workflows/_reusable-package-testpypi.yml index 3197caf2..15f0f770 100644 --- a/.github/workflows/_reusable-package-testpypi.yml +++ b/.github/workflows/_reusable-package-testpypi.yml @@ -33,7 +33,7 @@ jobs: with: package-name: ${{ inputs.package-name }} - if: ${{ !endsWith(github.repository, '/python-package-ci-cd') }} # Run the public action when this is run outside the python-package-ci-cd repository - uses: tektronix/python-package-ci-cd/actions/create_unique_testpypi_version@v0.0.0 + uses: tektronix/python-package-ci-cd/actions/create_unique_testpypi_version@v0.0.1 id: create-version with: package-name: ${{ inputs.package-name }} diff --git a/.github/workflows/_reusable-update-python-and-pre-commit-dependencies.yml b/.github/workflows/_reusable-update-python-and-pre-commit-dependencies.yml index ff1921e6..f08f7e76 100644 --- a/.github/workflows/_reusable-update-python-and-pre-commit-dependencies.yml +++ b/.github/workflows/_reusable-update-python-and-pre-commit-dependencies.yml @@ -93,7 +93,7 @@ jobs: pre-commit-hook-skip-list: ${{ inputs.pre-commit-hook-skip-list }} export-dependency-groups: ${{ inputs.export-dependency-groups }} - if: ${{ !endsWith(github.repository, '/python-package-ci-cd') }} # Run the public action when this is run outside the python-package-ci-cd repository - uses: tektronix/python-package-ci-cd/actions/update_development_dependencies@v0.0.0 + uses: tektronix/python-package-ci-cd/actions/update_development_dependencies@v0.0.1 with: dependency-dict: ${{ inputs.dependency-dict }} update-pre-commit: ${{ inputs.update-pre-commit }} diff --git a/actions/create_unique_testpypi_version/readme.md b/actions/create_unique_testpypi_version/readme.md index a84da229..a8b1a834 100644 --- a/actions/create_unique_testpypi_version/readme.md +++ b/actions/create_unique_testpypi_version/readme.md @@ -37,7 +37,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: ./actions/create_unique_testpypi_version + - uses: tektronix/python-package-ci-cd/actions/create_unique_testpypi_version@v0.0.1 id: create-version with: package-name: my-package # required diff --git a/actions/find_unreleased_changelog_items/readme.md b/actions/find_unreleased_changelog_items/readme.md index 78f6b742..4ffc7576 100644 --- a/actions/find_unreleased_changelog_items/readme.md +++ b/actions/find_unreleased_changelog_items/readme.md @@ -48,7 +48,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: tektronix/python-package-ci-cd/actions/find_unreleased_changelog_items@main # it is recommended to use the latest release tag instead of `main` + - uses: tektronix/python-package-ci-cd/actions/find_unreleased_changelog_items@v0.0.1 with: release-level: ${{ inputs.release-level }} # optional previous-changelog-filepath: .previous_changelog_for_template.md # optional diff --git a/actions/update_development_dependencies/readme.md b/actions/update_development_dependencies/readme.md index 12911336..d9c4d317 100644 --- a/actions/update_development_dependencies/readme.md +++ b/actions/update_development_dependencies/readme.md @@ -46,7 +46,7 @@ jobs: ref: ${{ github.head_ref }} token: ${{ secrets.checkout-token }} - - uses: tektronix/python-package-ci-cd/actions/update_development_dependencies@main # it is recommended to use the latest release tag instead of `main` + - uses: tektronix/python-package-ci-cd/actions/update_development_dependencies@v0.0.1 with: repo-root: . # optional, defaults to the current working directory install-dependencies: false # optional, this will almost never need to be set to true diff --git a/pyproject.toml b/pyproject.toml index 1dc83c96..a411c445 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ wrap-summaries = 0 [tool.poetry] package-mode = false -version = "0.0.0" +version = "0.0.1" [tool.poetry.dependencies] python = "~3.12" diff --git a/scripts/bump_version_in_files.py b/scripts/bump_version_in_files.py index 9e05e97e..11a2be1a 100644 --- a/scripts/bump_version_in_files.py +++ b/scripts/bump_version_in_files.py @@ -39,7 +39,11 @@ def update_github_actions_version(filepath: Path, incoming_version: str) -> None filepath: The path to the file to update. incoming_version: The version to update the file to """ - file_content = filepath.read_text() + try: + file_content = filepath.read_text() + except UnicodeDecodeError: + print(f'Skipping "{filepath}" due to a UnicodeDecodeError.') + return # Check if there's a match before replacing if GITHUB_WORKFLOW_AND_ACTION_REGEX.search(file_content): # Replace the version numbers with the new version diff --git a/workflows/check-api-for-breaking-changes.md b/workflows/check-api-for-breaking-changes.md index 64afdb21..bfcd71e9 100644 --- a/workflows/check-api-for-breaking-changes.md +++ b/workflows/check-api-for-breaking-changes.md @@ -39,7 +39,7 @@ on: jobs: check-api-for-breaking-changes: uses: - tektronix/python-package-ci-cd/.github/workflows/_reusable-check-api-for-breaking-changes.yml@main # it is recommended to use the latest release tag instead of `main` + tektronix/python-package-ci-cd/.github/workflows/_reusable-check-api-for-breaking-changes.yml@v0.0.0 with: package-name: my_package_name # required ``` diff --git a/workflows/codeql-analysis.md b/workflows/codeql-analysis.md index a501bd00..d7a998b8 100644 --- a/workflows/codeql-analysis.md +++ b/workflows/codeql-analysis.md @@ -43,7 +43,7 @@ on: branches: [main] jobs: analyze: - uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-codeql-analysis.yml@main # it is recommended to use the latest release tag instead of `main` + uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-codeql-analysis.yml@v0.0.1 with: languages-array: '["python", "javascript"]' codeql-queries: security-extended,security-and-quality diff --git a/workflows/enforce-community-standards.md b/workflows/enforce-community-standards.md index 86954bd2..60e12ba6 100644 --- a/workflows/enforce-community-standards.md +++ b/workflows/enforce-community-standards.md @@ -44,7 +44,7 @@ on: branches: [main] jobs: enforce-community-standards: - uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-enforce-community-standards.yml@main # it is recommended to use the latest release tag instead of `main` + uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-enforce-community-standards.yml@v0.0.1 ``` [workflow-file]: ../.github/workflows/_reusable-enforce-community-standards.yml diff --git a/workflows/package-build.md b/workflows/package-build.md index 92550993..a2d12753 100644 --- a/workflows/package-build.md +++ b/workflows/package-build.md @@ -59,7 +59,7 @@ concurrency: cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: package-build: - uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-package-build.yml@main # it is recommended to use the latest release tag instead of `main` + uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-package-build.yml@v0.0.1 with: package-name: my_package # required python-versions-array: '["3.9", "3.10", "3.11", "3.12"]' # required diff --git a/workflows/package-release.md b/workflows/package-release.md index 709ff898..205bbdb3 100644 --- a/workflows/package-release.md +++ b/workflows/package-release.md @@ -107,7 +107,7 @@ concurrency: # This concurrency is not required, but can be added if extra cont group: pypi jobs: package-release: - uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-package-release.yml@main # it is recommended to use the latest release tag instead of `main` + uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-package-release.yml@v0.0.1 with: package-name: my-package # required repo-name: owner/my-package # required diff --git a/workflows/package-testpypi.md b/workflows/package-testpypi.md index b92c85ae..19f92e5a 100644 --- a/workflows/package-testpypi.md +++ b/workflows/package-testpypi.md @@ -58,7 +58,7 @@ concurrency: # This concurrency is not required, but can be added if extra cont group: pypi jobs: package-testpypi: - uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-package-testpypi.yml@main # it is recommended to use the latest release tag instead of `main` + uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-package-testpypi.yml@v0.0.1 with: package-name: my-package # required repo-name: owner/my-package # required diff --git a/workflows/publish-api-comparison.md b/workflows/publish-api-comparison.md index 25e86a7d..4c3db521 100644 --- a/workflows/publish-api-comparison.md +++ b/workflows/publish-api-comparison.md @@ -45,7 +45,7 @@ on: types: [completed] jobs: publish-api-comparison: - uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-publish-api-comparison.yml@main # it is recommended to use the latest release tag instead of `main` + uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-publish-api-comparison.yml@v0.0.1 permissions: checks: write pull-requests: write diff --git a/workflows/publish-test-results.md b/workflows/publish-test-results.md index 154c89b3..69e1b174 100644 --- a/workflows/publish-test-results.md +++ b/workflows/publish-test-results.md @@ -55,7 +55,7 @@ on: types: [completed] jobs: publish-test-results: - uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-publish-test-results.yml@main # it is recommended to use the latest release tag instead of `main` + uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-publish-test-results.yml@v0.0.1 with: operating-systems-array: '["ubuntu", "windows", "macos"]' # required permissions: diff --git a/workflows/sbom-scan.md b/workflows/sbom-scan.md index 26cff3fb..fa79a15c 100644 --- a/workflows/sbom-scan.md +++ b/workflows/sbom-scan.md @@ -51,7 +51,7 @@ on: types: [published] jobs: sbom-scan: - uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-sbom-scan.yml@main # it is recommended to use the latest release tag instead of `main` + uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-sbom-scan.yml@v0.0.1 permissions: security-events: write contents: write diff --git a/workflows/test-code.md b/workflows/test-code.md index a0d735e5..3c63819f 100644 --- a/workflows/test-code.md +++ b/workflows/test-code.md @@ -134,7 +134,7 @@ concurrency: cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: test-code: - uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-test-code.yml@main # it is recommended to use the latest release tag instead of `main` + uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-test-code.yml@v0.0.1 with: repo-name: owner/repo # required operating-systems-array: '["ubuntu", "windows", "macos"]' # optional diff --git a/workflows/test-docs.md b/workflows/test-docs.md index 001873eb..a568325f 100644 --- a/workflows/test-docs.md +++ b/workflows/test-docs.md @@ -89,7 +89,7 @@ concurrency: cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: test-docs: - uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-test-docs.yml@main # it is recommended to use the latest release tag instead of `main` + uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-test-docs.yml@v0.0.1 with: node-version: 20 # required python-version: '3.11' # required diff --git a/workflows/update-python-and-pre-commit-dependencies.md b/workflows/update-python-and-pre-commit-dependencies.md index 2345f31d..b027aa17 100644 --- a/workflows/update-python-and-pre-commit-dependencies.md +++ b/workflows/update-python-and-pre-commit-dependencies.md @@ -56,7 +56,7 @@ on: branches: [main] jobs: update-python-and-pre-commit-dependencies: - uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-update-python-and-pre-commit-dependencies.yml@main # it is recommended to use the latest release tag instead of `main` + uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-update-python-and-pre-commit-dependencies.yml@v0.0.1 with: commit-user-name: 'User Name' commit-user-email: 'user-email' From 2935f10625de395bae5cd345f7282154a9a8948f Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Tue, 27 Aug 2024 11:32:41 -0700 Subject: [PATCH 2/2] test: Add a test for the new error handling in the bump version script --- tests/test_bump_version_in_files.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_bump_version_in_files.py b/tests/test_bump_version_in_files.py index deb2cce0..ab596b33 100644 --- a/tests/test_bump_version_in_files.py +++ b/tests/test_bump_version_in_files.py @@ -54,3 +54,19 @@ def test_update_github_actions_version_multiple_matches(temporary_directory: Pat "uses: tektronix/python-package-ci-cd/action1@v1.2.3\n" "uses: tektronix/python-package-ci-cd/action2@v1.2.3" ) + + +def test_update_github_actions_version_unicode_error( + temporary_directory: Path, capsys: pytest.CaptureFixture[str] +) -> None: + """Test handling of UnicodeDecodeError.""" + file_path = temporary_directory / "file4.txt" + # Write binary content to the file to trigger a UnicodeDecodeError + file_path.write_bytes(b"\x80\x81\x82") + + update_github_actions_version(file_path, "1.2.3") + + # Capture the stdout output + captured = capsys.readouterr() + + assert captured.out == f'Skipping "{file_path}" due to a UnicodeDecodeError.\n'