Upgrade to up-spec v1.6.0-alpha.3 and Implement uTwin Proto #138
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
name: Python Test and Coverage | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
test-and-coverage: | |
name: Test with coverage | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
git config --global user.name 'eclipse-uprotocol-bot' | |
git config --global user.email '[email protected]' | |
- name: Checkout code | |
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | |
- name: Set up Python | |
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 | |
with: | |
python-version: '3.x' | |
- name: Install Poetry | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install poetry | |
- name: Install dependencies | |
run: | | |
poetry install | |
- name: Run prebuild script | |
run: | | |
cd scripts | |
# Run the script within the Poetry virtual environment | |
poetry run python pull_and_compile_protos.py | |
- name: Run tests with coverage | |
run: | | |
set -o pipefail | |
poetry run coverage run --source=uprotocol -m pytest -x -o log_cli=true --timeout=300 2>&1 | tee test-output.log | |
poetry run coverage report > coverage_report.txt | |
export COVERAGE_PERCENTAGE=$(awk '/TOTAL/{print $4}' coverage_report.txt) | |
echo "COVERAGE_PERCENTAGE=$COVERAGE_PERCENTAGE" >> $GITHUB_ENV | |
echo "COVERAGE_PERCENTAGE: $COVERAGE_PERCENTAGE" | |
poetry run coverage html | |
timeout-minutes: 3 # Set a timeout of 3 minutes for this step | |
- name: Upload coverage report | |
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 | |
with: | |
name: coverage-report | |
path: htmlcov/ | |
- name: Generate coverage comment | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
with: | |
script: | | |
const fs = require('fs'); | |
fs.mkdirSync('./pr-comment', { recursive: true }); | |
const COVERAGE_PERCENTAGE = process.env.COVERAGE_PERCENTAGE; | |
const COVERAGE_REPORT_PATH = `https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/`; | |
var pr_number = `${{ github.event.number }}`; | |
var body = ` | |
Code coverage report is ready! :chart_with_upwards_trend: | |
- **Code Coverage Percentage:** ${COVERAGE_PERCENTAGE} | |
- **Code Coverage Report:** [View Coverage Report](${COVERAGE_REPORT_PATH}) | |
`; | |
fs.writeFileSync('./pr-comment/pr-number.txt', pr_number); | |
fs.writeFileSync('./pr-comment/body.txt', body); | |
- uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 | |
with: | |
name: pr-comment | |
path: pr-comment/ |