Skip to content

fix: linting

fix: linting #57

Workflow file for this run

name: CI/CD Pipeline
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry==1.4.2
poetry install
- name: Lint
run: |
source `poetry env info --path`/bin/activate
black . --check
mypy .
flake8
isort --check .
- name: Test with pytest
run: |
poetry run pytest --cov-report xml --cov-report term --cov=python_client_generator
# TODO: set up codecov
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v1
# with:
# file: ./coverage.xml
test-commits:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install commitlint
run: |
npm install -g @commitlint/config-conventional @commitlint/cli
- name: Git fetch
run: |
git fetch origin main
- name: Test commits
run: |
commitlint --from $(git merge-base origin/main HEAD) --to HEAD
release:
name: Release
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.version-number.outputs.VERSION }}
needs: [build, test-commits]
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Install semantic release
run: >
npm install -g semantic-release
@semantic-release/changelog
@semantic-release/git
@semantic-release/exec
conventional-changelog-conventionalcommits
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
run: |
# run semantic release and pipe the output both to the console and a log file
semantic-release 2>&1 | tee log.txt
- name: Set version number
id: version-number
run: |
# parse the output to get the new version number
echo "VERSION=$(sed -rn 's/.*Published release (.*) on .* channel/\1/p' log.txt)" >> $GITHUB_OUTPUT
publish:
name: Publish
runs-on: ubuntu-latest
needs: [release]
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry==1.4.2
poetry install
- name: Build and publish
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
VERSION: ${{ needs.release.outputs.output1 }}
run: |
poetry version $VERSION
poetry build
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish