Skip to content

SCANPY-217: Migrate from Cirrus CI to GitHub Action #2

SCANPY-217: Migrate from Cirrus CI to GitHub Action

SCANPY-217: Migrate from Cirrus CI to GitHub Action #2

Workflow file for this run

name: Build
on:
push:
branches: [master, branch-*, dogfood-*]
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: "Build"
runs-on: sonar-xs-public
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: jdx/mise-action@c5c33d5a70c9cc62e906bc25c5eb6080e40c3eba # v3.2.0
- uses: SonarSource/ci-github-actions/build-poetry@v1
with:
sonar-platform: none
formatting:
name: "Formatting"
runs-on: sonar-xs-public
needs: [build]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: jdx/mise-action@c5c33d5a70c9cc62e906bc25c5eb6080e40c3eba # v3.2.0
- uses: SonarSource/ci-github-actions/build-poetry@v1
with:
script: |
poetry run black src/ tests/ --check
poetry run licenseheaders -t license_header.tmpl -o "SonarSource SA" -y 2011-2024 -n "Sonar Scanner Python" -E .py -d src/
poetry run licenseheaders -t license_header.tmpl -o "SonarSource SA" -y 2011-2024 -n "Sonar Scanner Python" -E .py -d tests/
git diff --name-only --exit-code ./src ./tests
sonar-platform: none
documentation:
name: "CLI Documentation"
runs-on: sonar-xs-public
needs: [build]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: jdx/mise-action@c5c33d5a70c9cc62e906bc25c5eb6080e40c3eba # v3.2.0
- uses: SonarSource/ci-github-actions/build-poetry@v1
with:
script: |
poetry run python tools/generate_cli_documentation.py
git diff --exit-code CLI_ARGS.md
sonar-platform: none
analysis:
name: "NEXT Analysis"
runs-on: sonar-xs-public
needs: [build]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: jdx/mise-action@c5c33d5a70c9cc62e906bc25c5eb6080e40c3eba # v3.2.0
- uses: SonarSource/ci-github-actions/build-poetry@v1
with:
script: |
poetry run pytest --cov-report=xml:coverage.xml --cov-config=pyproject.toml --cov=src --cov-branch tests
poetry run mypy src/ > mypy-report.txt || true
artifactory-reader-role: public-reader
artifactory-deployer-role: public-deployer
sonar-platform: next
qa:
name: "Test Python ${{ matrix.python-version }}"
runs-on: sonar-xs-public
needs: [build]
permissions:
id-token: write
contents: read
strategy:
matrix:
python-version: ["3.9.18", "3.9.6", "3.10.13", "3.11.7", "3.12.1", "3.13.2"]
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: jdx/mise-action@c5c33d5a70c9cc62e906bc25c5eb6080e40c3eba # v3.2.0
- uses: SonarSource/ci-github-actions/build-poetry@v1
with:
python-version: ${{ matrix.python-version }}
script: |
poetry run pytest tests/
sonar-platform: none
qa-windows:
name: "Test Windows"
runs-on: github-windows-latest-s
needs: [build]
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: SonarSource/ci-github-actions/build-poetry@v1
with:
script: |
poetry run pytest tests/
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
sonar-platform: none
its:
name: "Integration Tests"
runs-on: sonar-xs-public
needs: [build]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: jdx/mise-action@c5c33d5a70c9cc62e906bc25c5eb6080e40c3eba # v3.2.0
- name: Cache SonarQube
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: sonarqube_cache/
key: sonarqube-25.3.0.104237
- name: Download SonarQube
run: |
mkdir -p sonarqube_cache
if [ ! -f sonarqube_cache/sonarqube.zip ]; then
wget -q https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-25.3.0.104237.zip -O sonarqube_cache/sonarqube.zip
fi
env:
SONARQUBE_VERSION: 25.3.0.104237
- uses: SonarSource/ci-github-actions/build-poetry@v1
with:
sonar-platform: none
script: .github/scripts/run_its.sh
promote:
name: "Promote"
needs: [formatting, documentation, analysis, qa, qa-windows, its]
runs-on: sonar-xs-public
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: jdx/mise-action@c5c33d5a70c9cc62e906bc25c5eb6080e40c3eba # v3.2.0
- uses: SonarSource/ci-github-actions/build-poetry@v1
with:
sonar-platform: none
artifactory-reader-role: public-reader
artifactory-deployer-role: public-deployer
deploy-pull-request: true