Skip to content

Commit

Permalink
Merge pull request #4567 from dev-hato/use_uv_2
Browse files Browse the repository at this point in the history
pipenvからuvへの移行
  • Loading branch information
massongit authored Dec 15, 2024
2 parents 21e50e6 + 9f1600e commit 25fa23e
Show file tree
Hide file tree
Showing 28 changed files with 1,919 additions and 3,018 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ __pycache__/
.mypy_cache/
node_modules/
docker-compose.yml
.venv/
14 changes: 7 additions & 7 deletions .github/workflows/deploy-hato-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ jobs:
env:
DOCKER_CONTENT_TRUST: 1
run: docker compose up -d --wait
# .python-version をDockerイメージと同期させる
update-version-python-version:
# pyproject.toml をDockerイメージと同期させる
update-version-pyproject:
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -125,8 +125,8 @@ jobs:
- uses: dev-hato/actions-diff-pr-management@8d475e5bc78f61c40024d4859b79134b66f788d2 # v1.2.1
with:
github-token: ${{secrets.GITHUB_TOKEN}}
branch-name-prefix: fix-version-python-version
pr-title-prefix: .python-versionを直してあげたよ
branch-name-prefix: fix-version-pyproject
pr-title-prefix: pyproject.tomlを直してあげたよ
pr-update-version:
runs-on: ubuntu-latest
needs: deploy_docker_image
Expand Down Expand Up @@ -210,14 +210,14 @@ jobs:
runs-on: ubuntu-latest
if: always()
needs:
- update-version-python-version
- update-version-pyproject
- pr-check-npm
- update-dockle
- dockle
steps:
- if: needs.update-dockle.result == 'success' && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.repository != github.event.pull_request.head.repo.full_name) || (needs.update-version-python-version.result == 'success' && (github.event.action == 'closed' || (needs.pr-check-npm.result == 'success' && needs.dockle.result == 'success'))))
- if: needs.update-dockle.result == 'success' && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.repository != github.event.pull_request.head.repo.full_name) || (needs.update-version-pyproject.result == 'success' && (github.event.action == 'closed' || (needs.pr-check-npm.result == 'success' && needs.dockle.result == 'success'))))
run: exit 0
- if: ${{ !(needs.update-dockle.result == 'success' && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.repository != github.event.pull_request.head.repo.full_name) || (needs.update-version-python-version.result == 'success' && (github.event.action == 'closed' || (needs.pr-check-npm.result == 'success' && needs.dockle.result == 'success'))))) }}
- if: ${{ !(needs.update-dockle.result == 'success' && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.repository != github.event.pull_request.head.repo.full_name) || (needs.update-version-pyproject.result == 'success' && (github.event.action == 'closed' || (needs.pr-check-npm.result == 'success' && needs.dockle.result == 'success'))))) }}
run: exit 1
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/pr-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ jobs:
# submodule: 'recursive'
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
id: setup_python
- name: Get uv version
id: get_uv_version
if: github.event_name != 'pull_request' || github.event.action != 'closed'
run: echo "uv_version=$(sed -e 's/uv==//g' requirements.txt)" >> "$GITHUB_OUTPUT"
- name: Set up uv
uses: astral-sh/setup-uv@v4.2.0
if: github.event_name != 'pull_request' || github.event.action != 'closed'
with:
python-version-file: .python-version
cache: pipenv
- if: github.event_name != 'pull_request' || github.event.action != 'closed'
run: sed -i -e "s/python_version = \".*\"/python_version = \"$(echo ${{ steps.setup_python.outputs.python-version }} | sed -e 's/\([0-9]*\.[0-9]*\).*/\1/g')\"/g" Pipfile
version: ${{steps.get_uv_version.outputs.uv_version}}
enable-cache: true
- name: Install dependencies
if: github.event_name != 'pull_request' || github.event.action != 'closed'
run: bash "${GITHUB_WORKSPACE}/scripts/pipenv_install.sh"
run: bash "${GITHUB_WORKSPACE}/scripts/uv_install.sh"
# formatする
# --exit-codeをつけることで、autopep8内でエラーが起きれば1、差分があれば2のエラーステータスコードが返ってくる。正常時は0が返る
- name: Format files
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/pr-test-hato-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: "recursive"
- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
- name: Get uv version
id: get_uv_version
run: echo "uv_version=$(sed -e 's/uv==//g' requirements.txt)" >> "$GITHUB_OUTPUT"
- name: Set up uv
uses: astral-sh/setup-uv@v4.2.0
with:
python-version-file: .python-version
cache: pipenv
version: ${{steps.get_uv_version.outputs.uv_version}}
enable-cache: true
- name: Install dependencies
run: bash "${GITHUB_WORKSPACE}/scripts/pipenv_install.sh"
run: bash "${GITHUB_WORKSPACE}/scripts/uv_install.sh"
- name: Test
run: bash "${GITHUB_WORKSPACE}/scripts/pr_test_hato_bot/pr_test/test.sh"
concurrency:
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ jobs:
with:
submodules: "recursive"
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
- name: Get uv version
id: get_uv_version
run: echo "uv_version=$(sed -e 's/uv==//g' requirements.txt)" >> "$GITHUB_OUTPUT"
- name: Set up uv
uses: astral-sh/setup-uv@v4.2.0
with:
python-version-file: .python-version
cache: pipenv
- name: Install pipenv
run: bash "${GITHUB_WORKSPACE}/scripts/pipenv_install.sh"
version: ${{steps.get_uv_version.outputs.uv_version}}
enable-cache: true
- name: Install uv
run: bash "${GITHUB_WORKSPACE}/scripts/uv_install.sh"
- name: Set venv path
env:
DEST_PATH: "/home/runner/work/_temp/_github_workflow/.venv"
Expand Down
1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

1 change: 0 additions & 1 deletion .python-version

This file was deleted.

12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ WORKDIR /usr/src/app

COPY .npmrc .npmrc
COPY requirements.txt requirements.txt
COPY Pipfile Pipfile
COPY Pipfile.lock Pipfile.lock
COPY pyproject.toml pyproject.toml
COPY uv.lock uv.lock
COPY package.json package.json
COPY package-lock.json package-lock.json

Expand All @@ -38,12 +38,12 @@ RUN apt-get update && \
apt-get install -y --no-install-recommends nodejs && \
pip install -r requirements.txt --no-cache-dir && \
if [ "${ENV}" = 'dev' ]; then \
pipenv install --system --dev; \
uv sync --frozen --dev; \
else \
pipenv install --system; \
uv sync --frozen; \
fi && \
npm install && \
pip uninstall -y pipenv virtualenv && \
pip uninstall -y uv virtualenv && \
apt-get remove -y git gcc libc6-dev gnupg && \
apt-get autoremove -y && \
apt-get clean && \
Expand All @@ -54,6 +54,8 @@ RUN apt-get update && \
chown -R nonroot /usr/src/app
USER nonroot

ENV PATH="/usr/src/app/.venv/bin:$PATH"

# Matplotlib用のフォントキャッシュ生成
RUN python -c 'import matplotlib.pyplot'

Expand Down
52 changes: 0 additions & 52 deletions Pipfile

This file was deleted.

Loading

0 comments on commit 25fa23e

Please sign in to comment.