From dcf9cc34db31eb42a1a51634d8462631455397cf Mon Sep 17 00:00:00 2001 From: d-eigo-hara Date: Thu, 27 Jun 2024 11:52:36 +0000 Subject: [PATCH 1/3] add: action for Setup Python with Rye --- .../actions/setup-python-with-rye/action.yml | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/actions/setup-python-with-rye/action.yml diff --git a/.github/actions/setup-python-with-rye/action.yml b/.github/actions/setup-python-with-rye/action.yml new file mode 100644 index 0000000..944dad1 --- /dev/null +++ b/.github/actions/setup-python-with-rye/action.yml @@ -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=1 + rye pin ${{ inputs.python-version }} + shell: bash + + - name: Install Dependencies + run: rye sync + shell: bash From 57a39a2a4b43a85c239812baa7621c45e7f50e31 Mon Sep 17 00:00:00 2001 From: d-eigo-hara Date: Thu, 27 Jun 2024 11:53:41 +0000 Subject: [PATCH 2/3] fix: setup-pythnon --- .github/workflows/ruff.yml | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index b37463c..316e66e 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -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 . @@ -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 From 689cfe8d0429ed96ed1741f68376ab0c9a827205 Mon Sep 17 00:00:00 2001 From: d-eigo-hara Date: Thu, 27 Jun 2024 12:07:11 +0000 Subject: [PATCH 3/3] fix: warning for Dockerfile --- .devcontainer/Dockerfile | 4 ++-- .github/actions/setup-python-with-rye/action.yml | 2 +- Dockerfile | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a58d761..ec88441 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:bookworm-slim as builder +FROM debian:bookworm-slim AS builder WORKDIR /opt @@ -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 diff --git a/.github/actions/setup-python-with-rye/action.yml b/.github/actions/setup-python-with-rye/action.yml index 944dad1..840d338 100644 --- a/.github/actions/setup-python-with-rye/action.yml +++ b/.github/actions/setup-python-with-rye/action.yml @@ -26,7 +26,7 @@ runs: - name: Set up Python ${{ inputs.python-version }} run: | - export PYTHONUNBUFFERED=1 + export PYTHONUNBUFFERED=True rye pin ${{ inputs.python-version }} shell: bash diff --git a/Dockerfile b/Dockerfile index 47c4c75..a548c22 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 ./ @@ -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 /