Skip to content

Update GitHub Actions for Setup Python with Rye #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 1, 2024
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
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:bookworm-slim as builder
FROM debian:bookworm-slim AS builder

WORKDIR /opt

Expand Down Expand Up @@ -26,7 +26,7 @@ COPY --from=builder /opt/rye /opt/rye

ENV RYE_HOME="/opt/rye"
ENV PATH="$RYE_HOME/shims:$PATH"
ENV PYTHONUNBUFFERED True
ENV PYTHONUNBUFFERED=True

RUN rye config --set-bool behavior.global-python=true && \
rye config --set-bool behavior.use-uv=true
Expand Down
35 changes: 35 additions & 0 deletions .github/actions/setup-python-with-rye/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Install Python with Rye

inputs:
python-version:
description: Python version
required: true
rye-version:
description: Rye version
required: false
default: "latest"

runs:
using: composite
steps:
- name: Install Rye
uses: eifinger/setup-rye@v3
with:
enable-cache: true
version: ${{ inputs.rye-version }}

- name: Set Rye Config
run: |
rye config --set-bool behavior.global-python=true
rye config --set-bool behavior.use-uv=true
shell: bash

- name: Set up Python ${{ inputs.python-version }}
run: |
export PYTHONUNBUFFERED=True
rye pin ${{ inputs.python-version }}
shell: bash

- name: Install Dependencies
run: rye sync
shell: bash
34 changes: 6 additions & 28 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install Rye
uses: eifinger/setup-rye@v3
- name: Setup Python ${{ matrix.python-version }} with Rye
uses: ./.github/actions/setup-python-with-rye
with:
enable-cache: true

- name: Set Rye Config
run: |
rye config --set-bool behavior.global-python=true
rye config --set-bool behavior.use-uv=true

- name: Set up Python ${{ matrix.python-version }}
run: |
export PYTHONUNBUFFERED=1
rye pin ${{ matrix.python-version }}
rye sync
python-version: ${{ matrix.python-version }}

- name: Lint
run: rye run ruff check --output-format=github .
Expand All @@ -48,21 +37,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install Rye
uses: eifinger/setup-rye@v3
- name: Setup Python ${{ matrix.python-version }} with Rye
uses: ./.github/actions/setup-python-with-rye
with:
enable-cache: true

- name: Set Rye Config
run: |
rye config --set-bool behavior.global-python=true
rye config --set-bool behavior.use-uv=true

- name: Set up Python ${{ matrix.python-version }}
run: |
export PYTHONUNBUFFERED=1
rye pin ${{ matrix.python-version }}
rye sync
python-version: ${{ matrix.python-version }}

- name: Format
run: rye run ruff format . --check --diff
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG VARIANT=3.12
FROM python:${VARIANT} as builder
FROM python:${VARIANT} AS builder

ENV PYTHONDONTWRITEBYTECODE True
ENV PYTHONDONTWRITEBYTECODE=True

WORKDIR /opt
COPY pyproject.toml requirements.lock ./
Expand All @@ -14,6 +14,6 @@ RUN pip install --upgrade pip && \
FROM python:${VARIANT}-slim
COPY --from=builder /usr/local/lib/python*/site-packages /usr/local/lib/python*/site-packages

ENV PYTHONUNBUFFERED True
ENV PYTHONUNBUFFERED=True

WORKDIR /