-
Notifications
You must be signed in to change notification settings - Fork 80
123 lines (116 loc) · 4.09 KB
/
main.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
122
123
name: CI
# Run on git push, PR, or manually from the Actions tab
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
jobs:
run_test:
name: ${{ matrix.py-ver-mypy-protobuf }}
runs-on: ubuntu-20.04
# Some CI issues regarding ubuntu-latest
# runs-on: ubuntu-latest
env:
PY_VER_MYPY: 3.8.17
PY_VER_UNIT_TESTS_3: 3.8.17
strategy:
matrix:
# Running mypy-protobuf itself
py-ver-mypy-protobuf: [3.8.17, 3.9.17, 3.10.12, 3.11.4]
steps:
- uses: actions/checkout@v3
- name: Read version numbers
run: |
echo ::set-output name=PROTOBUF_VERSION::$(grep "^protobuf>=" test_requirements.txt | cut -f2 -d=)
echo ::set-output name=PYRIGHT_VERSION::$(grep '"pyright"' .github/package.json | cut -d\" -f4)
id: read_versions
- name: Cache pyenv
uses: actions/cache@v3
with:
path: |
~/.pyenv
!~/.pyenv/versions
key: pyenv-installation-2
- name: Cache pyenv mypy-protobuf ver
uses: actions/cache@v3
with:
path: ~/.pyenv/versions/${{matrix.py-ver-mypy-protobuf}}
key: pyenv-${{matrix.py-ver-mypy-protobuf}}-${{hashFiles('setup.py')}}
- name: Cache pyenv unit tests 3 ver
uses: actions/cache@v3
with:
path: ~/.pyenv/versions/${{env.PY_VER_UNIT_TESTS_3}}
key: pyenv-${{env.PY_VER_UNIT_TESTS_3}}-${{hashFiles('setup.py')}}
- name: Cache pyenv mypy ver
uses: actions/cache@v3
with:
path: ~/.pyenv/versions/${{env.PY_VER_MYPY}}
key: pyenv-${{env.PY_VER_MYPY}}-${{hashFiles('setup.py')}}
- name: Install pyenv
run: |
if [ ! -e ~/.pyenv/bin/pyenv ]; then
rm -rf ~/.pyenv
curl https://pyenv.run | bash
fi
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"
for PY in ${{matrix.py-ver-mypy-protobuf}} ${{env.PY_VER_MYPY}} ${{env.PY_VER_UNIT_TESTS_3}}; do
if [ ! -e ~/.pyenv/versions/$PY ]; then
pyenv install --skip-existing $PY
pyenv shell $PY
python -m pip install virtualenv
fi
done
- name: Run Tests (./run_test.sh)
env:
PY_VER_MYPY_PROTOBUF: ${{matrix.py-ver-mypy-protobuf}}
VALIDATE: 1
run: |
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"
./run_test.sh
- name: Run Pyright
uses: jakebailey/pyright-action@v1
with:
version: "${{ steps.read_versions.outputs.PYRIGHT_VERSION }}"
linting:
name: Linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Run formatters and linters
run: |
pip3 install black isort flake8-pyi flake8-noqa flake8-bugbear
black --check --extend-exclude '(_pb2_grpc|_pb2).pyi?$' .
isort --check . --diff
flake8 .
- name: run shellcheck
uses: reviewdog/action-shellcheck@v1
with:
# By default, shellcheck tries to make sure any external files referenced actually exist
shellcheck_flags: -e SC1091
sanity_check_windows:
name: Sanity Check Windows Executable
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Read versions
run: echo ::set-output name=PROTOBUF_VERSION::$(grep "^protobuf>=" test_requirements.txt | cut -f2 -d=)
id: read_versions
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: "${{ steps.read_versions.outputs.PROTOBUF_VERSION }}"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run Protoc
run: |
pip3 install -e .
mkdir wintestout
protoc --python_out=wintestout --mypy_out=wintestout proto\mypy_protobuf\extensions.proto