-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6889 from smokestacklightnin/ci/testing/pytest-up…
…-and-running Revamp testing workflow and use `pytest` instead of `unittest`
- Loading branch information
Showing
360 changed files
with
1,888 additions
and
2,827 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,62 @@ | ||
# Github action definitions for ci-test with PRs. | ||
# Github action definitions for unit-tests with PRs. | ||
|
||
name: tfx-ci-test | ||
name: tfx-unit-tests | ||
on: | ||
pull_request: | ||
branches: [ master ] | ||
paths-ignore: | ||
- '**.md' | ||
- 'docs/**' | ||
workflow_dispatch: | ||
|
||
env: | ||
USE_BAZEL_VERSION: "6.5.0" | ||
# Changed to match tensorflow | ||
# https://github.com/tensorflow/tensorflow/blob/master/.bazelversion | ||
|
||
jobs: | ||
build: | ||
tests: | ||
if: github.actor != 'copybara-service[bot]' | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 60 | ||
|
||
strategy: | ||
matrix: | ||
python-version: ['3.9', '3.10'] | ||
which-tests: ["not e2e", "e2e"] | ||
dependency-selector: ["NIGHTLY", "DEFAULT"] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Get Changed Files | ||
id: changed_files | ||
uses: trilom/file-changes-action@v1.2.4 | ||
with: | ||
fileOutput: ' ' | ||
- name: Select files to check | ||
run: | | ||
# Filter out non-python files. | ||
(cat $HOME/files_added.txt; echo; cat $HOME/files_modified.txt) | tr ' ' '\n' | grep '\.py$' > py_files.txt || true | ||
# Filter out non-test python files and e2e or integration tests. | ||
cat py_files.txt | grep '_test\.py$' | grep -v _e2e_ | grep -v integration | grep -v 'examples/' > py_test_files.txt || true | ||
# Select proto files. | ||
(cat $HOME/files_added.txt; echo; cat $HOME/files_modified.txt) | tr ' ' '\n' | grep '\.proto$' > proto_files.txt || true | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v1 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Set up Bazel 5.3.0 | ||
run: | | ||
# Instruction from https://docs.bazel.build/versions/master/install-ubuntu.html | ||
curl -sSL https://github.com/bazelbuild/bazel/releases/download/5.3.0/bazel-5.3.0-installer-linux-x86_64.sh -o bazel_installer.sh | ||
chmod +x bazel_installer.sh | ||
sudo ./bazel_installer.sh | ||
- name: Cache pip | ||
uses: actions/cache@v2 | ||
python-version: ${{ matrix.python-version }} | ||
cache: 'pip' | ||
cache-dependency-path: | | ||
setup.py | ||
tfx/dependencies.py | ||
- name: Set up Bazel | ||
uses: bazel-contrib/setup-bazel@0.8.5 | ||
with: | ||
# This path is specific to Ubuntu | ||
path: ~/.cache/pip | ||
# Look to see if there is a cache hit for the corresponding setup.py + TFX version | ||
key: ${{ runner.os }}-pip-${{ hashFiles('tfx/dependencies.py') }}- | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
# 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 wheel | ||
# TODO(b/232490018): Cython need to be installed separately to build pycocotools. | ||
python -m pip install Cython -c ./test_constraints.txt | ||
TFX_DEPENDENCY_SELECTOR=NIGHTLY pip install -c ./test_constraints.txt --extra-index-url https://pypi-nightly.tensorflow.org/simple --pre .[all] | ||
- name: Run unit tests | ||
shell: bash | ||
run: | | ||
[ ! -s "py_test_files.txt" ] || cat py_test_files.txt | xargs -I {} python {} | ||
- name: Lint with protolint | ||
continue-on-error: true | ||
pip install -c ./test_constraints.txt --extra-index-url https://pypi-nightly.tensorflow.org/simple --pre --editable .[all] | ||
env: | ||
PROTOLINT_VERSION: 0.25.1 | ||
shell: bash | ||
run: | | ||
curl -sSOL https://github.com/yoheimuta/protolint/releases/download/v${PROTOLINT_VERSION}/protolint_${PROTOLINT_VERSION}_Linux_x86_64.tar.gz | ||
tar zxf protolint_${PROTOLINT_VERSION}_Linux_x86_64.tar.gz | ||
echo "[NOTE] This linter is currently EXPERIMENTAL.=======================================" | ||
echo "Please contact reviewers for existing lint errors or false negative errors." | ||
echo "====================================================================================" | ||
[ ! -s "proto_files.txt" ] || cat proto_files.txt | xargs -I {} ./protolint {} | ||
TFX_DEPENDENCY_SELECTOR: ${{ matrix.dependency-selector }} | ||
|
||
- name: Lint with pylint | ||
continue-on-error: true | ||
- name: Run unit tests | ||
shell: bash | ||
run: | | ||
pip install pylint | ||
echo "[NOTE] This linter is currently EXPERIMENTAL.=======================================" | ||
echo "Please contact reviewers for existing lint errors or false negative errors." | ||
echo "Feel free to send PRs for pylintrc in the root directory of the repository if needed." | ||
echo "====================================================================================" | ||
[ ! -s "py_files.txt" ] || pylint $(cat py_files.txt | tr '\n' ' ') | ||
pytest -m "${{ matrix.which-tests }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[pytest] | ||
addopts = --import-mode=importlib | ||
testpaths = tfx | ||
python_files = *_test.py | ||
norecursedirs = custom_components .* *.egg | ||
markers = | ||
e2e: end to end tests that are slow and require more dependencies (deselect with '-m "not e2e"') | ||
integration: integration tests that are slow and require more dependencies (deselect with '-m "not integration"') | ||
perf: performance "perf" tests that are slow and require more dependencies (deselect with '-m "not perf"') | ||
serial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.