Skip to content

Commit 433422a

Browse files
committed
squashed commits
more squashed commits
1 parent 1196599 commit 433422a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+9376
-16061
lines changed

.github/actions/python/cache-uv/action.yaml

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: 'UV Python Setup'
2+
description: 'Set up the environment for a UV-managed Python project'
3+
inputs:
4+
project:
5+
description: 'Which project (by subdirectory) to set up'
6+
required: true
7+
python-version:
8+
description: 'Python version to install via setup-uv'
9+
required: false
10+
default: '3.10'
11+
install-system-deps:
12+
description: 'Whether to install system dependencies (libsystemd-dev on Linux)'
13+
required: false
14+
default: 'true'
15+
runs:
16+
using: 'composite'
17+
steps:
18+
- shell: bash
19+
if: inputs.install-system-deps == 'true'
20+
run: |
21+
if [[ "${OSTYPE}" =~ "linux" ]]; then
22+
# WORKAROUND: Remove microsoft debian repo due to https://github.com/microsoft/linux-package-repositories/issues/130. Remove line below after it is resolved
23+
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
24+
sudo apt-get update
25+
sudo apt-get install -y --no-install-recommends libsystemd-dev
26+
fi
27+
- shell: bash
28+
run: npm install --global [email protected]
29+
- name: Setup Python and UV
30+
uses: astral-sh/setup-uv@v7
31+
with:
32+
python-version: ${{ inputs.python-version }}
33+
enable-cache: true
34+
cache-dependency-glob: |
35+
${{ inputs.project }}/pyproject.toml
36+
${{ inputs.project }}/uv.lock
37+
- name: Setup Python Environment
38+
id: setup-env
39+
shell: bash
40+
run: make -C ${{ inputs.project }} setup

.github/actions/python/setup/action.yaml

Lines changed: 6 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,10 @@ inputs:
44
project:
55
description: 'Which project (by subdirectory) to set up'
66
required: true
7-
python-version:
8-
description: "What Python version to use to create the project's virtual environment"
9-
required: false
10-
default: "false"
117
install-system-deps:
128
description: 'Whether to install system dependencies (libsystemd-dev on Linux)'
139
required: false
1410
default: 'true'
15-
install-dev-deps:
16-
description: 'Whether to install dev optional dependencies (UV projects only: --extra dev)'
17-
required: false
18-
default: 'true'
19-
outputs:
20-
start-time:
21-
description: 'Start time of the setup process (Unix timestamp)'
22-
value: ${{ steps.setup-env.outputs.start-time }}
23-
duration:
24-
description: 'Duration of the setup process in seconds'
25-
value: ${{ steps.setup-env.outputs.duration }}
2611
runs:
2712
using: 'composite'
2813
steps:
@@ -40,70 +25,18 @@ runs:
4025
- name: Setup Python
4126
uses: actions/setup-python@v5
4227
with:
43-
python-version: ${{ inputs.python-version != 'false' && inputs.python-version || '3.10' }}
44-
- name: Check project type
45-
id: project-type
46-
shell: bash
47-
run: |
48-
# Only api and shared-data use UV for now
49-
if [ "${{ inputs.project }}" == "api" ] || [ "${{ inputs.project }}" == "shared-data" ]; then
50-
echo "type=uv" >> $GITHUB_OUTPUT
51-
elif [ -f "${{ inputs.project }}/Pipfile" ]; then
52-
echo "type=pipenv" >> $GITHUB_OUTPUT
53-
else
54-
echo "type=make" >> $GITHUB_OUTPUT
55-
fi
56-
- name: Install pipenv and virtualenv (original behavior - always installed)
57-
if: steps.project-type.outputs.type != 'uv'
28+
python-version: '3.10'
29+
- name: Install pipenv and virtualenv
5830
shell: bash
5931
run: |
6032
python -m pip install --upgrade pip
6133
python -m pip install --user pipenv==2023.12.1
6234
python -m pip install --user virtualenv==20.30.0
63-
- name: Install UV
64-
if: steps.project-type.outputs.type == 'uv'
65-
uses: astral-sh/setup-uv@v7
66-
- name: Cache UV packages
67-
if: steps.project-type.outputs.type == 'uv'
68-
uses: ./.github/actions/python/cache-uv
69-
with:
70-
lockfile-path: ${{ inputs.project }}/uv.lock
7135
- name: Setup Python Environment
7236
id: setup-env
7337
shell: bash
7438
run: |
75-
START_TIME=$(date +%s)
76-
echo "start-time=$START_TIME" >> $GITHUB_OUTPUT
77-
# Use the project type determined earlier
78-
PROJECT_TYPE="${{ steps.project-type.outputs.type }}"
79-
if [ "$PROJECT_TYPE" == "uv" ]; then
80-
echo "::notice::Using UV for dependency management"
81-
# Add dev extra if requested
82-
DEV_EXTRA=""
83-
if [ "${{ inputs.install-dev-deps }}" == "true" ]; then
84-
DEV_EXTRA="--extra dev"
85-
fi
86-
if [ -f "${{ inputs.project }}/uv.lock" ]; then
87-
# Use --frozen to ensure exact versions from lockfile
88-
cd ${{ inputs.project }} && uv sync --frozen $DEV_EXTRA
89-
# Verify dev dependencies are installed if dev extra was used
90-
if [ -n "$DEV_EXTRA" ]; then
91-
echo "::notice::Verifying dev dependencies are installed..."
92-
uv pip list | grep -E "(sphinx|mypy|pytest|black)" || echo "::warning::Some dev dependencies may not be installed"
93-
fi
94-
else
95-
cd ${{ inputs.project }} && uv sync $DEV_EXTRA
96-
# Verify dev dependencies are installed if dev extra was used
97-
if [ -n "$DEV_EXTRA" ]; then
98-
echo "::notice::Verifying dev dependencies are installed..."
99-
uv pip list | grep -E "(sphinx|mypy|pytest|black)" || echo "::warning::Some dev dependencies may not be installed"
100-
fi
101-
fi
102-
else
103-
# For pipenv or make projects, just call make setup
104-
make -C ${{ inputs.project }} setup
105-
fi
106-
END_TIME=$(date +%s)
107-
DURATION=$((END_TIME - START_TIME))
108-
echo "duration=$DURATION" >> $GITHUB_OUTPUT
109-
echo "::notice::Setup completed in ${DURATION} seconds"
39+
# For pipenv projects, make setup runs "pipenv sync --dev" which always installs dev dependencies
40+
# (see scripts/python.mk where pipenv_opts includes --dev)
41+
make -C ${{ inputs.project }} setup
42+
echo "::notice::Setup completed"

.github/workflows/api-test-lint-deploy.yaml

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,10 @@ jobs:
5858
- uses: 'actions/setup-node@v4'
5959
with:
6060
node-version: '22.12.0'
61-
- uses: 'actions/setup-python@v4'
62-
with:
63-
python-version: '3.10'
64-
65-
- uses: './.github/actions/python/setup'
61+
- uses: './.github/actions/python/setup-uv'
6662
with:
6763
project: 'api'
64+
python-version: '3.10'
6865
- name: Lint with opentrons_hardware
6966
run: make -C api lint
7067
test:
@@ -95,25 +92,19 @@ jobs:
9592
- uses: 'actions/setup-node@v4'
9693
with:
9794
node-version: '22.12.0'
98-
- uses: 'actions/setup-python@v4'
99-
with:
100-
python-version: ${{ matrix.python }}
10195
- name: 'set complex environment variables'
10296
uses: actions/github-script@v6
10397
with:
10498
script: |
10599
const { buildComplexEnvVars, } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
106100
buildComplexEnvVars(core, context)
107-
- uses: './.github/actions/python/setup'
101+
- uses: './.github/actions/python/setup-uv'
108102
with:
109103
project: 'api'
110104
python-version: ${{ matrix.python }}
111-
install-dev-deps: 'true'
112105
- if: ${{ matrix.with-ot-hardware == 'false' }}
113106
name: Remove OT-3 hardware package
114107
run: make -C api setup-ot2
115-
env:
116-
OT_VIRTUALENV_VERSION: ${{ matrix.python }}
117108
- if: ${{ matrix.with-ot-hardware == 'false' }}
118109
name: Test without opentrons_hardware
119110
run: make -C api test-ot2
@@ -142,27 +133,12 @@ jobs:
142133
run: |
143134
git fetch -f origin ${{ github.ref }}:${{ github.ref }}
144135
git checkout ${{ github.ref }}
145-
- name: Install UV
146-
uses: astral-sh/setup-uv@v7
147-
- uses: 'actions/setup-python@v4'
148-
with:
149-
python-version: '3.10'
150-
- name: Cache UV packages
151-
uses: ./.github/actions/python/cache-uv
152-
with:
153-
lockfile-path: package-testing/uv.lock
154136
- name: Set up package-testing
155137
id: setup
156-
if: ${{ matrix.os != 'windows-2022' }}
157-
working-directory: package-testing
158-
shell: bash
159-
run: make setup
160-
- name: Set up package-testing (Windows)
161-
id: setup-windows
162-
if: ${{ matrix.os == 'windows-2022' }}
163-
working-directory: package-testing
164-
shell: pwsh
165-
run: make setup-windows
138+
uses: './.github/actions/python/setup-uv'
139+
with:
140+
project: 'package-testing'
141+
python-version: '3.10'
166142
- name: Run the tests
167143
if: ${{ matrix.os != 'windows-2022' }}
168144
shell: bash
@@ -175,7 +151,7 @@ jobs:
175151
working-directory: package-testing
176152
run: make test-windows
177153
- name: Save the test results
178-
if: ${{ always() && steps.setup.outcome == 'success' || steps.setup-windows.outcome == 'success' }}
154+
if: ${{ always() && steps.setup.outcome == 'success' }}
179155
id: results
180156
uses: actions/upload-artifact@v4
181157
with:
@@ -209,19 +185,19 @@ jobs:
209185
- uses: 'actions/setup-node@v4'
210186
with:
211187
node-version: '22.12.0'
212-
- uses: 'actions/setup-python@v4'
213-
with:
214-
python-version: '3.10'
215188
- name: 'set complex environment variables'
216189
uses: actions/github-script@v6
217190
with:
218191
script: |
219192
const { buildComplexEnvVars, } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
220193
buildComplexEnvVars(core, context)
221-
- uses: './.github/actions/python/setup'
194+
- uses: './.github/actions/python/setup-uv'
222195
with:
223196
project: 'api'
224-
install-dev-deps: 'false'
197+
python-version: '3.10'
198+
- name: 'build api distributables'
199+
shell: bash
200+
run: make -C api sdist wheel
225201
# creds and repository configuration for deploying python wheels
226202
- if: ${{ !env.OT_TAG }}
227203
name: 'upload to test pypi'

.github/workflows/docs-build.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ jobs:
8383
- uses: 'actions/setup-node@v4'
8484
with:
8585
node-version: '22.12.0'
86-
- uses: 'actions/setup-python@v3'
87-
with:
88-
python-version: '3.10'
89-
- uses: './.github/actions/python/setup'
86+
- uses: './.github/actions/python/setup-uv'
9087
with:
9188
project: 'api'
9289
- name: 'Build docs'

.github/workflows/g-code-confirm-tests.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,9 @@ jobs:
4242
- uses: 'actions/setup-node@v4'
4343
with:
4444
node-version: '12'
45-
- uses: 'actions/setup-python@v3'
46-
with:
47-
python-version: '3.10'
48-
- uses: './.github/actions/python/setup'
45+
- uses: './.github/actions/python/setup-uv'
4946
with:
5047
project: 'g-code-testing'
51-
5248
- name: 'Verify no missing comparison files'
5349
run: make -C g-code-testing check-for-missing-comparison-files
5450

.github/workflows/g-code-testing-lint-test.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ jobs:
6060
script: |
6161
const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
6262
buildComplexEnvVars(core, context)
63-
- uses: 'actions/setup-python@v4'
64-
with:
65-
python-version: '3.10'
66-
- uses: './.github/actions/python/setup'
63+
- uses: './.github/actions/python/setup-uv'
6764
with:
6865
project: 'g-code-testing'
6966
- name: 'cache yarn cache'

.github/workflows/hardware-lint-test.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,8 @@ jobs:
5252
with:
5353
node-version: '12'
5454

55-
- name: Setup Python
56-
uses: 'actions/setup-python@v4'
57-
with:
58-
python-version: '3.10'
59-
6055
- name: Setup Hardware Project
61-
uses: './.github/actions/python/setup'
56+
uses: './.github/actions/python/setup-uv'
6257
with:
6358
project: 'hardware'
6459

0 commit comments

Comments
 (0)