Skip to content

Commit

Permalink
Merge pull request #24 from a5chin/feature/actions
Browse files Browse the repository at this point in the history
Update GitHub Actions for Setup Python with Rye
  • Loading branch information
a5chin authored Jul 1, 2024
2 parents 6054680 + 689cfe8 commit 7759954
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 33 deletions.
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 /

0 comments on commit 7759954

Please sign in to comment.