-
Notifications
You must be signed in to change notification settings - Fork 278
110 lines (90 loc) · 3.4 KB
/
build-python-steps.yml
File metadata and controls
110 lines (90 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Build Python SDK
on:
workflow_call:
inputs:
version:
required: true
type: string
useWinML:
required: false
type: boolean
default: false
platform:
required: false
type: string
default: 'windows'
permissions:
contents: read
jobs:
build:
runs-on: ${{ inputs.platform }}-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
clean: true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
# Clone test-data-shared from Azure DevOps (models for integration tests)
- name: Checkout test-data-shared from Azure DevOps
shell: pwsh
working-directory: ${{ github.workspace }}/..
run: |
$pat = "${{ secrets.AZURE_DEVOPS_PAT }}"
$encodedPat = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$pat"))
git config --global http.https://dev.azure.com.extraheader "AUTHORIZATION: Basic $encodedPat"
git lfs install
git clone --depth 1 https://dev.azure.com/microsoft/windows.ai.toolkit/_git/test-data-shared test-data-shared
Write-Host "Clone completed successfully to ${{ github.workspace }}/../test-data-shared"
- name: Checkout specific commit in test-data-shared
shell: pwsh
working-directory: ${{ github.workspace }}/../test-data-shared
run: |
git checkout 231f820fe285145b7ea4a449b112c1228ce66a41
if ($LASTEXITCODE -ne 0) {
Write-Error "Git checkout failed."
exit 1
}
- name: Install build tool
run: |
python -m pip install build
- name: Configure pip for Azure Artifacts
run: |
pip config set global.index-url https://pkgs.dev.azure.com/aiinfra/PublicPackages/_packaging/ORT-Nightly/pypi/simple/
pip config set global.extra-index-url https://pypi.org/simple/
pip config set global.pre true
- name: Set package version
working-directory: sdk/python
run: echo '__version__ = "${{ inputs.version }}"' > src/version.py
- name: Build wheel (Cross-Platform)
if: ${{ inputs.useWinML == false }}
working-directory: sdk/python
run: python -m build --wheel --outdir dist/
- name: Build wheel (WinML)
if: ${{ inputs.useWinML == true }}
working-directory: sdk/python
run: python -m build --wheel -C winml=true --outdir dist/
- name: Install built wheel
working-directory: sdk/python
shell: pwsh
run: |
$wheel = (Get-ChildItem dist/*.whl | Select-Object -First 1).FullName
pip install $wheel
- name: Install test dependencies
run: pip install coverage pytest>=7.0.0 pytest-timeout>=2.1.0
- name: Run tests
working-directory: sdk/python
run: python -m pytest test/ -v
- name: Upload Python packages
uses: actions/upload-artifact@v4
with:
name: python-sdk-${{ inputs.platform }}${{ inputs.useWinML == true && '-winml' || '' }}
path: sdk/python/dist/*
- name: Upload flcore logs
uses: actions/upload-artifact@v4
if: always()
with:
name: python-sdk-${{ inputs.platform }}${{ inputs.useWinML == true && '-winml' || '' }}-logs
path: sdk/python/logs/**