-
Notifications
You must be signed in to change notification settings - Fork 1
121 lines (107 loc) · 3.82 KB
/
mypy.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Python Type Checking
on:
workflow_call:
inputs:
environment_file:
description: filename of conda env file
required: false
type: string
default: environment.yml
requirements_file:
description: filename of requirements.txt file, if frozen dependencies are desired
type: string
required: false
extra_index_urls:
description: additional index URLs, comma-separated, to use when pip installing
type: string
required: false
python_versions:
description: string containing a JSON array of versions
required: false
type: string
default: '["3.9"]'
install_types:
description: whether to use mypy to install type stubs
required: false
type: boolean
default: true
pip_install_args:
description: args to pass to pip install
required: false
type: string
default: ''
path:
type: string
description: Path of package, relative to the repo root
required: false
default: '.'
package_specification:
description: Specification of how to install the package, such as '.[tests]'
required: false
type: string
default: .[tests]
jobs:
python-mypy:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJson(inputs.python_versions) }}
defaults:
run:
# Necessary for the mamba-org/provision-with-micromamba action
shell: bash --login -eo pipefail {0}
env:
LD_LIBRARY_PATH: /home/runner/micromamba/envs/bindgen/lib:$LD_LIBRARY_PATH
PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/cpu
steps:
- uses: actions/checkout@v2
# Configure conda if an environment file is provided
- name: Set up micromamba
if: ${{ inputs.environment_file != '' }}
uses: mamba-org/provision-with-micromamba@v15
with:
cache-downloads: true
cache-downloads-key: "mamba-${{ hashFiles(inputs.environment_file) }}"
environment-file: ./${{ inputs.path }}/${{ inputs.environment_file }}
environment-name: typecheck
cache-env: true
extra-specs: |
python=${{ matrix.python-version }}
# Configure conda if an environment file is not provided
- name: Set up micromamba
if: ${{ inputs.environment_file == '' }}
uses: mamba-org/provision-with-micromamba@v15
with:
environment-file: false
environment-name: typecheck
cache-env: true
channels: main
extra-specs: |
python=${{ matrix.python-version }}
- name: Cache pip downloads
uses: actions/cache@v3
with:
path: "~/.cache/pip"
key: "pip-${{ hashFiles('setup.cfg') }}"
restore-keys: |
pip-${{ hashFiles('setup.cfg') }}
pip-
- name: Extra Index URLs
run: export EXTRA_INDEX_URL=${{ inputs.extra_index_url }}
- name: Install package
working-directory: ./${{ inputs.path }}
run: python -m pip install ${{ inputs.pip_install_args }} ${{ inputs.package_specification }}
if: ${{ !inputs.requirements_file }}
- name: Install from requirements file
working-directory: ./${{ inputs.path }}
run: python -m pip install --no-deps ${{ inputs.pip_install_args }} -r ${{ inputs.requirements_file }}
if: ${{ inputs.requirements_file }}
- name: Mypy Type Install
working-directory: ./${{ inputs.path }}
run: mkdir -p .mypy_cache && python -m mypy --install-types --non-interactive
if: ${{ inputs.install_types }}
- name: Mypy
working-directory: ./${{ inputs.path }}
run: python -m mypy src