Skip to content

Commit

Permalink
separate building and sonarcloud actions
Browse files Browse the repository at this point in the history
  • Loading branch information
CunliangGeng committed Mar 18, 2024
1 parent 20cceb0 commit 5f1c885
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 34 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,37 +86,3 @@ jobs:
install-nplinker-deps --run-on-github
- name: Run unit tests
run: pytest -v

sonarcloud:
name: SonarCloud
needs: smoke_test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Python info
shell: bash -l {0}
run: |
which python3
python3 --version
- name: Upgrade pip and setuptools
run: |
python3 -m pip install --upgrade pip setuptools wheel
- name: Install nplinker and its dependencies
run: |
python3 -m pip install .[dev]
install-nplinker-deps --run-on-github
- name: Check style against standards using ruff
run: ruff .
- name: Run unit tests with coverage
run: pytest --cov --cov-report term --cov-report xml --junitxml=xunit-result.xml tests/
- name: Correct coverage paths
run: sed -i "s+$PWD/++g" coverage.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{secrets.SONAR_TOKEN }}
63 changes: 63 additions & 0 deletions .github/workflows/sonar-cloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Check format and coverage, then upload to SonarCloud

on:
push:
branches:
- main
- dev
paths:
- bin/**
- src/**
- tests/**
- setup.py
- .github/workflows/build.yml
pull_request:
branches:
- main
- dev
paths:
- bin/**
- src/**
- tests/**
- setup.py
- .github/workflows/build.yml
types:
- opened
- reopened
- synchronize
- ready_for_review

jobs:

sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Python info
shell: bash -l {0}
run: |
which python3
python3 --version
- name: Upgrade pip and setuptools
run: |
python3 -m pip install --upgrade pip setuptools wheel
- name: Install nplinker and its dependencies
run: |
python3 -m pip install .[dev]
install-nplinker-deps --run-on-github
- name: Check style against standards using ruff
run: ruff check .
- name: Run unit tests with coverage
run: pytest --cov --cov-report term --cov-report xml --junitxml=xunit-result.xml tests/unit
- name: Correct coverage paths
run: sed -i "s+$PWD/++g" coverage.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{secrets.SONAR_TOKEN }}

0 comments on commit 5f1c885

Please sign in to comment.