From 1de12e415438cf70b8ce7fcdeb6e430f3ae1e341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sondre=20Lilleb=C3=B8=20Gundersen?= Date: Sun, 12 Feb 2023 00:11:32 +0100 Subject: [PATCH] chore: Remove old scripts --- .github/workflows/test.yml | 192 +++++++++++++++++-------------------- scripts/README.md | 4 - scripts/v1.1/main.sh | 45 --------- scripts/v1.2/main.sh | 63 ------------ 4 files changed, 90 insertions(+), 214 deletions(-) delete mode 100644 scripts/README.md delete mode 100755 scripts/v1.1/main.sh delete mode 100644 scripts/v1.2/main.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c8154674..80c4bc0e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,108 +7,96 @@ defaults: shell: bash jobs: -# # Make sure the action works using the default settings -# test-install: -# name: default ${{ matrix.poetry-version }} ${{ matrix.os }} ${{ matrix.python-version }} -# strategy: -# fail-fast: false -# matrix: -# os: [ ubuntu-latest, macos-latest, windows-latest ] -# python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ] -# poetry-version: [ "1.1.15", "1.2.2", "1.3.2" ] -# runs-on: ${{ matrix.os }} -# steps: -# - uses: actions/checkout@v3 -# - uses: ./ -# with: -# version: "${{ matrix.poetry-version }}" -# - uses: actions/setup-python@v4 -# with: -# python-version: "${{ matrix.python-version }}" -# - run: | -# poetry install --no-root --no-interaction -# poetry install --no-interaction -# poetry run pytest --version -# -# # Make sure the action sets config options correctly -# test-config-options: -# name: non-standard config - ${{ matrix.os }} ${{ matrix.python-version }} -# strategy: -# fail-fast: true -# matrix: -# os: [ ubuntu-latest, macos-latest, windows-latest ] -# python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ] -# runs-on: ${{ matrix.os }} -# steps: -# - uses: actions/checkout@v3 -# - uses: actions/setup-python@v4 -# with: -# python-version: "${{ matrix.python-version }}" -# - uses: ./ -# with: -# version: 1.3.2 -# virtualenvs-create: false -# virtualenvs-in-project: true -# virtualenvs-path: ~/.cache/test -# installer-parallel: false -# - run: | -# source .github/scripts/assert.sh -# assert_in "1.3.2" "$(poetry --version)" -# assert_in "false" "$(poetry config virtualenvs.create)" -# assert_in "true" "$(poetry config virtualenvs.in-project)" -# assert_in "test" "$(poetry config virtualenvs.path)" -# assert_in "false" "$(poetry config installer.parallel)" -# -# # Check that installation-arguments works -# test-installation-arguments: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 -# - uses: ./ -# with: -# installation-arguments: --git https://github.com/python-poetry/poetry.git@69bd6820e320f84900103fdf867e24b355d6aa5d -# - run: | -# source .github/scripts/assert.sh -# assert_in "1.1.9" "$(poetry --version)" -# -# # Retrieve the latest poetry version from PyPI -# check-latest: -# runs-on: ubuntu-latest -# outputs: -# latest-poetry-version: ${{ steps.fetch.outputs.version }} -# steps: -# - name: Fetch the latest Poetry version from PyPI -# id: fetch -# run: echo "::set-output name=version::$(python -c "import requests;response = requests.get(f'https://pypi.org/pypi/poetry/json');latest_version = response.json()['info']['version'];print(latest_version)")" -# -# # Make sure the action installs the latest version by default -# test-latest-version-when-unspecified: -# needs: check-latest -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 -# - uses: ./ -# - run: | -# source .github/scripts/assert.sh -# assert_in "." "${{ needs.check-latest.outputs.latest-poetry-version }}" -# assert_in "${{ needs.check-latest.outputs.latest-poetry-version }}" "$(poetry --version)" -# -# # Make sure we're able to run the action with both major and minor versions -# test-major-and-minor-versions: -# runs-on: ubuntu-latest -# steps: -# - uses: snok/install-poetry@v1 -# - uses: snok/install-poetry@v1.1 -# - uses: snok/install-poetry@v1.2 + # Make sure the action works using the default settings + test-install: + name: default ${{ matrix.poetry-version }} ${{ matrix.os }} ${{ matrix.python-version }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ] + poetry-version: [ "1.1.15", "1.2.2", "1.3.2" ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - uses: ./ + with: + version: "${{ matrix.poetry-version }}" + - uses: actions/setup-python@v4 + with: + python-version: "${{ matrix.python-version }}" + - run: | + poetry install --no-root --no-interaction + poetry install --no-interaction + poetry run pytest --version + + # Make sure the action sets config options correctly + test-config-options: + name: non-standard config - ${{ matrix.os }} ${{ matrix.python-version }} + strategy: + fail-fast: true + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "${{ matrix.python-version }}" + - uses: ./ + with: + version: 1.3.2 + virtualenvs-create: false + virtualenvs-in-project: true + virtualenvs-path: ~/.cache/test + installer-parallel: false + - run: | + source .github/scripts/assert.sh + assert_in "1.3.2" "$(poetry --version)" + assert_in "false" "$(poetry config virtualenvs.create)" + assert_in "true" "$(poetry config virtualenvs.in-project)" + assert_in "test" "$(poetry config virtualenvs.path)" + assert_in "false" "$(poetry config installer.parallel)" + + # Check that installation-arguments works + test-installation-arguments: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./ + with: + installation-arguments: --git https://github.com/python-poetry/poetry.git@69bd6820e320f84900103fdf867e24b355d6aa5d + - run: | + source .github/scripts/assert.sh + assert_in "1.1.9" "$(poetry --version)" + + # Retrieve the latest poetry version from PyPI + check-latest: + runs-on: ubuntu-latest + outputs: + latest-poetry-version: ${{ steps.fetch.outputs.version }} + steps: + - name: Fetch the latest Poetry version from PyPI + id: fetch + run: echo "::set-output name=version::$(python -c "import requests;response = requests.get(f'https://pypi.org/pypi/poetry/json');latest_version = response.json()['info']['version'];print(latest_version)")" + + # Make sure the action installs the latest version by default + test-latest-version-when-unspecified: + needs: check-latest + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./ + - run: | + source .github/scripts/assert.sh + assert_in "." "${{ needs.check-latest.outputs.latest-poetry-version }}" + assert_in "${{ needs.check-latest.outputs.latest-poetry-version }}" "$(poetry --version)" - # Legacy: make sure old scripts are not deleted - # The scripts folder contains scripts that are fetched by older versions of the - # action. They're unfortunately fetched from the main branch. - # If we delete these scripts, those versions of the action will fail. - test-scripts-exist: + # Make sure we're able to run the action with both major and minor versions + test-major-and-minor-versions: runs-on: ubuntu-latest steps: - # v1.1 script loaded in < 1.1.4 - - uses: snok/install-poetry@v1.1.4 - # v1.2 script loaded in > 1.1.4 - - uses: snok/install-poetry@v1.1.6 + - uses: snok/install-poetry@v1 + - uses: snok/install-poetry@v1.1 + - uses: snok/install-poetry@v1.2 diff --git a/scripts/README.md b/scripts/README.md deleted file mode 100644 index eb305387..00000000 --- a/scripts/README.md +++ /dev/null @@ -1,4 +0,0 @@ -The scripts in the scripts folder should not ever change. - -Previous versions of the action would curl scripts from the repos main branch, -meaning that if we remove them, old pinned versions of the action will break. diff --git a/scripts/v1.1/main.sh b/scripts/v1.1/main.sh deleted file mode 100755 index 2a7eb90b..00000000 --- a/scripts/v1.1/main.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -# Give inputs sensible names -os=$1 -venv_create=$2 -venv_in_project=$3 -venv_path=$4 - -# Define OS specific help text -if [ "$os" == "Windows" ]; then - conf="\033[33mConfiguring Poetry for Windows!\033[0m" - act="source .venv/scripts/activate" - echo "VENV=.venv/scripts/activate" >>"$GITHUB_ENV" -else - conf="\033[33mConfiguring Poetry!\033[0m" - act="source .venv/bin/activate" - echo "VENV=.venv/bin/activate" >>"$GITHUB_ENV" -fi - -# Echo help texts -echo -e "\n\n-------------------------------------------------------------------------------\n\n$conf 🎉" -if [ "$venv_create" == true ] || [ "$venv_create" == "true" ]; then - # If user is creating a venv in-project we tell them how to activate venv - echo -e "\n\n\033[33mIf you are creating a venv in your project, you can activate it by running '$act'\033[0m" - echo -e "\n\033[33mIf you're running this in an OS matrix, use 'source \$VENV'\033[0m" -fi -if [ "$os" == "Windows" ]; then - # If $SHELL isn't some variation of bash, output a yellow-texted warning - echo -e "\n\n\033[33mMake sure to set your default shell to bash when on Windows.\033[0m" - echo -e "\n\033[33mSee the package docs for more information and examples.\033[0m" -fi -echo -e '\n-------------------------------------------------------------------------------\n' - -# Configure Poetry -if [ "$os" == "Windows" ]; then - ln -s "$HOME/.poetry/bin/poetry.bat" "poetry" - "$HOME/.poetry/bin/poetry.bat" config virtualenvs.create "$venv_create" - "$HOME/.poetry/bin/poetry.bat" config virtualenvs.in-project "$venv_in_project" - "$HOME/.poetry/bin/poetry.bat" config virtualenvs.path "$venv_path" -else - source "$HOME"/.poetry/env - poetry config virtualenvs.create "$venv_create" - poetry config virtualenvs.in-project "$venv_in_project" - poetry config virtualenvs.path "$venv_path" -fi diff --git a/scripts/v1.2/main.sh b/scripts/v1.2/main.sh deleted file mode 100644 index 37ee2cd4..00000000 --- a/scripts/v1.2/main.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash - -# Give inputs sensible names -os=$1 -venv_create=$2 -venv_in_project=$3 -venv_path=$4 -version=$5 -installation_script=$6 - -# Set path for each OS - done because Poetry inference is inconsistent -# on mac-runners, and we need to know the install path so we can add it to $GITHUB_PATH -if [ "$os" == "Windows" ]; then - path="C:/Users/runneradmin/AppData/Roaming/Python/Scripts/" -else - path="$HOME/.local/" -fi - -# Install Poetry -POETRY_HOME=$path python3 $installation_script --yes --version=$version - -# Add to path -echo "$path/bin" >>$GITHUB_PATH -export PATH="$path/bin:$PATH" - -# Configure Poetry -if [ "$os" == "Windows" ]; then - # Adding to path on windows doesn't immediately take effect - # so calling the executable directly here - should be available - # in next steps regardless. - "$path/bin/poetry.exe" config virtualenvs.create "$venv_create" - "$path/bin/poetry.exe" config virtualenvs.in-project "$venv_in_project" - "$path/bin/poetry.exe" config virtualenvs.path "$venv_path" -else - poetry config virtualenvs.create "$venv_create" - poetry config virtualenvs.in-project "$venv_in_project" - poetry config virtualenvs.path "$venv_path" -fi - -# Define OS specific help texts -if [ "$os" == "Windows" ]; then - conf="\033[33mConfiguring Poetry for Windows!\033[0m" - act="source .venv/scripts/activate" - echo "VENV=.venv/scripts/activate" >>"$GITHUB_ENV" -else - conf="\033[33mConfiguring Poetry!\033[0m" - act="source .venv/bin/activate" - echo "VENV=.venv/bin/activate" >>"$GITHUB_ENV" -fi - -# Output help texts -echo -e "\n\n-------------------------------------------------------------------------------\n\n$conf 🎉" -if [ "$venv_create" == true ] || [ "$venv_create" == "true" ]; then - # If user is creating a venv in-project we tell them how to activate venv - echo -e "\n\n\033[33mIf you are creating a venv in your project, you can activate it by running '$act'\033[0m" - echo -e "\n\033[33mIf you're running this in an OS matrix, use 'source \$VENV'\033[0m" -fi -if [ "$os" == "Windows" ]; then - # If $SHELL isn't some variation of bash, output a yellow-texted warning - echo -e "\n\n\033[33mMake sure to set your default shell to bash when on Windows.\033[0m" - echo -e "\n\033[33mSee the github action docs for more information and examples.\033[0m" -fi -echo -e '\n-------------------------------------------------------------------------------\n'