Skip to content

Commit 53f50f8

Browse files
authored
Merge pull request #221 from UW-Macrostrat/uv
Migrate package management to uv
2 parents f2cf109 + 7b2c6bf commit 53f50f8

Some content is hidden

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

64 files changed

+16293
-24079
lines changed

.github/workflows/build-api-dev.yaml

Lines changed: 0 additions & 50 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: Build Production
2-
1+
name: API v3 build
32
on:
43
push:
54
branches:
65
- main
76
tags:
8-
- v[0-9]+.[0-9]+.[0-9]+ # Semver Release
7+
- api-v3-v[0-9]+.[0-9]+.[0-9]+ # Semver Release
8+
- api-v3-v[0-9]+.[0-9]+.[0-9]+-** # Semver Pre-Release
99
paths:
1010
- services/api-v3/**
1111

@@ -17,6 +17,11 @@ jobs:
1717
uses: actions/checkout@v3
1818
with:
1919
submodules: 'recursive'
20+
- name: Get the version from the tag, if it exists
21+
run: |
22+
TAG=${{ github.ref_name }}
23+
VERSION=$(echo "${TAG}" | sed -E 's/tileserver-v//')
24+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
2025
- name: Docker meta
2126
id: meta
2227
uses: docker/metadata-action@v4
@@ -25,17 +30,10 @@ jobs:
2530
tags: |
2631
type=ref,event=pr,suffix=-{{date 'YYYYMMDDHHmmss'}}
2732
type=ref,event=branch,suffix=-{{date 'YYYYMMDDHHmmss'}}
28-
type=semver,pattern={{version}}
2933
type=raw,value=latest,enable={{is_default_branch}}
34+
type=raw,value=main-{{date 'YYYYMMDDHHmmss'}},enable={{is_default_branch}}
3035
type=raw,value=sha-{{sha}}
31-
32-
# When a PRODUCTION tag (vX.Y.Z) is pushed → also tag staging and dev
33-
type=raw,value=main-{{date 'YYYYMMDDHHmmss'}},enable=${{ startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') }}
34-
type=semver,pattern={{version}},suffix=-beta.{{date 'YYYYMMDDHHmmss'}},enable=${{ startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') }}
35-
type=semver,pattern={{version}},suffix=-beta,enable=${{ startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') }}
36-
37-
# When a STAGING prerelease tag (vX.Y.Z-*) is pushed → also tag dev
38-
type=raw,value=main-{{date 'YYYYMMDDHHmmss'}},enable=${{ startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '-') }}
36+
type=raw,value=${{ env.VERSION }},enable=${{ env.VERSION != '' }}
3937
- name: Set up Docker Buildx
4038
uses: docker/setup-buildx-action@v2
4139
- name: Login to OSG DockerHub
@@ -48,8 +46,21 @@ jobs:
4846
uses: docker/build-push-action@v5
4947
with:
5048
context: services/api-v3
49+
build-contexts: |
50+
py-modules=./py-modules
5151
push: true
5252
tags: ${{ steps.meta.outputs.tags }}
5353
labels: ${{ steps.meta.outputs.labels }}
5454
cache-from: type=gha
5555
cache-to: type=gha,mode=max
56+
# Add a link to the built artifact to the workflow summary
57+
- name: Add link to workflow summary
58+
run: |
59+
echo "## Docker Image Built" >> $GITHUB_STEP_SUMMARY
60+
echo "" >> $GITHUB_STEP_SUMMARY
61+
echo "The Docker image has been built and pushed to [OSG Harbor](https://hub.opensciencegrid.org/harbor/projects/887/repositories/api-v3/artifacts-tab/artifacts/sha256:${{ github.sha }})" >> $GITHUB_STEP_SUMMARY
62+
echo "" >> $GITHUB_STEP_SUMMARY
63+
echo "### Tags:" >> $GITHUB_STEP_SUMMARY
64+
for tag in ${{ steps.meta.outputs.tags }}; do
65+
echo "- \`$tag\`" >> $GITHUB_STEP_SUMMARY
66+
done

.github/workflows/build-legacy-tileserver.yaml

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,31 @@ on:
55
branches: ["main"]
66
paths:
77
- services/legacy-tileserver/**
8+
- py-modules/tileserver-utils/**
89
tags:
910
- legacy-tileserver-v[0-9]+.[0-9]+.[0-9]+ # Semver Release (non-prerelease)
1011
- legacy-tileserver-v[0-9]+.[0-9]+.[0-9]+-** # Semver release (prerelease)
1112
pull_request:
1213
branches: [main]
1314
paths:
1415
- services/legacy-tileserver/**
16+
- py-modules/tileserver-utils/**
1517
jobs:
1618
docker:
1719
runs-on: ubuntu-latest
1820
steps:
1921
- name: Checkout
20-
uses: actions/checkout@v4
22+
uses: actions/checkout@v5
2123
with:
2224
submodules: "recursive"
2325
# Set up python and poetry
24-
- name: Set up Python
25-
uses: actions/setup-python@v4
26-
with:
27-
python-version: 3.11
28-
- name: Install Poetry
29-
run: python3 -m pip install poetry==2.1.1
30-
- name: Build and stage local packages
31-
run: scripts/prepare-services
3226
- name: Get the version from the tag, if it exists
3327
run: |
3428
TAG=${{ github.ref_name }}
3529
VERSION=$(echo "${TAG}" | sed -E 's/legacy-tileserver-v//')
3630
echo "VERSION=${VERSION}" >> $GITHUB_ENV
37-
- name: Docker meta
31+
32+
- name: Docker metadata
3833
id: meta
3934
uses: docker/metadata-action@v4
4035
with:
@@ -44,16 +39,8 @@ jobs:
4439
type=ref,event=pr,suffix=-{{date 'YYYYMMDDHHmmss'}}
4540
type=ref,event=branch,suffix=-{{date 'YYYYMMDDHHmmss'}}
4641
type=raw,value=latest,enable={{is_default_branch}}
42+
type=raw,value=main-{{date 'YYYYMMDDHHmmss'}},enable={{is_default_branch}}
4743
type=raw,value=sha-{{sha}}
48-
49-
50-
# When a PRODUCTION tag (legacy-tileserver-vX.Y.Z) → also tag staging and dev
51-
type=raw,value=main-{{date 'YYYYMMDDHHmmss'}},enable=${{ startsWith(github.ref, 'refs/tags/legacy-tileserver-v') && !contains(env.VERSION, '-') }}
52-
type=raw,value=${{ env.VERSION }}-beta.{{date 'YYYYMMDDHHmmss'}},enable=${{ startsWith(github.ref, 'refs/tags/legacy-tileserver-v') && !contains(env.VERSION, '-') }}
53-
type=raw,value=${{ env.VERSION }}-beta,enable=${{ startsWith(github.ref, 'refs/tags/legacy-tileserver-v') && !contains(env.VERSION, '-') }}
54-
55-
# When a STAGING prerelease tag (legacy-tileserver-vX.Y.Z-*) → also tag dev
56-
type=raw,value=main-{{date 'YYYYMMDDHHmmss'}},enable=${{ startsWith(github.ref, 'refs/tags/legacy-tileserver-v') && contains(env.VERSION, '-') }}
5744
5845
- name: Set up Docker BuildX
5946
uses: docker/setup-buildx-action@v2
@@ -67,6 +54,8 @@ jobs:
6754
uses: docker/build-push-action@v5
6855
with:
6956
context: services/legacy-tileserver
57+
build-contexts: |
58+
py-modules=./py-modules
7059
push: true
7160
tags: ${{ steps.meta.outputs.tags }}
7261
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/build-tileserver.yaml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,24 @@ on:
55
branches: ["main"]
66
paths:
77
- services/tileserver/**
8+
- py-modules/tileserver-utils/**
89
tags:
910
- tileserver-v[0-9]+.[0-9]+.[0-9]+ # Semver Release (non-prerelease)
1011
- tileserver-v[0-9]+.[0-9]+.[0-9]+-** # Semver release (prerelease)
1112
pull_request:
1213
branches: [main]
1314
paths:
1415
- services/tileserver/**
16+
- py-modules/tileserver-utils/**
1517
jobs:
1618
docker:
1719
runs-on: ubuntu-latest
1820
steps:
1921
- name: Checkout
20-
uses: actions/checkout@v4
22+
uses: actions/checkout@v5
2123
with:
2224
submodules: "recursive"
23-
# Set up python and poetry
24-
- name: Set up Python
25-
uses: actions/setup-python@v4
26-
with:
27-
python-version: 3.11
28-
- name: Install Poetry
29-
run: python3 -m pip install poetry==2.1.1
30-
- name: Build and stage local packages
31-
run: scripts/prepare-services
25+
3226
- name: Get the version from the tag, if it exists
3327
run: |
3428
TAG=${{ github.ref_name }}
@@ -45,15 +39,15 @@ jobs:
4539
type=raw,value=${{ env.VERSION }},enable=${{ env.VERSION != '' }}
4640
type=raw,value=latest,enable={{is_default_branch}}
4741
type=raw,value=sha-{{sha}}
48-
42+
4943
# When a PRODUCTION tag (tileserver-vX.Y.Z) → also tag staging and dev
5044
type=raw,value=main-{{date 'YYYYMMDDHHmmss'}},enable=${{ startsWith(github.ref, 'refs/tags/tileserver-v') && !contains(env.VERSION, '-') }}
5145
type=raw,value=${{ env.VERSION }}-beta.{{date 'YYYYMMDDHHmmss'}},enable=${{ startsWith(github.ref, 'refs/tags/tileserver-v') && !contains(env.VERSION, '-') }}
5246
type=raw,value=${{ env.VERSION }}-beta,enable=${{ startsWith(github.ref, 'refs/tags/tileserver-v') && !contains(env.VERSION, '-') }}
53-
47+
5448
# When a STAGING prerelease tag (tileserver-vX.Y.Z-*) → also tag dev
5549
type=raw,value=main-{{date 'YYYYMMDDHHmmss'}},enable=${{ startsWith(github.ref, 'refs/tags/tileserver-v') && contains(env.VERSION, '-') }}
56-
50+
5751
5852
- name: Set up Docker BuildX
5953
uses: docker/setup-buildx-action@v2
@@ -67,6 +61,8 @@ jobs:
6761
uses: docker/build-push-action@v5
6862
with:
6963
context: services/tileserver
64+
build-contexts: |
65+
py-modules=./py-modules
7066
push: true
7167
tags: ${{ steps.meta.outputs.tags }}
7268
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/format-code.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
name: Format code and sort imports
22
on:
33
pull_request:
4-
branches: [main]
4+
branches: [ main ]
55
push:
6-
branches: [main]
6+
branches: [ main ]
77
jobs:
88
format:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v4
11+
- uses: actions/checkout@v5
1212
with:
13-
ref: ${{ github.head_ref }}
14-
- uses: actions/[email protected]
13+
submodules: recursive
14+
15+
- name: "Set up Python"
16+
uses: actions/setup-python@v6
1517
with:
16-
python-version: '^3.11'
17-
- uses: actions/cache@v4
18+
python-version-file: "pyproject.toml"
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v6
1822
with:
19-
path: |
20-
~/.cache/pypoetry
21-
~/.virtualenvs
22-
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
23-
restore-keys: |
24-
${{ runner.os }}-poetry-
25-
- name: Install Poetry
26-
run: curl -sSL https://install.python-poetry.org | python3 -
23+
enable-cache: true
24+
2725
- name: Install dependencies
28-
run: poetry install --only dev
26+
run: uv sync --only-dev
27+
2928
- name: Run formatting commands
3029
run: make format
30+
3131
- name: Commit changes
3232
uses: stefanzweifel/git-auto-commit-action@v5
3333
with:

.github/workflows/run-tests.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,21 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14+
1415
- name: Checkout code
15-
uses: actions/checkout@v4
16+
uses: actions/checkout@v5
1617
with:
1718
submodules: recursive
1819

19-
- name: Set up Python and Poetry
20-
uses: abatilo/actions-poetry@v2
20+
- name: "Set up Python"
21+
uses: actions/setup-python@v6
22+
with:
23+
python-version-file: "pyproject.toml"
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v6
2127
with:
22-
poetry-version: "1.8.2"
28+
enable-cache: true
2329

2430
- name: Install system dependencies (GDAL)
2531
run: |

.idea/data_source_mapping.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
all:
2-
poetry lock
3-
poetry install --with=dev,gis
4-
# This breaks on fresh installs, not sure
5-
#./bin/macrostrat poetry run mono install
6-
# Install the version of the GDAL bindings that matches the native lib.
7-
# This is breakable and should be replaced with a more robust solution.
8-
poetry run pip install GDAL==$(shell gdal-config --version | sed 's/\([0-9]*\)\.\([0-9]*\).*/\1.\2/')
2+
# Install all dependencies
3+
# Install all optional dependency groups (dev, gis, etc)
4+
uv sync
5+
6+
gis:
7+
# Install GIS dependencies
8+
uv pip install "GDAL==$(shell gdal-config --version)"
9+
uv sync --group gis
910

1011
install:
1112
ln -sf $(shell pwd)/bin/macrostrat /usr/local/bin/macrostrat
1213

1314
format:
14-
poetry run black .
15-
poetry run isort .
15+
uv run black .
16+
uv run isort .
1617

1718
test:
1819
# These tests may fail due to an older GDAL version in use.
1920
# We need to figure out how to bundle GDAL or run in a Docker context
20-
poetry run macrostrat test all --skip-env -x -s
21-
# poetry run pytest -s -x \
22-
# --ignore=runtime-tests \
23-
# --ignore=services \
24-
# --ignore=v2-transition \
25-
# --ignore=submodules \
26-
# --skip-env \
27-
# .
21+
uv run macrostrat test all --skip-env -x -s
2822

2923
test-ci:
3024
# We need a fairly recent version of GDAL (3.10) for map integration tests to pass.
3125
# For now, we avoid running these tests in CI.
32-
poetry run macrostrat test all --skip-env -x -s -m "not requires_gdal"
26+
uv run macrostrat test all --skip-env -x -s -m "not requires_gdal"
3327

3428
test-warnings:
35-
poetry run pytest cli/tests -W error
29+
uv run pytest cli/tests -W error
30+
31+
reset:
32+
# Remove all virtual environments in subdirectories and re-create the main one
33+
find . -name ".venv" -type d -exec rm -rf {} +
34+
make all

0 commit comments

Comments
 (0)