-
Notifications
You must be signed in to change notification settings - Fork 63
87 lines (83 loc) · 2.54 KB
/
ci_examples.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Examples CI
on:
push:
paths:
- 'tfx_addons/**'
- 'examples/**'
- '.github/workflows/ci_examples.yml'
- '.github/workflows/filter_examples.py'
- 'setup.py'
- 'pyproject.toml'
branches:
- main
- r*
pull_request:
paths:
- 'tfx_addons/**'
- 'examples/**'
- '.github/workflows/ci_examples.yml'
- '.github/workflows/filter_examples.py'
- 'setup.py'
- 'pyproject.toml'
branches:
- main
- r*
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
filter_examples:
# Dynamic matrix trick inspired by https://www.cynkra.com/blog/2020-12-23-dynamic-gha/
runs-on: ubuntu-latest
timeout-minutes: 60
outputs:
projects: ${{ steps.set-matrix.outputs.projects }}
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Get Changed Files
id: changed_files
uses: trilom/file-changes-action@v1.2.4
with:
output: json
- name: Filter example projects
id: set-matrix
run: |
echo "projects=$(python ./.github/workflows/filter_examples.py $HOME/files.json)" >> $GITHUB_OUTPUT
ci-examples:
runs-on: ubuntu-latest
needs: filter_examples
timeout-minutes: 60
if: needs.filter_examples.outputs.projects != '[]'
strategy:
# Test for each project in parallel using ci_max and ci_min to ensure
# tested in range of tfx/tensorflow supported versions
matrix:
project: ${{fromJson(needs.filter_examples.outputs.projects)}}
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Cache python environment
uses: actions/cache@v2
with:
# Cache installed dependencies
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirement.txt + project name
key: ${{ runner.os }}-pip-ciexamples-${{ matrix.project }}-${{ hashFiles(format('examples/{0}/requirements.txt', matrix.project)) }}
restore-keys: |
${{ runner.os }}-pip-ciexamples-${{ matrix.project }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel pytest
cd examples/${{ matrix.project }}
pip install -r requirements.txt
- name: Run tests
run: |
cd examples/${{ matrix.project }}
python -m pytest .