-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
119 lines (105 loc) · 4.07 KB
/
python-package.yml
File metadata and controls
119 lines (105 loc) · 4.07 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Python package
on:
workflow_call:
# This workflow can be called by other workflows (like intelligent-testing.yml)
inputs:
concurrency_key:
required: false
type: string
workflow_dispatch:
inputs:
concurrency_key:
description: "Optional stable key to dedupe manual runs (for example: pr-123)"
required: false
type: string
jobs:
build:
runs-on: ${{ matrix.os }}
# Cancel outdated runs on the same OS and Python version when new commits are pushed
# Only cancels on PRs.
# Use a stable concurrency key only when one is explicitly provided
# (e.g. PR/workflow_call/manual dedupe). Otherwise fall back to github.run_id
# so pushes to main never cancel each other.
concurrency:
group: >-
tests-${{ github.workflow }}-
${{ github.event_name == 'workflow_call' && inputs.concurrency_key
|| github.event_name == 'workflow_dispatch' && inputs.concurrency_key
|| github.run_id }}-
${{ matrix.os }}-${{ matrix.python-version }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12"]
include:
- os: ubuntu-latest
path: ~/.cache/pip
- os: macos-latest
path: ~/Library/Caches/pip
- os: windows-latest
path: ~\AppData\Local\pip\Cache
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Free up disk space
if: runner.os == 'Linux'
run: |
echo "Disk space before cleanup:"
df -h
# Remove unnecessary software to free up disk space
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo docker image prune --all --force
echo "Disk space after cleanup:"
df -h
- name: Set up Python
uses: conda-incubator/setup-miniconda@v3
with:
channels: conda-forge
channel-priority: strict
python-version: ${{ matrix.python-version }}
- name: Install TensorFlow
shell: bash -el {0} # Important: activates the conda environment
if: runner.os != 'macOS'
run: |
pip install --no-cache-dir tensorflow tensorpack==0.11 tf_slim==1.1.0 tf-keras
- name: Install TensorFlow on macOS
shell: bash -el {0} # Important: activates the conda environment
if: runner.os == 'macOS'
run: |
pip install --no-cache-dir tensorflow-macos tensorpack==0.11 tf_slim==1.1.0 tf-keras
- name: Install dependencies
shell: bash -el {0} # Important: activates the conda environment
run: |
python -m pip install --upgrade pip setuptools wheel
pip install --no-cache-dir -e . --group dev
- name: Install ffmpeg
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get update
sudo apt-get install ffmpeg
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install ffmpeg || true
else
choco install ffmpeg
fi
shell: bash
- name: Run pytest tests
shell: bash -el {0} # Important: activates the conda environment
run: |
pip install --no-cache-dir -e . --group dev
python -m pytest
- name: Run functional tests
shell: bash -el {0} # Important: activates the conda environment
run: |
pip install -c "$GITHUB_WORKSPACE/.github/versioning/tf-ci-constraints.txt" \
tensorflow tensorpack==0.11 tf_slim==1.1.0 tf-keras
pip install --no-cache-dir -c "$GITHUB_WORKSPACE/.github/versioning/tf-ci-constraints.txt" -e .
python examples/testscript_tensorflow_single_animal.py
python examples/testscript_tensorflow_multi_animal.py
python examples/testscript_pytorch_single_animal.py
python examples/testscript_pytorch_multi_animal.py