Skip to content

Commit

Permalink
apply tmpl: ci: split ut into 3: ut, lint and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Mar 23, 2022
1 parent 1cd5596 commit b5b8abd
Showing 1 changed file with 67 additions and 11 deletions.
78 changes: 67 additions & 11 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package
name: Unit test

on:
push:
pull_request:

jobs:
build:
ut:

runs-on: ${{ matrix.os }}
strategy:
matrix:
# os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest]
python-version: [3.6, 3.7, 3.8]

Expand All @@ -26,7 +25,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi
- name: Install npm dependencies
Expand All @@ -35,21 +34,78 @@ jobs:
- name: Install apt dependencies
run: |
if [ -f packages.txt ]; then cat packages.txt | xargs sudo apt-get install; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
env:
# interactive command such as k3handy.cmdtty to run git, git complains
# if no TERM set:
# out: - (press RETURN)
# err: WARNING: terminal is not fully functional
# And waiting for a RETURN to press for ever
TERM: xterm
run: |
cp setup.py ..
cd ..
python setup.py install
cd -
sudo env "PATH=$PATH:$(npm bin)" pytest
sudo env "PATH=$PATH:$(npm bin)" pytest -v
- uses: actions/upload-artifact@v2
if: failure()
with:
path: test/

build_doc:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi
- name: Test building doc
run: |
pip install -r _building/building-requirements.txt
make -C docs html
lint:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

0 comments on commit b5b8abd

Please sign in to comment.