-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (94 loc) · 3.43 KB
/
pytest.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
88
89
90
91
92
93
94
95
96
name: pytest
on:
pull_request:
paths: # This action will only run if the PR modifies a file in one of these directories
- 'ml-agents/**'
- 'ml-agents-envs/**'
- 'test_constraints*.txt'
- 'test_requirements.txt'
- '.github/workflows/pytest.yml'
push:
branches:
- main
- develop
- 'release/**'
workflow_dispatch:
inputs:
pytest_markers:
description: "Restrict which tests to run based on pytest markers"
required: false
default: "not slow"
type: string
workflow_call:
inputs:
pytest_markers:
required: false
# Hacky way to make sure we run all tests
default: "slow or not slow"
type: string
jobs:
pytest:
runs-on: ubuntu-latest
env:
TEST_ENFORCE_BUFFER_KEY_TYPES: 1
strategy:
# If one test in the matrix fails we still want to run the others.
fail-fast: false
matrix:
python-version: [3.10.12]
include:
- python-version: 3.10.12
pip_constraints: test_constraints_version.txt
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v2
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('ml-agents/setup.py', 'ml-agents-envs/setup.py', 'test_requirements.txt', matrix.pip_constraints) }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
python -m pip install --progress-bar=off -e ./ml-agents-envs -c ${{ matrix.pip_constraints }}
python -m pip install --progress-bar=off -e ./ml-agents -c ${{ matrix.pip_constraints }}
python -m pip install --progress-bar=off -r test_requirements.txt -c ${{ matrix.pip_constraints }}
python -m pip install --progress-bar=off -e ./ml-agents-plugin-examples -c ${{ matrix.pip_constraints }}
- name: Save python dependencies
run: |
pip freeze > pip_versions-${{ matrix.python-version }}.txt
cat pip_versions-${{ matrix.python-version }}.txt
- name: Get pytest marker
id: pytest_marker
run: |
if [ "${{ github.event.inputs.pytest_markers }}" != "" ]; then
echo "::set-output name=markers::${{ github.event.inputs.pytest_markers }}"
else
echo "::set-output name=markers::not slow"
fi
- name: Run pytest
run: |
pytest --cov=ml-agents --cov=ml-agents-envs \
--cov-report=html --junitxml=junit/test-results-${{ matrix.python-version }}.xml \
-p no:warnings -v -m "${{ steps.pytest_marker.outputs.markers }}" -n 8
- name: Upload pytest test results
uses: actions/upload-artifact@v2
with:
name: artifacts-${{ matrix.python-version }}
path: |
htmlcov
pip_versions-${{ matrix.python-version }}.txt
junit/test-results-${{ matrix.python-version }}.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}