From 28ae40b6378c8aa248f50bcee9a1e5869a3e45c5 Mon Sep 17 00:00:00 2001 From: Cunliang Geng Date: Thu, 21 Mar 2024 14:39:31 +0100 Subject: [PATCH] enable github actions for PRs on all branches Major changes - update github actions to run building and type check actions for PRs on **all branches** - separate actions for building and sonarcloud - delete unused github action documentation.yml --- .github/workflows/build.yml | 37 ----------------- .github/workflows/documentation.yml | 40 ------------------ .github/workflows/sonar-cloud.yml | 63 +++++++++++++++++++++++++++++ .github/workflows/typing-check.yml | 3 -- pyproject.toml | 4 +- 5 files changed, 66 insertions(+), 81 deletions(-) delete mode 100644 .github/workflows/documentation.yml create mode 100644 .github/workflows/sonar-cloud.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1533b2f9..3226cf5a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,9 +12,6 @@ on: - setup.py - .github/workflows/build.yml pull_request: - branches: - - main - - dev paths: - bin/** - src/** @@ -89,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/documentation.yml b/.github/workflows/documentation.yml deleted file mode 100644 index 5e9999f0..00000000 --- a/.github/workflows/documentation.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: documentation - -on: - push: - branches: - - main - - dev - paths: - - docs/** - pull_request: - branches: - - main - - dev - paths: - - docs/** - -jobs: - build-documentation: - name: Build documentation - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.10 - uses: actions/setup-python@v2 - with: - python-version: 3.10 - - name: Python info - shell: bash -l {0} - run: | - which python3 - python3 --version - - name: Upgrade pip and install dependencies - run: | - python3 -m pip install --upgrade pip setuptools - python3 -m pip install .[dev,publishing] - - name: Install pandoc using apt - run: sudo apt install pandoc - - name: Build documentation - run: make coverage doctest html - working-directory: docs 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 }} diff --git a/.github/workflows/typing-check.yml b/.github/workflows/typing-check.yml index 1993530b..fdfbb657 100644 --- a/.github/workflows/typing-check.yml +++ b/.github/workflows/typing-check.yml @@ -9,9 +9,6 @@ on: - src/** - tests/** pull_request: - branches: - - main - - dev paths: - src/** - tests/** diff --git a/pyproject.toml b/pyproject.toml index 3673a9fb..acf50b91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,6 +67,8 @@ ignore_missing_imports = true [tool.ruff] target-version = "py310" line-length = 100 + +[tool.ruff.lint] select = [ "D", # pydocstyle "E", # pycodestyle (error) @@ -100,7 +102,7 @@ fixable = ["A", "B", "C", "D", "E", "F", "I"] ignore-init-module-imports = true -[tool.ruff.isort] +[tool.ruff.lint.isort] known-first-party = ["nplinker"] force-single-line = true lines-after-imports = 2