test: add testing is in contain #517
Workflow file for this run
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
# 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: 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 build 'coverage[toml]' pdoc3 flake8 flake8-docstrings | |
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 [ "$(python -m coverage json -q -o /dev/stdout | jq .totals.percent_covered)" = "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 |