From e3908d246b9c8c3f68815f030f4ca08caf13ced4 Mon Sep 17 00:00:00 2001 From: Maxim Date: Tue, 6 Feb 2024 14:49:41 +0100 Subject: [PATCH] Add test coverage on the main page of albs-sign-node repository Resolves: AlmaLinux/build-system#176 --- .github/workflows/pytest.yml | 61 ++++++++++++++++++++++++++++++++++ README.md | 2 ++ requirements.txt | 1 + tests/__init__.py | 0 tests/sign_node/__init__.py | 0 tests/sign_node/test_signer.py | 6 ++++ 6 files changed, 70 insertions(+) create mode 100644 .github/workflows/pytest.yml create mode 100644 tests/__init__.py create mode 100644 tests/sign_node/__init__.py create mode 100644 tests/sign_node/test_signer.py diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..0d58401 --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,61 @@ +name: pytest +on: + pull_request: + branches: + - "**" + push: + branches: + - master +jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v3 + name: Check out repository + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Add node config file + run: | + mkdir node-config + touch ./node-config/sign_node.yml + echo --- >> ./node-config/sign_node.yml + echo development_mode: yes >> ./node-config/sign_node.yml + - uses: isbang/compose-action@v1.5.1 + name: Run docker-compose + with: + # Use this if you change something in Dockerfile + # up-flags: --build --no-deps + up-flags: "--pull always --no-build --no-deps" + down-flags: "--volumes" + - name: Run unit tests (pytest) + run: docker-compose run -v /tmp:/tmp --no-deps sign_node bash -o pipefail -c 'source + env/bin/activate && pip3 install -r requirements.txt && + pytest -vv --cov-report term-missing:skip-covered + --cov-report xml:/tmp/coverage.xml --junitxml=/tmp/pytest.xml --cov=sign_node + tests/ | tee /tmp/pytest-coverage.txt' + - name: Pytest coverage comment + uses: MishaKav/pytest-coverage-comment@main + id: coverageComment + with: + pytest-coverage-path: /tmp/pytest-coverage.txt + pytest-xml-coverage-path: /tmp/coverage.xml + title: Coverage report for changed files + badge-title: Total coverage + hide-badge: false + hide-report: false + report-only-changed-files: true + hide-comment: false + remove-link-from-badge: false + junitxml-path: /tmp/pytest.xml + - name: Create the Badge + if: ${{ github.ref == 'refs/heads/master' && steps.coverageComment.outputs.coverage }} + uses: schneegans/dynamic-badges-action@v1.6.0 + with: + auth: ${{ secrets.GIST_SECRET }} + gistID: 7d2552a0fbf81edbaa7d3deb001e142b + filename: sign-node-badge__master.json + label: Test Coverage + message: ${{ steps.coverageComment.outputs.coverage }} + color: ${{ steps.coverageComment.outputs.color }} + namedLogo: pytest diff --git a/README.md b/README.md index 3aa9b02..b5af93f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # System Overview +[![badges](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/maccelf/7d2552a0fbf81edbaa7d3deb001e142b/raw/sign-node-badge__master.json)](https://github.com/AlmaLinux/albs-sign-node/blob/master/README.md) + AlmaLinux Build System Sing Node is designed to sign build packages. Sign Node sends a request to the [Web-Server](https://github.com/AlmaLinux/albs-web-server) and receives back a task to sign packages. diff --git a/requirements.txt b/requirements.txt index e8d655f..6ca9c08 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,4 +18,5 @@ websocket-client==0.59.0 # https://jasonralph.org/?p=997 cryptography==37.0.4 pgpy==0.5.4 +pytest-cov==4.1.0 git+https://github.com/AlmaLinux/immudb-wrapper.git@0.1.2#egg=immudb_wrapper diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/sign_node/__init__.py b/tests/sign_node/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/sign_node/test_signer.py b/tests/sign_node/test_signer.py new file mode 100644 index 0000000..6e955b3 --- /dev/null +++ b/tests/sign_node/test_signer.py @@ -0,0 +1,6 @@ +from sign_node.signer import Signer + + +class TestSigner: + def test_example(self): + pass