Replace Maven dependency with python native proto binding and submodule workflow #147
Workflow file for this run
This file contains hidden or 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 'uprotocol-bot@eclipse.org' | |
| - 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.8' | |
| - name: Install Poetry | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install poetry | |
| - name: Checkout submodules | |
| run: | | |
| git submodule update --init --recursive | |
| - name: Set up Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install .[dev] | |
| - name: Generate protobufs | |
| run: | | |
| python generate_proto.py | |
| - name: Verify generated protobuf files | |
| run: | | |
| ls -lhR uprotocol/v1 | |
| - name: Run tests with coverage | |
| run: | | |
| set -o pipefail | |
| coverage run --source=uprotocol -m pytest -x -o log_cli=true 2>&1 | tee test-output.log | |
| 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" | |
| coverage html | |
| timeout-minutes: 3 | |
| - 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/ |