Skip to content

fix: linter and delete try execpt #570

fix: linter and delete try execpt

fix: linter and delete try execpt #570

Workflow file for this run

# Copyright (C) Free Software Foundation, Inc. All rights reserved.
# Licensed under the AGPL-3.0-only License. See LICENSE in the project root
# for license information.
name: Python
on:
pull_request:
push:
branches: ['**']
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-[a-z]+'
- '[0-9]+.[0-9]+.[0-9]+-[a-z]+.[0-9]+'
jobs:
venv:
name: Virtual Environment
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache venv
id: cache-python-venv
uses: actions/cache@v3
with:
path: venv/
key: python-venv
- name: Set up Python
if: steps.cache-python-venv.outputs.cache-hit != 'true'
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install dependencies
if: steps.cache-python-venv.outputs.cache-hit != 'true'
run: |
python -m venv venv/
. venv/bin/activate
pip install --upgrade pip
pip install toml build 'coverage[toml]' pdoc3 flake8 flake8-docstrings
python -c 'import toml; c = toml.load("pyproject.toml"); print("\n".join([*c["project"].get("dependencies", []), *[row for optional_dependency in c["project"].get("optional-dependencies", {}).values() for row in optional_dependency]]))' > /tmp/requirements.txt
pip install -r /tmp/requirements.txt
lint:
name: Linter Test
needs: venv
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache venv
uses: actions/cache@v3
with:
path: venv/
key: python-venv
- name: Lint with flake8
run: |
. venv/bin/activate
python -m flake8 --exclude build/,venv/
unittest:
name: Unit Test
needs: venv
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache venv
uses: actions/cache@v3
with:
path: venv/
key: python-venv
- name: Activate venv
run: |
. venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: Install package
run: pip install '.[converter,gsheet,s3,sql]'
- name: Test
run: python -m coverage run -m unittest
- name: Display coverage
run: python -m coverage report -m
- name: Coverage comment
if: github.ref_type != 'tag'
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
- name: Test coverage must be 100% passed!
if:
github.ref_type == 'tag' ||
github.event_name == 'pull_request' ||
contains('refs/heads/main refs/heads/develop', github.ref) ||
startsWith(github.ref, 'refs/heads/release/') ||
startsWith(github.ref, 'refs/heads/hotfix/')
run: if [ $(printf '%.0f' $(python -m coverage report | awk '$1 == "TOTAL" {print $NF+0}')) = 100 ]; then exit; else exit 1; fi
pypi:
name: PyPI
needs: [lint, unittest]
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
environment:
name: python
url: https://pypi.org/project/${{ github.event.repository.name }}/
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache venv
uses: actions/cache@v3
with:
path: venv/
key: python-venv
- name: Build package
run: |
. venv/bin/activate
python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
docs:
name: Release Docs
needs: pypi
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
environment:
name: github-pages
url: ${{ steps.docs.outputs.page_url }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache venv
uses: actions/cache@v3
with:
path: venv/
key: python-venv
- name: Generate docs
run: |
. venv/bin/activate
pip install '.[converter,gsheet,s3,sql]'
python -m pdoc \
datasae \
--html \
--force \
-o docs/
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: 'docs/datasae/'
- name: Deploy to GitHub Pages
id: docs
uses: actions/deploy-pages@v2