Python tests #162
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 tests | |
on: | |
workflow_run: | |
workflows: [ 'Linting' ] | |
types: | |
- completed | |
jobs: | |
build: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Get PR information | |
uses: potiuk/get-workflow-origin@v1_5 | |
if: ${{ github.event.workflow_run.event == 'pull_request' }} | |
id: source-run-info | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
sourceRunId: ${{ github.event.workflow_run.id }} | |
- name: Set up yanglint | |
run: | | |
sudo apt update | |
sudo apt install libpcre2-dev libssl3 libssl-dev libxml2-dev | |
git clone --single-branch --depth 1 https://github.com/CESNET/libyang.git | |
mkdir libyang/build | |
cd libyang/build | |
cmake .. | |
make | |
sudo make install | |
sudo ldconfig | |
- uses: actions/checkout@v3 | |
if: ${{ github.event.workflow_run.event == 'pull_request' }} | |
with: | |
ref: ${{ steps.source-run-info.outputs.mergeCommitSha }} | |
- uses: actions/checkout@v3 | |
if: ${{ github.event.workflow_run.event != 'pull_request' }} | |
with: | |
ref: ${{ github.event.workflow_run.head_branch }} | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
cache: 'pip' | |
cache-dependency-path: | | |
requirements.txt | |
tests_requirements.txt | |
- name: Install dependencies | |
run: | | |
pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install -r tests_requirements.txt | |
- name: Run tests | |
env: | |
YANGCATALOG_CONFIG_PATH: tests/resources/test.conf | |
DJANGO_SETTINGS_MODULE: tests.resources.settings | |
CONFD_VERSION: 0 | |
run: | | |
coverage run manage.py test tests | |
coverage xml | |
- name: Coverage report PR | |
if: ${{ github.repository == 'YangCatalog/yang-validator-extractor' && github.event.workflow_run.event == 'pull_request' }} | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
override_commit: ${{ steps.source-run-info.outputs.mergeCommitSha }} | |
override_pr: ${{ steps.source-run-info.outputs.pullRequestNumber }} | |
files: ./coverage.xml | |
fail_ci_if_error: true | |
verbose: true | |
- name: Coverage report | |
if: ${{ github.repository == 'YangCatalog/yang-validator-extractor' && github.event.workflow_run.event != 'pull_request'}} | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ./coverage.xml | |
fail_ci_if_error: true | |
verbose: true | |
- uses: LouisBrunner/checks-action@v1.5.0 | |
if: always() | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
sha: ${{ github.event.workflow_run.head_sha }} | |
name: Tests | |
conclusion: ${{ job.status }} | |
output: "{\"summary\":\"Workflow run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" |