@@ -29,105 +29,28 @@ concurrency:
29
29
# Cancel only PR intermediate builds.
30
30
cancel-in-progress : ${{ startsWith(github.ref, 'refs/pull/') }}
31
31
32
- env :
33
- PYTEST_NUM_SHARDS : 4 # Controls tests sharding enabled by `pytest-shard`
34
-
35
32
jobs :
36
33
activate-tests :
37
- name : Check if tests should be run
34
+ name : Check whether we should run tests or not
38
35
runs-on : ubuntu-latest
39
36
40
37
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
50
41
51
42
outputs :
52
43
status : ${{ steps.check.outputs.status }}
53
44
54
- shards -job :
45
+ pytest -job :
55
46
needs : activate-tests
56
47
if : ${{ needs.activate-tests.outputs.status }}
57
48
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
131
54
132
55
huggingface-pytest-job :
133
56
needs : activate-tests
0 commit comments