-
Notifications
You must be signed in to change notification settings - Fork 45
144 lines (131 loc) · 4.39 KB
/
python.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Python CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [released]
workflow_dispatch:
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
AZURE_OPENAI_API: ${{ secrets.AZURE_OPENAI_API }}
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
jobs:
validation:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tools: ['black', 'bandit', 'pylint', 'flake8']
python: ['3.10'] # '3.11.3'
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: ${{ matrix.tools }}
uses: microsoft/action-python@0.7.1
with:
${{ matrix.tools }}: true
workdir: '.'
testdir: 'tests'
python_version: ${{ matrix.python }}
tests:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ADO_TOKEN: ${{ secrets.ADO_TOKEN }}
strategy:
fail-fast: true
matrix:
python: ['3.8', '3.9', '3.10', '3.11']
args: ['-m unit']
flags: ['unittests']
include:
- python: '3.10'
args: -m integration
flags: integration
- python: '3.11'
args: -m integration
flags: integration
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: Azure/login@v1.4.6
if: ${{ matrix.flags == 'integration' }}
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: ${{ matrix.tools }}
uses: microsoft/action-python@0.7.1
with:
pytest: true
args: ${{ matrix.args }}
workdir: '.'
testdir: 'tests'
python_version: ${{ matrix.python }}
flags: ${{ matrix.flags }}-${{ matrix.python }}
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
if: ${{ github.event_name == 'release' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.PAT }}
- uses: actions/checkout@v2
if: ${{ github.event_name != 'release' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-python@v4
with:
python-version: '3.11.3'
cache: 'pip' # caching pip dependencies
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
dry_run: true
tag_prefix: 'v'
default_bump: false
- name: Set Configurations
if: steps.tag_version.outputs.release_type && github.event_name != 'release'
shell: bash
env:
VERSION: ${{ steps.tag_version.outputs.new_version }}
run: sed -ri 's/(__version__ = ")([0-9]+\.[0-9]+\.[0-9]+?.*)(")/\1'"$VERSION"'\3/' "src/gpt_review/__init__.py" || exit 1
- name: Set Configurations
if: steps.tag_version.outputs.release_type && github.event_name == 'release'
shell: bash
env:
VERSION: ${{ steps.tag_version.outputs.previous_version }}
run: sed -ri 's/(__version__ = ")([0-9]+\.[0-9]+\.[0-9]+?.*)(")/\1'"$VERSION"'\3/' "src/gpt_review/__init__.py" || exit 1
- name: Publish Snapshot to TestPyPi
uses: microsoft/action-python@0.7.1
continue-on-error: true
if: ${{ github.event_name == 'pull_request_target' }}
with:
pypi_publish: true
pypi_password: ${{ secrets.TEST_PYPI_PASSWORD }}
pypi_repo: testpypi
version_suffix: -post${{ github.run_number }}-dev${{ github.run_attempt }}
workdir: '.'
python_version: '3.11.3'
- name: Publish RC to PyPi
uses: microsoft/action-python@0.7.1
if: ${{ github.event_name == 'push' }}
with:
pypi_publish: true
pypi_password: ${{ secrets.PYPI_PASSWORD }}
version_suffix: -rc${{ github.run_number }}-post${{ github.run_attempt }}
workdir: '.'
python_version: '3.11.3'
- name: Publish Release to PyPi
uses: microsoft/action-python@0.7.1
if: ${{ github.event_name == 'release' }}
with:
pypi_publish: true
pypi_password: ${{ secrets.PYPI_PASSWORD }}
workdir: '.'
python_version: '3.11.3'