Skip to content

Commit b1182a9

Browse files
committed
squashed commits
more squashed commits
1 parent 46e1bf9 commit b1182a9

Some content is hidden

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

67 files changed

+9187
-16288
lines changed
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: 9 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +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"
7+
install-system-deps:
8+
description: 'Whether to install system dependencies (libsystemd-dev on Linux)'
99
required: false
10-
default: "false"
10+
default: 'true'
1111
runs:
1212
using: 'composite'
1313
steps:
@@ -31,70 +31,18 @@ runs:
3131
- name: Setup Python
3232
uses: actions/setup-python@v5
3333
with:
34-
python-version: ${{ inputs.python-version != 'false' && inputs.python-version || '3.10' }}
35-
- name: Check project type
36-
id: project-type
37-
shell: bash
38-
run: |
39-
# Only api and shared-data use UV for now
40-
if [ "${{ inputs.project }}" == "api" ] || [ "${{ inputs.project }}" == "shared-data" ]; then
41-
echo "type=uv" >> $GITHUB_OUTPUT
42-
elif [ -f "${{ inputs.project }}/Pipfile" ]; then
43-
echo "type=pipenv" >> $GITHUB_OUTPUT
44-
else
45-
echo "type=make" >> $GITHUB_OUTPUT
46-
fi
47-
- name: Install pipenv and virtualenv (original behavior - always installed)
48-
if: steps.project-type.outputs.type != 'uv'
34+
python-version: '3.10'
35+
- name: Install pipenv and virtualenv
4936
shell: bash
5037
run: |
5138
python -m pip install --upgrade pip
5239
python -m pip install --user pipenv==2023.12.1
5340
python -m pip install --user virtualenv==20.30.0
54-
- name: Install UV
55-
if: steps.project-type.outputs.type == 'uv'
56-
uses: astral-sh/setup-uv@v7
57-
- name: Cache UV packages
58-
if: steps.project-type.outputs.type == 'uv'
59-
uses: ./.github/actions/python/cache-uv
60-
with:
61-
lockfile-path: ${{ inputs.project }}/uv.lock
6241
- name: Setup Python Environment
6342
id: setup-env
6443
shell: bash
6544
run: |
66-
START_TIME=$(date +%s)
67-
echo "start-time=$START_TIME" >> $GITHUB_OUTPUT
68-
# Use the project type determined earlier
69-
PROJECT_TYPE="${{ steps.project-type.outputs.type }}"
70-
if [ "$PROJECT_TYPE" == "uv" ]; then
71-
echo "::notice::Using UV for dependency management"
72-
# Add dev extra if requested
73-
DEV_EXTRA=""
74-
if [ "${{ inputs.install-dev-deps }}" == "true" ]; then
75-
DEV_EXTRA="--extra dev"
76-
fi
77-
if [ -f "${{ inputs.project }}/uv.lock" ]; then
78-
# Use --frozen to ensure exact versions from lockfile
79-
cd ${{ inputs.project }} && uv sync --frozen $DEV_EXTRA
80-
# Verify dev dependencies are installed if dev extra was used
81-
if [ -n "$DEV_EXTRA" ]; then
82-
echo "::notice::Verifying dev dependencies are installed..."
83-
uv pip list | grep -E "(sphinx|mypy|pytest|black)" || echo "::warning::Some dev dependencies may not be installed"
84-
fi
85-
else
86-
cd ${{ inputs.project }} && uv sync $DEV_EXTRA
87-
# Verify dev dependencies are installed if dev extra was used
88-
if [ -n "$DEV_EXTRA" ]; then
89-
echo "::notice::Verifying dev dependencies are installed..."
90-
uv pip list | grep -E "(sphinx|mypy|pytest|black)" || echo "::warning::Some dev dependencies may not be installed"
91-
fi
92-
fi
93-
else
94-
# For pipenv or make projects, just call make setup
95-
make -C ${{ inputs.project }} setup
96-
fi
97-
END_TIME=$(date +%s)
98-
DURATION=$((END_TIME - START_TIME))
99-
echo "duration=$DURATION" >> $GITHUB_OUTPUT
100-
echo "::notice::Setup completed in ${DURATION} seconds"
45+
# For pipenv projects, make setup runs "pipenv sync --dev" which always installs dev dependencies
46+
# (see scripts/python.mk where pipenv_opts includes --dev)
47+
make -C ${{ inputs.project }} setup
48+
echo "::notice::Setup completed"

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

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,10 @@ jobs:
5858
- uses: 'actions/setup-node@v6'
5959
with:
6060
node-version: '22.12.0'
61-
- uses: 'actions/setup-python@v4'
62-
with:
63-
python-version: '3.12'
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,24 +92,19 @@ jobs:
9592
- uses: 'actions/setup-node@v6'
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 }}
111105
- if: ${{ matrix.with-ot-hardware == 'false' }}
112106
name: Remove OT-3 hardware package
113107
run: make -C api setup-ot2
114-
env:
115-
OT_VIRTUALENV_VERSION: ${{ matrix.python }}
116108
- if: ${{ matrix.with-ot-hardware == 'false' }}
117109
name: Test without opentrons_hardware
118110
run: make -C api test-ot2
@@ -147,23 +139,12 @@ jobs:
147139
run: |
148140
git fetch -f origin ${{ github.ref }}:${{ github.ref }}
149141
git checkout ${{ github.ref }}
150-
- name: Install UV
151-
uses: astral-sh/setup-uv@v7
152-
- uses: 'actions/setup-python@v4'
153-
with:
154-
python-version: ${{matrix.python}}
155142
- name: Set up package-testing
156143
id: setup
157-
if: ${{ matrix.os != 'windows-2022' }}
158-
working-directory: package-testing
159-
shell: bash
160-
run: make setup
161-
- name: Set up package-testing (Windows)
162-
id: setup-windows
163-
if: ${{ matrix.os == 'windows-2022' }}
164-
working-directory: package-testing
165-
shell: pwsh
166-
run: make setup-windows
144+
uses: './.github/actions/python/setup-uv'
145+
with:
146+
project: 'package-testing'
147+
python-version: '3.10'
167148
- name: Run the tests
168149
if: ${{ matrix.os != 'windows-2022' }}
169150
shell: bash
@@ -176,7 +157,7 @@ jobs:
176157
working-directory: package-testing
177158
run: make test-windows
178159
- name: Save the test results
179-
if: ${{ always() && steps.setup.outcome == 'success' || steps.setup-windows.outcome == 'success' }}
160+
if: ${{ always() && steps.setup.outcome == 'success' }}
180161
id: results
181162
uses: actions/upload-artifact@v4
182163
with:
@@ -210,22 +191,19 @@ jobs:
210191
- uses: 'actions/setup-node@v6'
211192
with:
212193
node-version: '22.12.0'
213-
- uses: 'actions/setup-python@v4'
214-
with:
215-
python-version: '3.12'
216194
- name: 'set complex environment variables'
217195
uses: actions/github-script@v6
218196
with:
219197
script: |
220198
const { buildComplexEnvVars, } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
221199
buildComplexEnvVars(core, context)
222-
- uses: './.github/actions/python/setup'
200+
- uses: './.github/actions/python/setup-uv'
223201
with:
224202
project: 'api'
203+
python-version: '3.10'
225204
- name: 'build api distributables'
226205
shell: bash
227206
run: make -C api sdist wheel
228-
229207
# creds and repository configuration for deploying python wheels
230208
- if: ${{ !env.OT_TAG }}
231209
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@v6'
8484
with:
8585
node-version: '22.12.0'
86-
- uses: 'actions/setup-python@v3'
87-
with:
88-
python-version: '3.12'
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@v6'
4343
with:
4444
node-version: '12'
45-
- uses: 'actions/setup-python@v3'
46-
with:
47-
python-version: '3.12'
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.12'
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.12'
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

.github/workflows/http-docs-build.yaml

Lines changed: 0 additions & 79 deletions
This file was deleted.

.github/workflows/robot-server-lint-test.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,7 @@ jobs:
6262
- uses: 'actions/setup-node@v6'
6363
with:
6464
node-version: '22.12.0'
65-
- uses: 'actions/setup-python@v4'
66-
with:
67-
python-version: '3.12'
68-
69-
- uses: './.github/actions/python/setup'
65+
- uses: './.github/actions/python/setup-uv'
7066
with:
7167
project: 'robot-server'
7268
- if: ${{ matrix.with-ot-hardware == 'false' }}

0 commit comments

Comments
 (0)