From 2fdd517fb471445786d7b4e93165ee56b28bac63 Mon Sep 17 00:00:00 2001 From: smokestacklightnin <125844868+smokestacklightnin@users.noreply.github.com> Date: Thu, 15 May 2025 19:53:02 -0700 Subject: [PATCH 1/9] Add pytest as a dependency --- setup.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/setup.py b/setup.py index 739835f..e175535 100644 --- a/setup.py +++ b/setup.py @@ -132,6 +132,11 @@ def run(self): 'protobuf>=4.21.6,<4.22;python_version<"3.11"', ], python_requires='>=3.9,<4', + extras_require={ + 'test': [ + 'pytest>=8,<9', + ], + }, packages=find_packages(), include_package_data=True, description='Library and standards for schema and statistics.', From 92b8e4dfd2377d98769f9d54f0ee9e66eee91140 Mon Sep 17 00:00:00 2001 From: smokestacklightnin <125844868+smokestacklightnin@users.noreply.github.com> Date: Thu, 15 May 2025 19:56:39 -0700 Subject: [PATCH 2/9] Add pytest config --- pytest.ini | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 pytest.ini diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..f59df51 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +addopts = -ra +testpaths = + tensorflow_metadata \ No newline at end of file From 31868a86dd177a861be9e37f5f2f5bd39c08b0f6 Mon Sep 17 00:00:00 2001 From: smokestacklightnin <125844868+smokestacklightnin@users.noreply.github.com> Date: Thu, 15 May 2025 20:08:41 -0700 Subject: [PATCH 3/9] Add test workflow Adapted from the TFX repo --- .github/workflows/test.yml | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..f7e21fc --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,55 @@ +name: Tests + +on: + pull_request: + branches: [ master ] + paths-ignore: + - '**.md' + - 'docs/**' + workflow_dispatch: + +env: + USE_BAZEL_VERSION: "7.6.1" + +jobs: + tests: + if: github.actor != 'copybara-service[bot]' + runs-on: ubuntu-latest + + + strategy: + matrix: + python-version: ['3.9', '3.10', '3.11'] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: | + setup.py + + - name: Set up Bazel + uses: bazel-contrib/setup-bazel@0.8.5 + with: + # Avoid downloading Bazel every time. + bazelisk-cache: true + # Store build cache per workflow. + disk-cache: ${{ github.workflow }}-${{ hashFiles('.github/workflows/ci-test.yml') }} + # Share repository cache between workflows. + repository-cache: true + + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install .[test] + + - name: Run unit tests + shell: bash + run: | + pytest + From 579ac1d6605165a52b33e2713632d8b50bc76469 Mon Sep 17 00:00:00 2001 From: smokestacklightnin <125844868+smokestacklightnin@users.noreply.github.com> Date: Thu, 15 May 2025 20:16:02 -0700 Subject: [PATCH 4/9] Add python 3.12 to test workflow --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f7e21fc..fe0010b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: strategy: matrix: - python-version: ['3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 From 51d688ffc0e1b94e6298981df58eecb4ef47ab9a Mon Sep 17 00:00:00 2001 From: smokestacklightnin <125844868+smokestacklightnin@users.noreply.github.com> Date: Thu, 15 May 2025 20:25:39 -0700 Subject: [PATCH 5/9] Remove unnecessary `if __name__ == "__main__"` section --- tensorflow_metadata/python/proto_test.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tensorflow_metadata/python/proto_test.py b/tensorflow_metadata/python/proto_test.py index 6e6902e..4dd25d0 100644 --- a/tensorflow_metadata/python/proto_test.py +++ b/tensorflow_metadata/python/proto_test.py @@ -32,7 +32,3 @@ def test_import_works(self): # Check for the presence of the Schema symbol. dummy = schema_pb2.Schema del dummy - - -if __name__ == '__main__': - absltest.main() From 705efcbe565a7a00a75dc0ad4c32622143571df1 Mon Sep 17 00:00:00 2001 From: smokestacklightnin <125844868+smokestacklightnin@users.noreply.github.com> Date: Thu, 24 Jul 2025 16:42:13 -0700 Subject: [PATCH 6/9] Remove conditional involving copybara --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fe0010b..7c4ea22 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,6 @@ env: jobs: tests: - if: github.actor != 'copybara-service[bot]' runs-on: ubuntu-latest From 09a8089e7232e6a9b82931da2452b2ad5f16571c Mon Sep 17 00:00:00 2001 From: smokestacklightnin <125844868+smokestacklightnin@users.noreply.github.com> Date: Thu, 24 Jul 2025 16:42:45 -0700 Subject: [PATCH 7/9] Remove deprecated Bazel install action --- .github/workflows/test.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7c4ea22..0e6b2ca 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,17 +31,6 @@ jobs: cache-dependency-path: | setup.py - - name: Set up Bazel - uses: bazel-contrib/setup-bazel@0.8.5 - with: - # Avoid downloading Bazel every time. - bazelisk-cache: true - # Store build cache per workflow. - disk-cache: ${{ github.workflow }}-${{ hashFiles('.github/workflows/ci-test.yml') }} - # Share repository cache between workflows. - repository-cache: true - - - name: Install dependencies run: | python -m pip install --upgrade pip From 702b2b003587506d4247ca520d3363007743a096 Mon Sep 17 00:00:00 2001 From: smokestacklightnin <125844868+smokestacklightnin@users.noreply.github.com> Date: Thu, 24 Jul 2025 16:50:29 -0700 Subject: [PATCH 8/9] Run pre-commit --- .github/workflows/test.yml | 5 ++--- pytest.ini | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0e6b2ca..b8d3d7a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: tests: runs-on: ubuntu-latest - + strategy: matrix: python-version: ['3.9', '3.10', '3.11', '3.12'] @@ -29,7 +29,7 @@ jobs: python-version: ${{ matrix.python-version }} cache: 'pip' cache-dependency-path: | - setup.py + setup.py - name: Install dependencies run: | @@ -40,4 +40,3 @@ jobs: shell: bash run: | pytest - diff --git a/pytest.ini b/pytest.ini index f59df51..a58ee98 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,4 @@ [pytest] addopts = -ra testpaths = - tensorflow_metadata \ No newline at end of file + tensorflow_metadata From 425bb6c6a490b83fbf95a60b618cc0ea3e21ebab Mon Sep 17 00:00:00 2001 From: smokestacklightnin <125844868+smokestacklightnin@users.noreply.github.com> Date: Thu, 24 Jul 2025 17:03:21 -0700 Subject: [PATCH 9/9] Fix typo --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index f841746..3c3bf72 100644 --- a/setup.py +++ b/setup.py @@ -138,10 +138,9 @@ def run(self): 'protobuf>=4.25.2;python_version>="3.11"', 'protobuf>=4.21.6,<4.22;python_version<"3.11"', ], - extras_require={}, python_requires=">=3.9,<4", packages=find_packages(), - extra_requires={ + extras_require={ "dev": ["precommit"], "test": [ "pytest>=8,<9",