Skip to content

Commit dbc735f

Browse files
committed
Test split poetry install action
1 parent 74d0075 commit dbc735f

File tree

3 files changed

+89
-44
lines changed

3 files changed

+89
-44
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
name: Configure Poetry
3+
description: GitHub Action to configure a poetry project
4+
5+
outputs:
6+
project-version:
7+
description: The project version from pyproject.toml with BUILD_NUMBER
8+
value: ${{ steps.build.outputs.project-version }}
9+
BUILD_NUMBER:
10+
description: The build number, incremented or reused if already cached
11+
value: ${{ steps.get_build_number.outputs.BUILD_NUMBER }}
12+
13+
runs:
14+
using: composite
15+
steps:
16+
- name: Set build parameters
17+
shell: bash
18+
env:
19+
ARTIFACTORY_READER_ROLE: private-reader
20+
run: |
21+
echo "ARTIFACTORY_READER_ROLE=${ARTIFACTORY_READER_ROLE}" >> "$GITHUB_ENV"
22+
- uses: SonarSource/ci-github-actions/get-build-number@v1
23+
id: get_build_number
24+
- name: Cache local Poetry cache
25+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
26+
with:
27+
path: ${{ github.workspace }}/.cache/pypoetry
28+
key: poetry-${{ runner.os }}-${{ hashFiles('poetry.lock') }}
29+
restore-keys: poetry-${{ runner.os }}-
30+
- uses: jdx/mise-action@5ac50f778e26fac95da98d50503682459e86d566 # v3.2.0
31+
with:
32+
version: 2025.7.12
33+
install_args: "jfrog-cli@2.77.0 poetry@2.2.1"
34+
- name: Vault
35+
# yamllint disable rule:line-length
36+
id: secrets
37+
uses: SonarSource/vault-action-wrapper@320bd31b03e5dacaac6be51bbbb15adf7caccc32 # 3.1.0
38+
with:
39+
secrets: |
40+
development/artifactory/token/{REPO_OWNER_NAME_DASH}-${{ env.ARTIFACTORY_READER_ROLE }} access_token | ARTIFACTORY_ACCESS_TOKEN;
41+
# yamllint enable rule:line-length
42+
- name: Config Poetry
43+
id: config
44+
shell: bash
45+
env:
46+
ARTIFACTORY_URL: https://repox.jfrog.io/artifactory
47+
ARTIFACTORY_PYPI_REPO: sonarsource-pypi
48+
ARTIFACTORY_ACCESS_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_ACCESS_TOKEN }}
49+
run: |
50+
mise use -g poetry@2.2.1
51+
mise use -g jfrog-cli@2.77.0
52+
${GITHUB_ACTION_PATH}/config-poetry.sh
53+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# Config script for SonarSource Poetry projects.
3+
4+
set -euo pipefail
5+
6+
: "${ARTIFACTORY_URL:?}"
7+
: "${ARTIFACTORY_PYPI_REPO:?}" "${ARTIFACTORY_ACCESS_TOKEN:?}"
8+
: "${BUILD_NUMBER:?}" "${GITHUB_REPOSITORY:?}"
9+
10+
set_build_env() {
11+
export PROJECT=${GITHUB_REPOSITORY#*/}
12+
echo "PROJECT: $PROJECT"
13+
}
14+
15+
config_poetry() {
16+
jf config add repox --artifactory-url "$ARTIFACTORY_URL" --access-token "$ARTIFACTORY_ACCESS_TOKEN"
17+
jf poetry-config --server-id-resolve repox --repo-resolve "$ARTIFACTORY_PYPI_REPO"
18+
jf poetry install --build-name="$PROJECT" --build-number="$BUILD_NUMBER"
19+
}
20+
21+
main() {
22+
set_build_env
23+
config_poetry
24+
}
25+
26+
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
27+
main "$@"
28+
fi

.github/workflows/build.yml

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,7 @@ jobs:
3838
contents: write
3939
steps:
4040
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
41-
- uses: jdx/mise-action@e3d7b8d67a7958d1207f6ed871e83b1ea780e7b0 #v3.3.1
42-
with:
43-
install_args: "poetry@2.2.1"
44-
- run: mise use -g poetry@2.2.1
45-
- uses: SonarSource/ci-github-actions/build-poetry@v1
46-
with:
47-
sonar-platform: none
48-
artifactory-reader-role: private-reader
49-
artifactory-deployer-role: qa-deployer
50-
- run: poetry install
41+
- uses: ./.github/actions/config-poetry
5142
- run: |
5243
poetry run black src/ tests/ --check
5344
poetry run licenseheaders -t license_header.tmpl -o "SonarSource SA" -y 2011-2024 -n "Sonar Scanner Python" -E .py -d src/
@@ -66,7 +57,6 @@ jobs:
6657
with:
6758
install_args: "poetry@2.2.1"
6859
- run: mise use -g poetry@2.2.1
69-
- run: poetry install
7060
- run: |
7161
poetry run python tools/generate_cli_documentation.py
7262
git diff --exit-code CLI_ARGS.md
@@ -79,20 +69,15 @@ jobs:
7969
contents: write
8070
steps:
8171
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
82-
- uses: jdx/mise-action@e3d7b8d67a7958d1207f6ed871e83b1ea780e7b0 #v3.3.1
83-
with:
84-
install_args: "poetry@2.2.1"
72+
- uses: ./.github/actions/config-poetry
8573
- run: |
86-
mise use -g poetry@2.2.1
74+
poetry run pytest --cov-report=xml:coverage.xml --cov-config=pyproject.toml --cov=src --cov-branch tests
75+
poetry run mypy src/ > mypy-report.txt || true
8776
- uses: SonarSource/ci-github-actions/build-poetry@v1
8877
with:
8978
sonar-platform: next
9079
artifactory-reader-role: private-reader
9180
artifactory-deployer-role: qa-deployer
92-
- run: poetry install
93-
- run: |
94-
poetry run pytest --cov-report=xml:coverage.xml --cov-config=pyproject.toml --cov=src --cov-branch tests
95-
poetry run mypy src/ > mypy-report.txt || true
9681

9782
qa:
9883
name: "Test Python ${{ matrix.python-version }}"
@@ -105,17 +90,7 @@ jobs:
10590
python-version: ["3.9.18", "3.9.6", "3.10.13", "3.11.7", "3.12.1", "3.13.2"]
10691
steps:
10792
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
108-
- uses: jdx/mise-action@e3d7b8d67a7958d1207f6ed871e83b1ea780e7b0 #v3.3.1
109-
with:
110-
install_args: "poetry@2.2.1"
111-
- run: mise use -g poetry@2.2.1
112-
- uses: SonarSource/ci-github-actions/build-poetry@v1
113-
with:
114-
sonar-platform: none
115-
python-version: ${{ matrix.python-version }}
116-
artifactory-reader-role: private-reader
117-
artifactory-deployer-role: qa-deployer
118-
- run: poetry install
93+
- uses: ./.github/actions/config-poetry
11994
- run: |
12095
poetry run pytest tests/
12196
@@ -127,15 +102,7 @@ jobs:
127102
contents: write
128103
steps:
129104
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
130-
- uses: jdx/mise-action@e3d7b8d67a7958d1207f6ed871e83b1ea780e7b0 #v3.3.1
131-
with:
132-
install_args: "poetry@2.2.1"
133-
- uses: SonarSource/ci-github-actions/build-poetry@v1
134-
with:
135-
sonar-platform: none
136-
artifactory-reader-role: private-reader
137-
artifactory-deployer-role: qa-deployer
138-
- run: poetry install
105+
- uses: ./.github/actions/config-poetry
139106
- run: |
140107
poetry run pytest tests/
141108
@@ -148,7 +115,7 @@ jobs:
148115
steps:
149116
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
150117
- name: Cache SonarQube
151-
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
118+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
152119
with:
153120
path: sonarqube_cache/
154121
key: sonarqube-25.3.0.104237
@@ -160,10 +127,7 @@ jobs:
160127
fi
161128
env:
162129
SONARQUBE_VERSION: 25.3.0.104237
163-
- uses: SonarSource/ci-github-actions/build-poetry@v1
164-
with:
165-
sonar-platform: none
166-
script: .github/scripts/run_its.sh
130+
- run: .github/scripts/run_its.sh
167131

168132
promote:
169133
name: "Promote"

0 commit comments

Comments
 (0)