|
9 | 9 | - 'feature/**'
|
10 | 10 |
|
11 | 11 | jobs:
|
12 |
| - test: |
13 |
| - runs-on: ubuntu-latest |
14 |
| - permissions: |
15 |
| - id-token: write # required by SonarSource/vault-action-wrapper |
16 |
| - contents: read # required by actions/checkout |
17 |
| - strategy: |
18 |
| - fail-fast: false |
19 |
| - matrix: |
20 |
| - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] |
21 |
| - steps: |
22 |
| - - name: Get vault secrets |
23 |
| - id: secrets |
24 |
| - uses: SonarSource/vault-action-wrapper@v2 |
25 |
| - with: |
26 |
| - secrets: | |
27 |
| - development/artifactory/token/{REPO_OWNER_NAME_DASH}-private-reader role | ARTIFACTORY_ROLE; |
28 |
| - development/artifactory/token/{REPO_OWNER_NAME_DASH}-private-reader access_token | ARTIFACTORY_PASSWORD; |
29 |
| - development/kv/data/repox url | REPOX_URL; |
30 |
| - - uses: actions/checkout@v3 |
31 |
| - - name: Install Poetry |
32 |
| - run: | |
33 |
| - pipx install poetry |
34 |
| - - name: Set up Python ${{ matrix.python-version }} |
35 |
| - uses: actions/setup-python@v4 |
36 |
| - with: |
37 |
| - python-version: ${{ matrix.python-version }} |
38 |
| - cache: "poetry" |
39 |
| - - name: Install dependencies |
40 |
| - env: |
41 |
| - ARTIFACTORY_USERNAME: vault-${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_ROLE }} |
42 |
| - ARTIFACTORY_PASSWORD: ${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_PASSWORD }} |
43 |
| - REPOX_URL: ${{ fromJSON(steps.secrets.outputs.vault).REPOX_URL }} |
44 |
| - run: | |
45 |
| - poetry config repositories.repox "${REPOX_URL}/api/pypi/sonarsource-pypi/simple/" |
46 |
| - poetry config http-basic.repox "${ARTIFACTORY_USERNAME}" "${ARTIFACTORY_PASSWORD}" |
47 |
| - poetry install |
48 |
| - - name: Check tests |
49 |
| - run: | |
50 |
| - poetry run pytest tests/ |
51 |
| - analysis: |
52 |
| - runs-on: ubuntu-latest |
53 |
| - permissions: |
54 |
| - id-token: write # required by SonarSource/vault-action-wrapper |
55 |
| - contents: read # required by actions/checkout |
56 |
| - pull-requests: read # required by SonarSource/sonarcloud-github-action |
57 |
| - strategy: |
58 |
| - fail-fast: false |
59 |
| - steps: |
60 |
| - - name: Get vault secrets |
61 |
| - id: secrets |
62 |
| - uses: SonarSource/vault-action-wrapper@v2 |
63 |
| - with: |
64 |
| - secrets: | |
65 |
| - development/artifactory/token/{REPO_OWNER_NAME_DASH}-private-reader role | ARTIFACTORY_ROLE; |
66 |
| - development/artifactory/token/{REPO_OWNER_NAME_DASH}-private-reader access_token | ARTIFACTORY_PASSWORD; |
67 |
| - development/kv/data/repox url | REPOX_URL; |
68 |
| - development/kv/data/sonarcloud token | SONARCLOUD_TOKEN; |
69 |
| - - uses: actions/checkout@v3 |
70 |
| - - name: Install Poetry |
71 |
| - run: | |
72 |
| - pipx install poetry |
73 |
| - - name: Set up Python |
74 |
| - uses: actions/setup-python@v4 |
75 |
| - with: |
76 |
| - python-version: | |
77 |
| - 3.12 |
78 |
| - cache: "poetry" |
79 |
| - - name: Install dependencies |
80 |
| - env: |
81 |
| - ARTIFACTORY_USERNAME: vault-${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_ROLE }} |
82 |
| - ARTIFACTORY_PASSWORD: ${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_PASSWORD }} |
83 |
| - REPOX_URL: ${{ fromJSON(steps.secrets.outputs.vault).REPOX_URL }} |
84 |
| - run: | |
85 |
| - poetry config repositories.repox "${REPOX_URL}/api/pypi/sonarsource-pypi/simple/" |
86 |
| - poetry config http-basic.repox "${ARTIFACTORY_USERNAME}" "${ARTIFACTORY_PASSWORD}" |
87 |
| - poetry install |
88 |
| - - name: Check formatting |
89 |
| - run: | |
90 |
| - poetry run black src/ tests/ --check |
91 |
| - - name: Check licensing |
92 |
| - run: | |
93 |
| - poetry run licenseheaders -t license_header.tmpl -o "SonarSource SA" -y 2011-2024 -n "Sonar Scanner Python" -E .py -d src/ |
94 |
| - poetry run licenseheaders -t license_header.tmpl -o "SonarSource SA" -y 2011-2024 -n "Sonar Scanner Python" -E .py -d tests/ |
95 |
| - poetry run licenseheaders -t license_header.tmpl -o "SonarSource SA" -y 2011-2024 -n "Sonar Scanner Python" -E .py -d its/ -x its/sources/**.py |
96 |
| - git diff --name-only --exit-code ./src ./tests ./its |
97 |
| - - name: Check tests and generate coverage |
98 |
| - run: | |
99 |
| - poetry run pytest --cov-report=xml:coverage.xml --cov-config=pyproject.toml --cov=src --cov-branch tests |
100 |
| - - name: SonarCloud Scan |
101 |
| - uses: SonarSource/sonarcloud-github-action@master |
102 |
| - env: |
103 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
104 |
| - SONAR_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).SONARCLOUD_TOKEN }} |
105 | 12 | integration_tests:
|
106 | 13 | runs-on: ubuntu-latest
|
107 | 14 | permissions:
|
@@ -144,37 +51,3 @@ jobs:
|
144 | 51 | working-directory: ./its
|
145 | 52 | run: |
|
146 | 53 | poetry run pytest
|
147 |
| - publish: |
148 |
| - runs-on: ubuntu-latest |
149 |
| - permissions: |
150 |
| - id-token: write # required by SonarSource/vault-action-wrapper |
151 |
| - contents: read # required by actions/checkout |
152 |
| - strategy: |
153 |
| - fail-fast: false |
154 |
| - steps: |
155 |
| - - name: Get vault secrets |
156 |
| - id: secrets |
157 |
| - uses: SonarSource/vault-action-wrapper@v2 |
158 |
| - with: |
159 |
| - secrets: | |
160 |
| - development/artifactory/token/{REPO_OWNER_NAME_DASH}-qa-deployer access_token | ARTIFACTORY_PASSWORD_QA; |
161 |
| - - uses: actions/checkout@v3 |
162 |
| - - name: Set up Python |
163 |
| - uses: actions/setup-python@v4 |
164 |
| - with: |
165 |
| - python-version: | |
166 |
| - 3.12 |
167 |
| - - name: Install Poetry |
168 |
| - run: | |
169 |
| - pipx install poetry |
170 |
| - - name: Configure pypi repo |
171 |
| - run: poetry config repositories.sonarsource https://repox.jfrog.io/artifactory/api/pypi/sonarsource-pypi-builds |
172 |
| - - name: Build and publish |
173 |
| - env: |
174 |
| - ARTIFACTORY_PYPI_DEPLOYER_USER: vault-SonarSource-sonar-scanner-python-qa-deployer |
175 |
| - ARTIFACTORY_PYPI_DEPLOYER_API_KEY: ${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_PASSWORD_QA }} |
176 |
| - run: | |
177 |
| - poetry version patch |
178 |
| - poetry version $(poetry version -s).dev${{ github.run_number }} |
179 |
| - poetry build |
180 |
| - poetry publish -r sonarsource --username $ARTIFACTORY_PYPI_DEPLOYER_USER --password $ARTIFACTORY_PYPI_DEPLOYER_API_KEY --verbose |
0 commit comments