From 588d03f63ef01271284e5286ccea9a1ad0613293 Mon Sep 17 00:00:00 2001 From: yozik04 Date: Sun, 14 Jan 2024 12:15:52 +0200 Subject: [PATCH] workflows --- .github/workflows/codeql-analysis.yml | 6 ++--- .github/workflows/coverage.yml | 33 +++++++++++++++++++++++++++ .github/workflows/python-publish.yml | 8 +++++-- .github/workflows/test.yml | 9 +++++--- 4 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 791338d..742daee 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -54,7 +54,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # ℹī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -68,4 +68,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..fa8da8e --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,33 @@ +name: Coverage + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.11"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pytest pytest-cov pytest-asyncio + - name: Coverage + run: | + python -m pip install . + pytest tests/ --cov=nibe --cov-report=xml + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index f45359c..6fc9ad5 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -22,8 +22,12 @@ jobs: needs: test steps: - uses: actions/checkout@v4 + - name: Check versions match + run: | + PUBLISHING_VERSION=${{ github.event.release.tag_name }} + grep -qE '__version__ = "'$PUBLISHING_VERSION'"' vallox_websocket_api/__init__.py - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.x' - name: Install dependencies @@ -32,7 +36,7 @@ jobs: - name: Build package run: python -m build - name: Publish package - uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e + uses: pypa/gh-action-pypi-publish@release/v1.5 with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 06d9e71..920a61a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,8 +6,11 @@ name: Test and Lint on: workflow_call: workflow_dispatch: - pull_request: push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] jobs: build: @@ -21,12 +24,12 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install flake8 tox + python -m pip install --upgrade flake8 tox - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names