diff --git a/.github/workflows/pr-format.yml b/.github/workflows/pr-format.yml index 293f57413c..27fe0fd5bd 100644 --- a/.github/workflows/pr-format.yml +++ b/.github/workflows/pr-format.yml @@ -35,13 +35,9 @@ jobs: 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 - - name: Install pipenv - id: install_pipenv - if: github.event_name != 'pull_request' || github.event.action != 'closed' - run: bash "${GITHUB_WORKSPACE}/scripts/pr_format/pr_format/install_pipenv.sh" - name: Install dependencies if: github.event_name != 'pull_request' || github.event.action != 'closed' - run: bash "${GITHUB_WORKSPACE}/scripts/pr_format/pr_format/pipenv_install.sh" + run: bash "${GITHUB_WORKSPACE}/scripts/pipenv_install.sh" # formatする # --exit-codeをつけることで、autopep8内でエラーが起きれば1、差分があれば2のエラーステータスコードが返ってくる。正常時は0が返る - name: Format files diff --git a/.github/workflows/pr-test-hato-bot.yml b/.github/workflows/pr-test-hato-bot.yml index ed49149f8f..20bfe250d1 100644 --- a/.github/workflows/pr-test-hato-bot.yml +++ b/.github/workflows/pr-test-hato-bot.yml @@ -21,6 +21,8 @@ jobs: with: python-version-file: .python-version cache: pipenv + - name: Install dependencies + run: bash "${GITHUB_WORKSPACE}/scripts/pipenv_install.sh" - name: Test run: bash "${GITHUB_WORKSPACE}/scripts/pr_test_hato_bot/pr_test/test.sh" concurrency: diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index be47db0408..0d5e23600a 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -20,9 +20,11 @@ jobs: python-version-file: .python-version cache: pipenv - name: Install pipenv + run: bash "${GITHUB_WORKSPACE}/scripts/pipenv_install.sh" + - name: Set venv path env: DEST_PATH: "/home/runner/work/_temp/_github_workflow/.venv" - run: bash "${GITHUB_WORKSPACE}/scripts/pr_test/pr_super_lint/install_pipenv.sh" + run: bash "${GITHUB_WORKSPACE}/scripts/pr_test/pr_super_lint/set_venv_path.sh" - name: Set up Node.js uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: diff --git a/Dockerfile b/Dockerfile index 52d6322fc4..04ad473b9f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,7 @@ ENV ENV="${ENV}" WORKDIR /usr/src/app COPY .npmrc .npmrc +COPY requirements.txt requirements.txt COPY Pipfile Pipfile COPY Pipfile.lock Pipfile.lock COPY package.json package.json @@ -35,7 +36,7 @@ RUN apt-get update && \ echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \ apt-get update && \ apt-get install -y --no-install-recommends nodejs && \ - pip install pipenv==2024.0.1 --no-cache-dir && \ + pip install -r requirements.txt --no-cache-dir && \ if [ "${ENV}" = 'dev' ]; then \ pipenv install --system --dev; \ else \ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000..34b9e5c44c --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pipenv==2024.0.1 diff --git a/scripts/pr_format/pr_format/pipenv_install.sh b/scripts/pipenv_install.sh similarity index 64% rename from scripts/pr_format/pr_format/pipenv_install.sh rename to scripts/pipenv_install.sh index f325620c9d..2f7b478c53 100755 --- a/scripts/pr_format/pr_format/pipenv_install.sh +++ b/scripts/pipenv_install.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +pip install -r requirements.txt pipenv --version pipenv install --dev diff --git a/scripts/pr_format/pr_format/install_pipenv.sh b/scripts/pr_format/pr_format/install_pipenv.sh deleted file mode 100755 index c235e4a109..0000000000 --- a/scripts/pr_format/pr_format/install_pipenv.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -file_name=Dockerfile -package_name=pipenv - -if [ -f ${file_name} ]; then - PATTERN="${package_name}[^ ]+" - package_name_with_version=$(grep -oE "${PATTERN}" ${file_name}) -else - package_name_with_version=${package_name} -fi - -pip install "${package_name_with_version}" - -if [ -f ${file_name} ]; then - new_version="$(pip list --outdated | grep pipenv || true)" - new_version="$(echo -e "${new_version}" | awk '{print $3}')" - if [ -n "${new_version}" ]; then - PATTERN_BEFORE="${package_name}[^ ]+" - PATTERN_AFTER="${package_name}==${new_version}" - sed -i -E "s/${PATTERN_BEFORE}/${PATTERN_AFTER}/g" ${file_name} - pip install "${package_name}==${new_version}" - exit 1 - fi -fi diff --git a/scripts/pr_test/pr_super_lint/install_pipenv.sh b/scripts/pr_test/pr_super_lint/set_venv_path.sh similarity index 68% rename from scripts/pr_test/pr_super_lint/install_pipenv.sh rename to scripts/pr_test/pr_super_lint/set_venv_path.sh index 973179ac6c..6c08a1cec7 100755 --- a/scripts/pr_test/pr_super_lint/install_pipenv.sh +++ b/scripts/pr_test/pr_super_lint/set_venv_path.sh @@ -1,18 +1,5 @@ #!/usr/bin/env bash -file_name=Dockerfile -package_name=pipenv - -if [ -f ${file_name} ]; then - package_name_v=$(grep -oE "${package_name}[^ ]+" ${file_name}) -else - package_name_v=${package_name} -fi - -pip install "${package_name_v}" -pipenv --version -pipenv install --dev - # 環境ファイルを使ってenvにsetしている # 参考URL: https://bit.ly/2KJhjqk venv_path=$(pipenv --venv) diff --git a/scripts/pr_test_hato_bot/pr_test/test.sh b/scripts/pr_test_hato_bot/pr_test/test.sh index 07db607163..bb9ca7bded 100755 --- a/scripts/pr_test_hato_bot/pr_test/test.sh +++ b/scripts/pr_test_hato_bot/pr_test/test.sh @@ -1,17 +1,4 @@ #!/usr/bin/env bash -file_name=Dockerfile -package_name=pipenv - -if [ -f ${file_name} ]; then - PATTERN="${package_name}[^ ]+" - package_name_with_version=$(grep -oE "${PATTERN}" ${file_name}) -else - package_name_with_version=${package_name} -fi - -pip install "${package_name_with_version}" -pipenv --version -pipenv install --dev cp .env.example .env pipenv run python -m unittest