Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ WORKDIR /app

# add a non-privileged user for installing and running the application
# We use --non-unique in case $groupid/$userid collide with the existing "vscode" user.
# useradd -g app --uid $userid --non-unique --shell /usr/sbin/nologin --create-home app && \
RUN groupadd --gid $groupid --non-unique app && \
useradd -g app --uid $userid --non-unique --shell /bin/bash --create-home app && \
chown app:app /app/
Expand All @@ -18,9 +17,15 @@ RUN groupadd --gid $groupid --non-unique app && \
RUN apt-get update && \
apt-get install -y ripgrep tig

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

USER app

COPY --chown=app:app . /app

# Install Python dependencies
COPY requirements.txt /app/
RUN pip install -U 'pip>=20' && \
pip install --no-cache-dir --no-deps --only-binary :all: -r requirements.txt && \
pip install --no-cache-dir ipython && \
pip check --disable-pip-version-check
RUN --mount=type=cache,uid=$userid,gid=$groupid,target=/home/app/.cache/uv \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync
ENV PATH="/app/.venv/bin:$PATH"
8 changes: 4 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
*.py[co]
*.sw[po]
.docker-build
Comment thread
smarnach marked this conversation as resolved.
.DS_Store
.env
.git/
.pytest_cache
.python-version
build
.venv/
build/
dist/
obs_common.egg-info/
venv/
.git
uv.lock

# Ignore generated credentials from google-github-actions/auth
gha-creds-*.json
12 changes: 0 additions & 12 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
---
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "monthly"
groups:
production-dependencies:
dependency-type: "production"
update-types: ["major", "minor", "patch"]
development-dependencies:
dependency-type: "development"
update-types: ["major", "minor", "patch"]

- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
33 changes: 13 additions & 20 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,17 @@ jobs:

steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m venv venv
venv/bin/pip install -r requirements.txt
venv/bin/pip install -e . --no-deps
- name: Verify requirements.txt
if: ${{ matrix.python-version == '3.11' }}
run: |
venv/bin/pip-compile --quiet --allow-unsafe --generate-hashes --strip-extras
git diff --exit-code -- requirements.txt
uv sync
- name: Run lint check
if: ${{ matrix.python-version == '3.11' }}
run: |
PATH="venv/bin:$PATH" bin/lint.sh
uv run bin/lint.sh
- name: Run tests
env:
SENTRY_DSN: http://public@localhost:8090/1
Expand All @@ -44,7 +37,7 @@ jobs:
run: |
docker compose up -d fakesentry gcs-emulator pubsub
# Run outside docker because we are testing the matrix python version
PATH="venv/bin:$PATH" bin/test.sh
uv run bin/test.sh
# stop services immediate and ignore errors
docker compose down -t0 || true

Expand All @@ -61,16 +54,15 @@ jobs:
- uses: actions/checkout@v6
- name: Fetch tags
run: git fetch --tags origin
- name: Set up Python
uses: actions/setup-python@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m venv venv
venv/bin/pip install -r requirements.txt
uv sync
- name: Generate release tag
run: echo RELEASE_TAG="$(venv/bin/python -c 'import obs_common.release; print(obs_common.release.generate_tag())')" >> "$GITHUB_ENV"
run: echo RELEASE_TAG="$(uv run python -c 'import obs_common.release; print(obs_common.release.generate_tag())')" >> "$GITHUB_ENV"
- name: Overrride wheel version
run: |
# Convert version number to PEP 440-conformant version that's treated correctly
Expand All @@ -81,9 +73,9 @@ jobs:
*-*) SUBVERSION=".${VERSION##*-}";;
*) SUBVERSION="";;
esac
echo SETUPTOOLS_SCM_PRETEND_VERSION_FOR_OBS_COMMON="$MAIN_VERSION$SUBVERSION" >> "$GITHUB_ENV"
uv version "$MAIN_VERSION$SUBVERSION"
- name: Build python wheel
run: venv/bin/python -m build
run: uv build --wheel
- name: Build docker images for publishing
run: |
docker compose build fakesentry gcs-emulator
Expand All @@ -108,7 +100,8 @@ jobs:
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: Publish python package
run:
venv/bin/twine upload --verbose --repository-url https://us-python.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/cavendish-prod-python/ dist/*.whl
uv tool install keyring --with keyrings.google-artifactregistry-auth
uv publish --index=cavendish --keyring-provider=subprocess --username=oauth2accesstoken
Comment thread
smarnach marked this conversation as resolved.
- name: Publish release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
*.py[co]
*.sw[po]
.docker-build
.DS_Store
.env
.pytest_cache
.python-version
build
.venv/
build/
dist/
obs_common.egg-info/
venv/
uv.lock
Comment thread
smarnach marked this conversation as resolved.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# obs-common

code and commands shared between obs-team repositories
Code and commands shared between Crash ingestion service repositories

## service-status

Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ services:
- pubsub
volumes:
- .:/app
- /app/.venv

devcontainer:
build:
Expand All @@ -32,6 +33,7 @@ services:
- pubsub
volumes:
- .:/app
- /app/.venv

# https://github.com/willkg/kent
fakesentry:
Expand Down
19 changes: 7 additions & 12 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This should be kept in sync with the python version used in .devcontainer/Dockerfile and
# docker/images/fakesentry/Dockerfile
FROM --platform=linux/amd64 python:3.11.14-slim-bookworm@sha256:65a93d69fa75478d554f4ad27c85c1e69fa184956261b4301ebaf6dbb0a3543d
FROM --platform=linux/amd64 ghcr.io/astral-sh/uv:python3.11-bookworm-slim@sha256:4f5d923c9dcea037f57bda425dd209f3ec643da2f0b74227f68d09dab0b3bb36

# Set up user and group
ARG groupid=10001
Expand All @@ -20,19 +20,14 @@ RUN apt-get update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Install Python dependencies
COPY --chown=app:app requirements.txt /app/

RUN pip install -U 'pip>=20' && \
pip install --no-cache-dir --no-deps --only-binary :all: -r requirements.txt && \
pip install --no-cache-dir ipython && \
pip check --disable-pip-version-check
USER app

COPY --chown=app:app . /app

ARG version=1.0
RUN SETUPTOOLS_SCM_PRETEND_VERSION_FOR_OBS_COMMON=${version} pip install -e . --no-deps

USER app
# Install Python dependencies
RUN --mount=type=cache,uid=$userid,gid=$groupid,target=/home/app/.cache/uv \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync
ENV PATH="/app/.venv/bin:$PATH"

CMD ["/bin/bash"]
6 changes: 3 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ shell *args:
devcontainer:
docker compose up --detach devcontainer

# Rebuild requirements.txt file after requirements.in changes.
rebuild-reqs *args:
docker compose run --rm --no-deps shell pip-compile --allow-unsafe --generate-hashes --strip-extras {{args}}
# Run uv inside the container
uv *args:
docker compose run --rm --no-deps shell uv {{args}}

# Lint code, or use --fix to reformat and apply auto-fixes for lint.
lint *args:
Expand Down
43 changes: 25 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[project]
name = "obs-common"
description = "code shared between obs-team repositories"
license = {file = "LICENSE"}
version = "1.0" # Will be overridden with the actual version in CI builds.
description = "code shared between Mozilla crash ingestion repositories"
license = "MPL-2.0"
license-files = ["LICENSE"]
readme = "README.md"
requires-python = ">=3.11"
classifiers = [
Expand All @@ -11,13 +13,19 @@ classifiers = [
"Programming Language :: Python :: 3.14",
]
dependencies = [
"click",
"google-cloud-pubsub",
"google-cloud-storage",
"requests",
"sentry-sdk",
"click",
"google-cloud-pubsub",
"google-cloud-storage",
"sentry-sdk",
]

[dependency-groups]
dev = [
"ipython",
"pytest",
"requests",
"ruff"
]
dynamic = ["version"]

[project.scripts]
license-check = "obs_common.license_check:main"
Expand All @@ -28,18 +36,17 @@ sentry-wrap = "obs_common.sentry_wrap:cli_main"
waitfor = "obs_common.waitfor:main"

[build-system]
requires = ["setuptools", "setuptools_scm[toml]>=8.0"]
build-backend = "setuptools.build_meta"

[tool.distutils.bdist_wheel]
universal = true

[tool.setuptools]
packages = ["obs_common"]
requires = ["uv_build"]
build-backend = "uv_build"

[tool.setuptools_scm]
# Empty is fine
[tool.uv.build-backend]
module-name = "obs_common"
module-root = ""

[[tool.uv.index]]
name = "cavendish"
url = "https://us-python.pkg.dev/moz-fx-cavendish-prod/cavendish-prod-python/simple/"
publish-url = "https://us-python.pkg.dev/moz-fx-cavendish-prod/cavendish-prod-python/"

[tool.ruff]
line-length = 88
Expand Down
10 changes: 0 additions & 10 deletions requirements.in

This file was deleted.

Loading