Add sonar cloud analysis #24
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: "UnitTests" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref_name }} | |
cancel-in-progress: true | |
on: | |
push: | |
paths: | |
- "nuvla/**" | |
- "tests/**" | |
- ".github/workflows/unittests.yml" | |
- "pyproject.toml" | |
- "poetry.lock" | |
pull_request: | |
paths: | |
- "nuvla/**" | |
- "tests/**" | |
- ".github/workflows/unittests.yml" | |
- "pyproject.toml" | |
- "poetry.lock" | |
workflow_dispatch: | |
jobs: | |
run-unittests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Load cached Poetry installation | |
id: cached-poetry | |
uses: actions/cache@v4 | |
with: | |
path: ~/.local # the path depends on the OS | |
key: poetry-0 # increment to reset cache | |
- name: Setup Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Install test environment | |
run: | | |
pip install tox | |
- name: Run UnitTests | |
run: | | |
tox | |
- name: Install jq (For Quality Gate) | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y jq | |
- name: SonarCloud Scan | |
uses: SonarSource/sonarcloud-github-action@v2.1.1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }} | |
- name: SonarQube Quality Gate check | |
if: matrix.python_version == '3.11' | |
uses: sonarsource/sonarqube-quality-gate-action@v1.1.0 | |
# Force to fail step after specific time | |
timeout-minutes: 5 | |
with: | |
scanMetadataReportFile: .scannerwork/report-task.txt | |
env: | |
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }} | |
- name: Publish Unit Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
if: always() | |
with: | |
files: test-report.xml |