Skip to content

Commit 394994a

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

File tree

4 files changed

+116
-45
lines changed

4 files changed

+116
-45
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/scripts/run_its.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ cd -
1515
unset SONAR_TOKEN
1616
unset SONAR_HOST_URL
1717

18+
poetry install
1819
poetry run pytest --its tests/its

.github/workflows/build.yml

Lines changed: 34 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ jobs:
2929
artifactory-deployer-role: qa-deployer
3030
deploy-pull-request: true
3131

32-
3332
formatting:
3433
name: "Formatting"
3534
runs-on: github-ubuntu-latest-s
@@ -38,16 +37,7 @@ jobs:
3837
contents: write
3938
steps:
4039
- 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
40+
- uses: ./.github/actions/config-poetry
5141
- run: |
5242
poetry run black src/ tests/ --check
5343
poetry run licenseheaders -t license_header.tmpl -o "SonarSource SA" -y 2011-2024 -n "Sonar Scanner Python" -E .py -d src/
@@ -66,33 +56,52 @@ jobs:
6656
with:
6757
install_args: "poetry@2.2.1"
6858
- run: mise use -g poetry@2.2.1
69-
- run: poetry install
7059
- run: |
7160
poetry run python tools/generate_cli_documentation.py
7261
git diff --exit-code CLI_ARGS.md
7362
63+
coverage:
64+
name: "Coverage report generation"
65+
runs-on: github-ubuntu-latest-s
66+
permissions:
67+
id-token: write
68+
contents: write
69+
steps:
70+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
71+
- uses: ./.github/actions/config-poetry
72+
- run: |
73+
poetry run pytest --cov-report=xml:coverage.xml --cov-config=pyproject.toml --cov=src --cov-branch tests
74+
poetry run mypy src/ > mypy-report.txt || true
75+
- name: Upload coverage artifacts
76+
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
77+
with:
78+
name: coverage-reports
79+
path: |
80+
coverage.xml
81+
mypy-report.txt
82+
7483
analysis:
7584
name: "NEXT Analysis"
7685
runs-on: github-ubuntu-latest-s
86+
needs: [coverage]
7787
permissions:
7888
id-token: write
7989
contents: write
8090
steps:
8191
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
92+
- name: Download coverage artifacts
93+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
94+
with:
95+
name: coverage-reports
8296
- uses: jdx/mise-action@e3d7b8d67a7958d1207f6ed871e83b1ea780e7b0 #v3.3.1
8397
with:
8498
install_args: "poetry@2.2.1"
85-
- run: |
86-
mise use -g poetry@2.2.1
99+
- run: mise use -g poetry@2.2.1
87100
- uses: SonarSource/ci-github-actions/build-poetry@v1
88101
with:
89-
sonar-platform: next
90-
artifactory-reader-role: private-reader
102+
sonar-platform: next
103+
artifactory-reader-role: private-reader
91104
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
96105

97106
qa:
98107
name: "Test Python ${{ matrix.python-version }}"
@@ -105,17 +114,7 @@ jobs:
105114
python-version: ["3.9.18", "3.9.6", "3.10.13", "3.11.7", "3.12.1", "3.13.2"]
106115
steps:
107116
- 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
117+
- uses: ./.github/actions/config-poetry
119118
- run: |
120119
poetry run pytest tests/
121120
@@ -127,15 +126,7 @@ jobs:
127126
contents: write
128127
steps:
129128
- 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
129+
- uses: ./.github/actions/config-poetry
139130
- run: |
140131
poetry run pytest tests/
141132
@@ -148,7 +139,7 @@ jobs:
148139
steps:
149140
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
150141
- name: Cache SonarQube
151-
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
142+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
152143
with:
153144
path: sonarqube_cache/
154145
key: sonarqube-25.3.0.104237
@@ -160,10 +151,8 @@ jobs:
160151
fi
161152
env:
162153
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
154+
- uses: ./.github/actions/config-poetry
155+
- run: ./.github/scripts/run_its.sh
167156

168157
promote:
169158
name: "Promote"

0 commit comments

Comments
 (0)