Repository navigation
162 lines (157 loc) · 6.65 KB
/
Copy path_build_python_reusable.yml
File metadata and controls
162 lines (157 loc) · 6.65 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Build and validate one Python component
on:
workflow_call:
inputs:
component:
required: true
type: string
source_repository:
required: true
type: string
source_sha:
required: true
type: string
target:
required: true
type: string
test_version:
type: string
default: ''
client_version:
type: string
default: ''
client_artifact_id:
type: string
default: ''
client_manifest_sha:
type: string
default: ''
outputs:
version:
value: ${{ jobs.build-check.outputs.version }}
artifact_id:
value: ${{ jobs.build-check.outputs.artifact_id }}
manifest_sha:
value: ${{ jobs.build-check.outputs.manifest_sha }}
permissions:
contents: read
env:
UV_VERSION: '0.12.18'
COMPONENT: ${{ inputs.component }}
SOURCE_REPOSITORY: ${{ inputs.source_repository }}
UV_DEFAULT_INDEX: https://pypi.org/simple
UV_NO_CONFIG: 'true'
jobs:
build-check:
runs-on: ubuntu-24.04
timeout-minutes: 30
outputs:
version: ${{ steps.metadata.outputs.version }}
manifest_sha: ${{ steps.manifest.outputs.manifest_sha }}
artifact_id: ${{ steps.upload.outputs.artifact-id }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.11'
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: ${{ inputs.source_repository }}
ref: ${{ inputs.source_sha }}
path: source
persist-credentials: false
- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
with:
version: ${{ env.UV_VERSION }}
enable-cache: false
- name: Validate and prepare package version
id: metadata
env:
TARGET: ${{ inputs.target }}
SOURCE_SHA: ${{ inputs.source_sha }}
TEST_VERSION: ${{ inputs.test_version }}
run: |
test "$(git -C source rev-parse HEAD)" = "$SOURCE_SHA"
python .github/scripts/python_release.py metadata --target "$TARGET" --test-version "$TEST_VERSION" --component "$COMPONENT"
- name: Build and check distributions
id: manifest
env:
SOURCE_SHA: ${{ inputs.source_sha }}
VERSION: ${{ steps.metadata.outputs.version }}
MODULE: ${{ steps.metadata.outputs.module }}
run: |
uv build --no-sources "source/$MODULE" --out-dir dist
uvx --from twine==7.0.0 twine check --strict dist/*
python .github/scripts/python_release.py manifest --sha "$SOURCE_SHA" --version "$VERSION" --component "$COMPONENT" --source-repository "$SOURCE_REPOSITORY"
- name: Isolated wheel and sdist smoke and client tests
if: inputs.component == 'client'
env:
VERSION: ${{ steps.metadata.outputs.version }}
run: |
uv python install 3.10 3.11
for version in 3.10 3.11; do
for artifact in "$GITHUB_WORKSPACE"/dist/*.whl "$GITHUB_WORKSPACE"/dist/*.tar.gz; do
scratch=$(mktemp -d)
uv venv --python "$version" "$scratch/venv"
uv pip install --python "$scratch/venv/bin/python" "$artifact"
(
cd "$scratch"
"$scratch/venv/bin/python" -I -c 'import importlib.metadata as m, os; from pyhugegraph.client import PyHugeClient; assert m.version("hugegraph-python") == os.environ["VERSION"]'
uv pip install --python "$scratch/venv/bin/python" 'pytest==8.4.2'
cp -R "$GITHUB_WORKSPACE/source/hugegraph-python-client/src/tests" "$scratch/tests"
"$scratch/venv/bin/python" -m pytest tests -m 'unit or contract' -v --tb=short
)
done
done
- name: Download tested client for the package pair
if: inputs.component == 'mcp' && inputs.client_artifact_id != ''
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
artifact-ids: ${{ inputs.client_artifact_id }}
merge-multiple: true
path: client-dist
- name: Select the client dependency
if: inputs.component == 'mcp'
id: client
env:
TARGET: ${{ inputs.target }}
SOURCE_SHA: ${{ inputs.source_sha }}
CLIENT_VERSION: ${{ inputs.client_version }}
CLIENT_ARTIFACT_ID: ${{ inputs.client_artifact_id }}
CLIENT_MANIFEST_SHA: ${{ inputs.client_manifest_sha }}
TEST_VERSION: ${{ inputs.test_version }}
run: |
if [ -n "$CLIENT_ARTIFACT_ID" ]; then
python .github/scripts/python_release.py verify --component client --dist client-dist \
--sha "$SOURCE_SHA" --version "$CLIENT_VERSION" --manifest-sha "$CLIENT_MANIFEST_SHA" \
--source-repository "$SOURCE_REPOSITORY"
echo "client_requirement=$(realpath client-dist/*.whl)" >> "$GITHUB_OUTPUT"
echo "Pre-publish pair: using this run's tested client artifact, not a registry release."
elif [ "$TARGET" = testpypi ]; then
python .github/scripts/python_release.py test-client --version "$TEST_VERSION"
elif [ -n "$CLIENT_VERSION" ]; then
echo "client_requirement=hugegraph-python==$CLIENT_VERSION" >> "$GITHUB_OUTPUT"
fi
- name: Isolated MCP wheel, sdist and uvx smoke
if: inputs.component == 'mcp'
env:
VERSION: ${{ steps.metadata.outputs.version }}
CLIENT_REQUIREMENT: ${{ steps.client.outputs.client_requirement }}
SOURCE_DIR: ${{ github.workspace }}/source
DIST_DIR: ${{ github.workspace }}/dist
run: bash .github/scripts/check_mcp_distribution.sh
- name: Verify artifacts unchanged after tests
env:
SOURCE_SHA: ${{ inputs.source_sha }}
VERSION: ${{ steps.metadata.outputs.version }}
MANIFEST_SHA: ${{ steps.manifest.outputs.manifest_sha }}
run: python .github/scripts/python_release.py verify --sha "$SOURCE_SHA" --version "$VERSION" --component "$COMPONENT" --source-repository "$SOURCE_REPOSITORY" --manifest-sha "$MANIFEST_SHA"
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
id: upload
with:
name: python-release-${{ inputs.component }}-${{ github.run_id }}-${{ github.run_attempt }}
path: dist/
if-no-files-found: error
retention-days: 14