Skip to content

Commit 66577d7

Browse files
authored
SCANPY-78 CI Pipeline should test our scanner on a macos VM (#168)
1 parent 0378c00 commit 66577d7

File tree

3 files changed

+94
-10
lines changed

3 files changed

+94
-10
lines changed

.cirrus.yml

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ linux_container_definition: &LINUX_CONTAINER_DEFINITION
2929
cpu: 3
3030
memory: 8G
3131

32-
3332
win_vm_definition: &WINDOWS_VM_DEFINITION
3433
ec2_instance:
3534
experimental: true # see https://github.com/cirruslabs/cirrus-ci-docs/issues/1051
@@ -95,6 +94,31 @@ poetry_cache_template: &POETRY_CACHE
9594
eks_container:
9695
<<: *LINUX_CONTAINER_DEFINITION
9796

97+
98+
.poetry_macos_template: &POETRY_MACOS_TEMPLATE
99+
<<: *POETRY_CACHE
100+
jfrog_install_script:
101+
- brew install jfrog-cli
102+
- jf intro
103+
poetry_install_script:
104+
- brew install poetry
105+
- poetry config keyring.enabled false # Keyring is locked in macOS VM and not needed for downloading dependencies
106+
- jfrog config add repox --artifactory-url "$ARTIFACTORY_URL" --access-token "$ARTIFACTORY_PRIVATE_ACCESS_TOKEN"
107+
- jfrog poetry-config --server-id-resolve repox --repo-resolve sonarsource-pypi
108+
- jfrog poetry install --build-name="$CIRRUS_REPO_NAME" --build-number="$CI_BUILD_NUMBER"
109+
110+
macos_worker_template: &MACOS_WORKER_DEFINITION
111+
persistent_worker:
112+
isolation:
113+
tart:
114+
image: ghcr.io/cirruslabs/macos-sonoma-xcode:latest
115+
cpu: 3
116+
memory: 6G
117+
resources:
118+
tart-vms: 1
119+
labels:
120+
envname: prod
121+
98122
mend_scan_task:
99123
<<: *POETRY_LINUX_TEMPLATE
100124
depends_on:
@@ -171,6 +195,26 @@ qa_task:
171195
qa_script:
172196
- poetry run pytest tests/
173197

198+
qa_macos_task:
199+
alias: qa_macos
200+
only_if: $CIRRUS_CRON == "macos-its-cron"
201+
name: "[macOS] Run tests"
202+
<<: [*MACOS_WORKER_DEFINITION, *POETRY_MACOS_TEMPLATE]
203+
env:
204+
PATH: "/Users/admin/.local/bin:$PATH"
205+
install_uv_script:
206+
- brew install uv
207+
test_39_script:
208+
- .cirrus/run_macos_tests.sh "3.9.18"
209+
test_310_script:
210+
- .cirrus/run_macos_tests.sh "3.10.13"
211+
test_311_script:
212+
- .cirrus/run_macos_tests.sh "3.11.7"
213+
test_312_script:
214+
- .cirrus/run_macos_tests.sh "3.12.1"
215+
test_313_script:
216+
- .cirrus/run_macos_tests.sh "3.13.2"
217+
174218
qa_windows_task:
175219
name: "Test Windows"
176220
<<: *POETRY_WIN_INSTALL
@@ -194,15 +238,20 @@ its_task:
194238
fingerprint_script: echo "sonarqube-$SONARQUBE_VERSION"
195239
<<: *POETRY_LINUX_TEMPLATE
196240
its_script:
197-
- unzip -q sonarqube_cache/sonarqube.zip -d sonarqube
198-
- cd $(ls -d sonarqube/*/)
199-
- ./bin/linux-x86-64/sonar.sh start
200-
- cd -
201-
- jfrog poetry-config --server-id-resolve repox --repo-resolve sonarsource-pypi
202-
- jfrog poetry install
203-
- unset SONAR_TOKEN
204-
- unset SONAR_HOST_URL
205-
- poetry run pytest --its tests/its
241+
- .cirrus/run_its.sh
242+
243+
its_macos_task:
244+
name: "[macOS] Integration Tests"
245+
alias: its_macos
246+
only_if: $CIRRUS_CRON == "macos-its-cron"
247+
# the macOS workers are only available from Monday 06:45 CEST to Friday 20:00 CEST (see https://xtranet-sonarsource.atlassian.net/wiki/spaces/Platform/pages/3447980037/MacOS+Persistent+Workers+User+Guide+-+Cirrus+CI)
248+
<<: [*MACOS_WORKER_DEFINITION, *POETRY_MACOS_TEMPLATE]
249+
sonarqube_cache:
250+
folder: sonarqube_cache/
251+
populate_script: mkdir -p sonarqube_cache && wget -q https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-$SONARQUBE_VERSION.zip -O sonarqube_cache/sonarqube.zip
252+
fingerprint_script: echo "sonarqube-$SONARQUBE_VERSION"
253+
its_script:
254+
- .cirrus/run_its.sh
206255

207256
promote_task:
208257
depends_on:

.cirrus/run_its.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
unzip -q sonarqube_cache/sonarqube.zip -d sonarqube
5+
6+
PLATFORM="linux-x86-64"
7+
if [[ "$(uname)" == "Darwin" ]]; then
8+
PLATFORM="macosx-universal-64"
9+
fi
10+
11+
cd $(ls -d sonarqube/*/)
12+
./bin/${PLATFORM}/sonar.sh start
13+
cd -
14+
15+
jfrog poetry install
16+
17+
unset SONAR_TOKEN
18+
unset SONAR_HOST_URL
19+
20+
poetry run pytest --its tests/its

.cirrus/run_macos_tests.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
if [ $# -eq 0 ]; then
5+
echo "No arguments supplied"
6+
fi
7+
8+
PYTHON_VERSION="$1"
9+
echo "========================================================================"
10+
echo "Running tests on macOS with Python version: $PYTHON_VERSION"
11+
echo "========================================================================"
12+
uv python install ${PYTHON_VERSION} --default --preview
13+
poetry run python --version
14+
poetry install
15+
poetry run pytest tests/

0 commit comments

Comments
 (0)