@@ -29,105 +29,28 @@ concurrency:
2929 # Cancel only PR intermediate builds.
3030 cancel-in-progress : ${{ startsWith(github.ref, 'refs/pull/') }}
3131
32- env :
33- PYTEST_NUM_SHARDS : 4 # Controls tests sharding enabled by `pytest-shard`
34-
3532jobs :
3633 activate-tests :
37- name : Check if tests should be run
34+ name : Check whether we should run tests or not
3835 runs-on : ubuntu-latest
3936
4037 steps :
41- - name : Check
42- id : check
43- # For merged PR, activate testing only on the master branch, based on:
44- # https://github.community/t/trigger-workflow-only-on-pull-request-merge/17359
45- run : |
46- echo "status=${{ github.ref == 'refs/heads/master' || (
47- github.event.action != 'closed'
48- && github.event.pull_request.merged == false
49- ) }}" >> $GITHUB_OUTPUT
38+ - uses : actions/checkout@v3
39+ - id : check
40+ uses : ./.github/actions/activate-tests
5041
5142 outputs :
5243 status : ${{ steps.check.outputs.status }}
5344
54- shards -job :
45+ pytest -job :
5546 needs : activate-tests
5647 if : ${{ needs.activate-tests.outputs.status }}
5748
58- name : Generate shards
59- runs-on : ubuntu-latest
60-
61- steps :
62- - name : Create variables
63- id : create-vars
64- run : |
65- echo "num-shards=$(jq -n -c '[${{ env.PYTEST_NUM_SHARDS }}]')" >> $GITHUB_OUTPUT
66- echo "shard-ids=$(jq -n -c '[range(1;${{ env.PYTEST_NUM_SHARDS }}+1)]')" >> $GITHUB_OUTPUT
67-
68- outputs :
69- num-shards : ${{ steps.create-vars.outputs.num-shards }}
70- shard-ids : ${{ steps.create-vars.outputs.shard-ids }}
71-
72- pytest-job :
73- needs : shards-job
74-
75- name : ' [${{ matrix.os-version }}][${{ matrix.tf-version }}][Python ${{ matrix.python-version }}][${{ matrix.shard-id }}/${{ matrix.num-shards }}] Core TFDS tests'
76- runs-on : ${{ matrix.os-version }}
77- timeout-minutes : 30
78- strategy :
79- # Do not cancel in-progress jobs if any matrix job fails.
80- fail-fast : false
81- matrix :
82- tf-version : [tensorflow]
83- # Can't reference env variables in matrix
84- num-shards : ${{ fromJson(needs.shards-job.outputs.num-shards) }}
85- shard-id : ${{ fromJson(needs.shards-job.outputs.shard-ids) }}
86- # TF suppported versions: https://www.tensorflow.org/install/pip#software_requirements
87- python-version : ['3.10', '3.11', '3.12']
88- os-version : [ubuntu-latest]
89-
90- steps :
91- - uses : actions/checkout@v3
92- - uses : ./.github/actions/setup
93- with :
94- tf-version : ${{ matrix.tf-version }}
95- python-version : ${{ matrix.python-version }}
96-
97- # Run tests
98- # Ignores:
99- # * Nsynth is run in isolation due to dependency conflict (crepe).
100- # * Lsun tests is disabled because the tensorflow_io used in open-source
101- # is linked to static libraries compiled again specific TF version, which
102- # makes test fails with linking error (libtensorflow_io_golang.so).
103- # * imagenet2012_corrupted requires imagemagick binary.
104- # * import_without_tf_test.py, because the test relies on TensorFlow not being imported.
105- # * github_api is run separately to not overuse API quota.
106- # * wmt is run separately to avoid worker hanging.
107- # * Huggingface requires `datasets` library.
108- - name : Run core tests
109- run : |
110- pytest --durations=100 -vv -n auto --shard-id=$((${{ matrix.shard-id }} - 1)) --num-shards=${{ env.PYTEST_NUM_SHARDS }} \
111- --ignore="tensorflow_datasets/datasets/nsynth/nsynth_dataset_builder_test.py" \
112- --ignore="tensorflow_datasets/image/lsun_test.py" \
113- --ignore="tensorflow_datasets/datasets/imagenet2012_corrupted/imagenet2012_corrupted_dataset_builder_test.py" \
114- --ignore="tensorflow_datasets/scripts/documentation/build_api_docs_test.py" \
115- --ignore="tensorflow_datasets/import_without_tf_test.py" \
116- --ignore="tensorflow_datasets/core/github_api/github_path_test.py" \
117- --ignore="tensorflow_datasets/translate/wmt19_test.py" \
118- --ignore="tensorflow_datasets/core/dataset_builders/huggingface_dataset_builder_test.py" \
119- --ignore="tensorflow_datasets/core/utils/huggingface_utils_test.py"
120-
121- # Run tests without any pytest plugins. The tests should be triggered for a single shard only.
122- - name : Run leftover tests
123- if : ${{ matrix.shard-id == 1 }}
124- uses : nick-fields/retry@v2
125- with :
126- timeout_minutes : 1
127- max_attempts : 2
128- retry_on : timeout
129- command : |
130- pytest -vv -o faulthandler_timeout=10 tensorflow_datasets/translate/wmt19_test.py
49+ name : ' Core TFDS tests'
50+ uses : ./.github/workflows/pytest-template.yml
51+ with :
52+ tf-version : tensorflow
53+ os-version : ubuntu-latest
13154
13255 huggingface-pytest-job :
13356 needs : activate-tests
0 commit comments