Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .azure/templates/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# .azure/templates/run-tests.yml
parameters:
- name: includeReleaseCandidates
type: boolean
default: false

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
displayName: 'Use Python $(python.version)'

- script: |
echo "=== System Information ==="
python --version
echo "Agent OS: $(Agent.OS)"
echo "Python version: $(python.version)"
displayName: 'Print system information'

- script: |
python -m pip install --upgrade pip
python -m pip install -U uv
displayName: 'Install uv'

- script: |
uv sync --python $(python.version) --extra test
displayName: 'Install dependencies'
condition: ${{ eq(parameters.includeReleaseCandidates, false) }}

- script: |
uv sync --python $(python.version) --extra test --prerelease allow
Comment on lines +26 to +31
displayName: 'Install dependencies (allow pre-releases)'
condition: ${{ eq(parameters.includeReleaseCandidates, true) }}

- script: |
uv run pytest tests/ -v --disable-warnings --junitxml=junit/test-results.xml --cov=scalar/ --cov-report=xml --cov-report=html
displayName: 'Run tests'
env:
CI: 'true'
AZURE_PIPELINES: 'true'

- task: PublishTestResults@2
inputs:
testResultsFiles: '**/test-results.xml'
testRunTitle: '$(Agent.OS) - $(Build.BuildNumber)[$(Agent.JobName)] - Python $(python.version)'
condition: succeededOrFailed()

- task: PublishCodeCoverageResults@2
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/htmlcov'
displayName: 'Publish coverage results'
condition: succeededOrFailed()
119 changes: 119 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Azure Pipelines CI for scalar-cluster
#
# Trigger a build when there is a push to the main branch or a tag starts with release-
trigger:
branches:
include:
- main
tags:
include:
- release-*

# Trigger a build when there is a pull request to the main branch
# Ignore PRs that are just updating the docs
pr:
branches:
include:
- main
exclude:
- docs/*
- README.rst

parameters:
- name: includeReleaseCandidates
displayName: "Allow pre-release dependencies"
type: boolean
default: false

variables:
triggeredByPullRequest: $[eq(variables['Build.Reason'], 'PullRequest')]

stages:
- stage: RunAllTests
displayName: Run test suite
jobs:
- job: Tests
timeoutInMinutes: 60
pool:
vmImage: $(imageName)
workspace:
clean: all
strategy:
matrix:
linux_py39:
imageName: 'ubuntu-latest'
python.version: '3.9'
linux_py310:
imageName: 'ubuntu-latest'
python.version: '3.10'
linux_py311:
imageName: 'ubuntu-latest'
python.version: '3.11'
linux_py312:
imageName: 'ubuntu-latest'
python.version: '3.12'
windows_py310:
imageName: 'windows-latest'
python.version: '3.10'
windows_py312:
imageName: 'windows-latest'
python.version: '3.12'
mac_py310:
imageName: 'macOS-latest'
python.version: '3.10'
mac_py312:
imageName: 'macOS-latest'
python.version: '3.12'
Comment on lines +42 to +66
steps:
- template: .azure/templates/run-tests.yml
parameters:
includeReleaseCandidates: ${{ parameters.includeReleaseCandidates }}

- stage: BuildPublishArtifact
dependsOn: RunAllTests
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/release-'), eq(variables.triggeredByPullRequest, false))
jobs:
- job: BuildArtifacts
timeoutInMinutes: 60
displayName: Build source dists and wheels
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.10'
displayName: 'Use Python 3.10'

- script: |
python -m pip install --upgrade pip
python -m pip install -U uv
uv sync --python "$(python -c 'import sys; print(sys.executable)')"
displayName: 'Install dependencies'
Comment on lines +90 to +91

- script: |
uv build --no-sources --sdist --wheel
displayName: 'Build package'

- bash: |
export PACKAGE_VERSION="$(uv version --short)"
echo "Package Version: ${PACKAGE_VERSION}"
echo "##vso[task.setvariable variable=packageVersionFormatted;]release-${PACKAGE_VERSION}"
displayName: 'Get package version'

- script: |
echo "Version in git tag $(Build.SourceBranchName) does not match version derived from setup.py $(packageVersionFormatted)"
exit 1
displayName: Raise error if version doesnt match tag
condition: and(succeeded(), ne(variables['Build.SourceBranchName'], variables['packageVersionFormatted']))

- task: DownloadSecureFile@1
name: PYPIRC_CONFIG
displayName: 'Download pypirc'
inputs:
secureFile: 'pypirc'

- script: |
uvx twine check dist/*
uvx twine upload --repository pypi --config-file $(PYPIRC_CONFIG.secureFilePath) dist/*
displayName: 'Upload to PyPI'
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], variables['packageVersionFormatted']))