-
Notifications
You must be signed in to change notification settings - Fork 1
93 lines (80 loc) · 2.8 KB
/
tests.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
name: Tests
on:
workflow_dispatch:
workflow_call:
pull_request:
branches: [main]
paths-ignore: ["**/*.md", "**/*.rst"]
env:
PYTHON_VERSION: 3.9
# Disable tokenizers parallelism because this doesn't help, and can cause issues in distributed tests.
TOKENIZERS_PARALLELISM: "false"
# Disable multithreading with OMP because this can lead to dead-locks in distributed tests.
OMP_NUM_THREADS: "1"
# See https://github.com/pytorch/pytorch/issues/37377#issuecomment-677851112.
MKL_THREADING_LAYER: "GNU"
jobs:
changes:
name: Check for Python file changes
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
outputs:
python: ${{steps.filter.outputs.python}}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
python:
- '**/*.py'
- 'storage/fixtures/**/*'
- 'pyproject.toml'
- 'poetry.lock'
- '.github/workflows/tests.yml'
python:
name: Run Python test suite
defaults:
run:
shell: bash
runs-on: self-hosted
needs: [changes]
if: ${{needs.changes.outputs.python == 'true' && !github.event.pull_request.draft }}
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install PoethePoet as a Poetry plugin
run: poetry self add 'poethepoet[poetry_plugin]'
- name: Configure GitHub to download private repos
env:
PAT: ${{ secrets.PAT }}
run: |
git config --global url."https://${PAT}@github.com/".insteadOf "https://github.com/"
- name: Load cached Python
uses: tespkg/actions-cache@v1
id: python-cache
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}-${{ hashFiles('pyproject.toml') }}
bucket: ${{ secrets.AWS_S3_BUCKET_NAME }}
accessKey: ${{ secrets.AWS_ACCESS_KEY_ID }}
secretKey: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Install dependencies
run: |
poetry install --all-extras
- name: Run test suite
run: |
poetry run poe test-everything | tee pytest-coverage.txt
- name: Comment the coverage
if: ${{ always() && github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml