From f8f4a65d95ba2a2bde7fb3e42890cbfaf49360ab Mon Sep 17 00:00:00 2001 From: Paul Balanca Date: Wed, 8 Nov 2023 11:59:00 +0000 Subject: [PATCH] Add pytest unit test Github action (#7) --- .github/workflows/tests.yaml | 23 +++++++++++++++++++++++ .pre-commit-config.yaml | 17 +++++++++-------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 85c7060..dd67f71 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -29,3 +29,26 @@ jobs: with: python-version: 3.8 - uses: pre-commit/action@v3.0.0 + + unit_tests: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Cancel previous + uses: styfle/cancel-workflow-action@0.11.0 + with: + access_token: ${{ github.token }} + if: ${{github.ref != 'refs/head/main'}} + - uses: actions/checkout@v3 + - name: Update pip + id: pip-cache + run: | + python3 -m pip install --upgrade pip + - name: Local install & test requirements + run: | + pip3 install -e ./ + pip3 install -r ./test-requirements.txt + # Run repository unit tests. + - name: Run unit tests + run: | + pytest --tb=short -v --log-cli-level=INFO ./ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 710ffdc..52b08cd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,15 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.5.0 hooks: - id: check-merge-conflict - id: check-toml - id: check-yaml - id: debug-statements - id: end-of-file-fixer - - id: no-commit-to-branch - args: [--branch, main] + # Issue on Github action CI? + # - id: no-commit-to-branch + # args: [--branch, main] - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/PyCQA/isort @@ -17,21 +18,21 @@ repos: - id: isort args: [--profile, black] - repo: https://github.com/asottile/pyupgrade - rev: v3.2.2 + rev: v3.15.0 hooks: - id: pyupgrade args: [--py38-plus] - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + rev: 6.1.0 hooks: - id: flake8 args: ['--ignore=E501,E203,E731,W503'] - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 23.11.0 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.990 + rev: v1.6.1 hooks: - id: mypy - additional_dependencies: [types-dataclasses, numpy==1.22.4] + additional_dependencies: [types-dataclasses, numpy]