From 5f1c8859308bbc8618eaa82f7104085047503fde Mon Sep 17 00:00:00 2001 From: Cunliang Geng Date: Mon, 18 Mar 2024 11:33:31 +0100 Subject: [PATCH] separate building and sonarcloud actions --- .github/workflows/build.yml | 34 ----------------- .github/workflows/sonar-cloud.yml | 63 +++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/sonar-cloud.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e95bcade..3226cf5a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 }} diff --git a/.github/workflows/sonar-cloud.yml b/.github/workflows/sonar-cloud.yml new file mode 100644 index 00000000..656c0ea7 --- /dev/null +++ b/.github/workflows/sonar-cloud.yml @@ -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 }}