-
Notifications
You must be signed in to change notification settings - Fork 35
118 lines (105 loc) · 3.6 KB
/
checks_template.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
name: check_template
on:
workflow_call:
inputs:
integration_name:
required: true
type: string
deprecated:
required: true
type: boolean
extra_cmds:
required: false
type: string
python_matrix:
required: false
type: string
default: "['3.8', '3.9', '3.10', '3.11', '3.12']"
jobs:
checks:
runs-on: ubuntu-latest
if: ${{ !inputs.deprecated }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Check Integration Name
run: |
echo "Input is ${{ inputs.integration_name }}"
- name: Install Common Dependencies
run: |
python -m pip install -U pip
pip install --progress-bar off -U .[checking]
pip install --progress-bar off -U .[test]
- name: Install Integration Dependencies
run: |
pip install --progress-bar off .[${{ inputs.integration_name }}]
- name: Black
run: |
if [ -e optuna_integration/${{ inputs.integration_name }} ]; then
black optuna_integration/${{ inputs.integration_name }} --check --diff
fi
if [ -e tests/${{ inputs.integration_name }} ]; then
black tests/${{ inputs.integration_name }} --check --diff
fi
- name: Import Sorting
run: |
if [ -e optuna_integration/${{ inputs.integration_name }} ]; then
isort optuna_integration/${{ inputs.integration_name }} --check --diff
fi
if [ -e tests/${{ inputs.integration_name }} ]; then
isort tests/${{ inputs.integration_name }} --check --diff
fi
- name: MyPy
run: |
if [ -e optuna_integration/${{ inputs.integration_name }} ]; then
mypy optuna_integration/${{ inputs.integration_name }}
fi
if [ -e tests/${{ inputs.integration_name }} ]; then
mypy tests/${{ inputs.integration_name }}
fi
- name: BlackDoc
run: |
if [ -e optuna_integration/${{ inputs.integration_name }} ]; then
blackdoc optuna_integration/${{ inputs.integration_name }} --check --diff
fi
if [ -e tests/${{ inputs.integration_name }} ]; then
blackdoc tests/${{ inputs.integration_name }} --check --diff
fi
- name: Flake8
run: |
if [ -e optuna_integration/${{ inputs.integration_name }} ]; then
flake8 optuna_integration/${{ inputs.integration_name }}
fi
if [ -e tests/${{ inputs.integration_name }} ]; then
flake8 tests/${{ inputs.integration_name }}
fi
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ${{ fromJSON(inputs.python_matrix) }}
if: ${{ !inputs.deprecated }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Common Dependencies
run: |
python -m pip install --upgrade pip
# Install optuna from optuna master
pip install git+https://github.com/optuna/optuna@master
pip install --progress-bar off .[test]
- name: Install Integration Dependencies
run: |
pip install --progress-bar off .[${{ inputs.integration_name }}]
- name: Extra Commands
run: |
${{ inputs.extra_cmds }}
- name: Tests
run: |
if [ -e tests/${{ inputs.integration_name }} ]; then
pytest tests/${{ inputs.integration_name }}
fi