-
Notifications
You must be signed in to change notification settings - Fork 4
SCANPY-217: Migrate from Cirrus CI to GitHub Action #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b215d0b
SCANPY-217: Migrate from Cirrus CI to GitHub Action
joke1196 68a2b49
Fix after review
joke1196 ef8707a
Test with proper Python version
joke1196 e1d9948
Test with pipx backend
joke1196 488eec6
Getting rid of the pipx backend
joke1196 0bb15a5
Used provided sonar version
joke1196 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| --- | ||
| name: Configure Poetry | ||
| description: GitHub Action to configure a poetry project | ||
joke1196 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| inputs: | ||
| python-version: | ||
| description: The version of python to use | ||
| default: 3.12.1 | ||
| poetry-version: | ||
| description: The version of poetry to install | ||
| default: 2.2.1 | ||
| jfrog-version: | ||
| description: The version of jFrog to install | ||
| default: 2.77.0 | ||
| poetry-virtualenvs-path: | ||
| description: Path to the Poetry virtual environments, relative to GitHub workspace. The folder is cached only if it is a subdirectory of | ||
| `poetry-cache-dir`. | ||
| default: .cache/pypoetry/virtualenvs | ||
| poetry-cache-dir: | ||
| description: Path to the Poetry cache directory, relative to GitHub workspace. | ||
| default: .cache/pypoetry | ||
| outputs: | ||
| BUILD_NUMBER: | ||
| description: The build number, incremented or reused if already cached | ||
| value: ${{ steps.get_build_number.outputs.BUILD_NUMBER }} | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Set build parameters | ||
| shell: bash | ||
| env: | ||
| ARTIFACTORY_READER_ROLE: private-reader | ||
| run: | | ||
| echo "ARTIFACTORY_READER_ROLE=${ARTIFACTORY_READER_ROLE}" >> "$GITHUB_ENV" | ||
| - uses: SonarSource/ci-github-actions/get-build-number@v1 | ||
| id: get_build_number | ||
| - name: Cache local Poetry cache | ||
| uses: SonarSource/ci-github-actions/cache@v1 | ||
| with: | ||
| path: ${{ inputs.poetry-cache-dir }} | ||
| key: poetry-${{ runner.os }}-${{ hashFiles('poetry.lock') }} | ||
| restore-keys: poetry-${{ runner.os }}- | ||
| - name: Install mise and Python | ||
| uses: jdx/mise-action@5ac50f778e26fac95da98d50503682459e86d566 # v3.2.0 | ||
| with: | ||
| version: 2025.7.12 | ||
| install_args: "python@${{ inputs.python-version }}" | ||
| - name: Install jfrog and poetry through mise | ||
| uses: jdx/mise-action@5ac50f778e26fac95da98d50503682459e86d566 # v3.2.0 | ||
| with: | ||
| version: 2025.7.12 | ||
| experimental: true # needed to use the http backend for installation of jfrog on windows | ||
| - name: Vault | ||
| # yamllint disable rule:line-length | ||
| id: secrets | ||
| uses: SonarSource/vault-action-wrapper@320bd31b03e5dacaac6be51bbbb15adf7caccc32 # 3.1.0 | ||
| with: | ||
| secrets: | | ||
| development/artifactory/token/{REPO_OWNER_NAME_DASH}-${{ env.ARTIFACTORY_READER_ROLE }} access_token | ARTIFACTORY_ACCESS_TOKEN; | ||
| # yamllint enable rule:line-length | ||
| - name: Config Poetry | ||
| id: config | ||
| shell: bash | ||
| env: | ||
| ARTIFACTORY_URL: https://repox.jfrog.io/artifactory | ||
| ARTIFACTORY_PYPI_REPO: sonarsource-pypi | ||
| ARTIFACTORY_ACCESS_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_ACCESS_TOKEN }} | ||
| POETRY_VIRTUALENVS_PATH: ${{ github.workspace }}/${{ inputs.poetry-virtualenvs-path }} | ||
| POETRY_CACHE_DIR: ${{ github.workspace }}/${{ inputs.poetry-cache-dir }} | ||
| run: | | ||
| echo "POETRY_VIRTUALENVS_PATH=${POETRY_VIRTUALENVS_PATH}" >> "$GITHUB_ENV" | ||
| echo "POETRY_CACHE_DIR=${POETRY_CACHE_DIR}" >> "$GITHUB_ENV" | ||
| ${GITHUB_ACTION_PATH}/config-poetry.sh | ||
|
|
||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #!/bin/bash | ||
| # Config script for SonarSource Poetry projects. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| : "${ARTIFACTORY_URL:?}" | ||
joke1196 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| : "${ARTIFACTORY_PYPI_REPO:?}" "${ARTIFACTORY_ACCESS_TOKEN:?}" | ||
| : "${BUILD_NUMBER:?}" "${GITHUB_REPOSITORY:?}" | ||
|
|
||
| set_build_env() { | ||
| export PROJECT=${GITHUB_REPOSITORY#*/} | ||
| echo "PROJECT: $PROJECT" | ||
| } | ||
|
|
||
| config_poetry() { | ||
| jf config add repox --artifactory-url "$ARTIFACTORY_URL" --access-token "$ARTIFACTORY_ACCESS_TOKEN" | ||
| jf poetry-config --server-id-resolve repox --repo-resolve "$ARTIFACTORY_PYPI_REPO" | ||
| jf poetry install --build-name="$PROJECT" --build-number="$BUILD_NUMBER" | ||
| } | ||
|
|
||
| main() { | ||
| set_build_env | ||
| config_poetry | ||
| } | ||
|
|
||
| if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then | ||
| main "$@" | ||
| fi | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| unzip -q sonarqube_cache/sonarqube.zip -d sonarqube | ||
|
|
||
| PLATFORM="linux-x86-64" | ||
| if [[ "$(uname)" == "Darwin" ]]; then | ||
| PLATFORM="macosx-universal-64" | ||
| fi | ||
|
|
||
| cd $(ls -d sonarqube/*/) | ||
| ./bin/${PLATFORM}/sonar.sh start | ||
| cd - | ||
|
|
||
| unset SONAR_TOKEN | ||
| unset SONAR_HOST_URL | ||
|
|
||
| poetry install | ||
| poetry run pytest --its tests/its |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the macos runner seem to work now in GH action. But this also can be tackled as a separate ticket