From a222ff3bf1dad30b321b1971914957ab3eaa57c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sondre=20Lilleb=C3=B8=20Gundersen?= Date: Thu, 6 Oct 2022 13:20:30 +0800 Subject: [PATCH] wip --- .github/scripts/assert.sh | 3 + .github/workflows/test.yml | 270 ++++++++++++++++++------------------- main.sh | 6 +- 3 files changed, 143 insertions(+), 136 deletions(-) diff --git a/.github/scripts/assert.sh b/.github/scripts/assert.sh index a933efda..161226eb 100644 --- a/.github/scripts/assert.sh +++ b/.github/scripts/assert.sh @@ -1,5 +1,8 @@ #!/bin/bash +set -o errexit +set -o pipefail + assert_in_one() { local option1="$1" local option2="$2" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6e284346..b55e99e9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,13 +8,13 @@ on: pull_request env: # JSON variables (used in our strategy/matrix) - SUPPORTED_POETRY_VERSIONS: '\"poetry-version\":[\"1.1.0\", \"1.1.10\", \"1.1.14\", \"1.2.0a2\", \"1.2.0b1\", \"1.2.0b2\", \"1.2.0b3\"]' - SUPPORTED_PYTHON_VERSIONS: '\"python-version\":[\"3.7\", \"3.9\", \"3.10.0-rc.2\"]' + SUPPORTED_POETRY_VERSIONS: '\"poetry-version\":[\"1.1.0\", \"1.1.10\", \"1.1.14\", \"1.2.0\", \"1.2.1\"]' + SUPPORTED_PYTHON_VERSIONS: '\"python-version\":[\"3.7\", \"3.10\", \"3.11.0-rc.1\"]' SUPPORTED_OPERATING_SYSTEMS: '\"os\":[\"ubuntu-latest\", \"macos-latest\", \"windows-latest\"]' # Normal variables (used in steps/*) LATEST_PYTHON: "3.10" - LATEST_POETRY: "1.1.14" + LATEST_POETRY: "1.2.1" jobs: # The set-env job translates our json variables to a format we @@ -70,135 +70,135 @@ jobs: - run: poetry install --no-root --no-interaction - run: poetry install --no-interaction - run: poetry run pytest --version - - test-create-venv-false: - name: Skip venv creation - ${{ matrix.os }} - needs: set-env - strategy: - fail-fast: true - matrix: ${{ fromJson(needs.set-env.outputs.os-matrix) }} - defaults: - run: - shell: bash - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - uses: ./ - with: - version: ${{ env.LATEST_POETRY }} - virtualenvs-create: false - - uses: actions/setup-python@v2 - with: - python-version: ${{ env.LATEST_PYTHON }} - - name: Test no venv is created - run: | - output=$(poetry config virtualenvs.create) - echo $output - source .github/scripts/assert.sh - assert_in "false" "$output" - - # Makes sure creating a venv in-project works - # Makes sure all operating system combinations can activate venvs - # using the custom install-poetry $VENV environment variable - test-venv-env-var: - needs: set-env - strategy: - fail-fast: true - matrix: ${{ fromJson(needs.set-env.outputs.os-matrix) }} - defaults: - run: - shell: bash - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - name: Setup Poetry - uses: ./ - with: - virtualenvs-in-project: true - - uses: actions/setup-python@v2 - with: - python-version: ${{ env.LATEST_PYTHON }} - - run: | - output="$(poetry install)" - source .github/scripts/assert.sh - echo "$output" - assert_in "/install-poetry/install-poetry/.venv" "$output" - source $VENV - pytest --version - - # Make sure the default version corresponds to 'latest' - test-latest-version-when-unspecified: - needs: set-env - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Setup Poetry - uses: ./ - # This test will need to change every time poetry releases a new version - # If you're submitting a PR and this fails because Poetry release a new version - # feel free to update it - - run: | - source .github/scripts/assert.sh - assert_in "${{LATEST_POETRY}} "$(poetry --version)" - - # Make sure scripts are not deleted. - # If we deleted the scripts folder (or subfolders) by accident, - # different versions of the action would fail - test-scripts-exist: - 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 - - # Make sure we're able to run the action with major and - # minor version, not just with complete 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 - - test-setting-non-default-settings: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: ./ - with: - version: 1.1.7 - virtualenvs-create: false - virtualenvs-in-project: true - virtualenvs-path: ~/.cache/virtualenvs - installer-parallel: false - - run: | - source .github/scripts/assert.sh - assert_in "1.1.7" "$(poetry --version)" - assert_in "false" "$(poetry config virtualenvs.create)" - assert_in "true" "$(poetry config virtualenvs.in-project)" - assert_in "/home/runner/.cache/virtualenvs" "$(poetry config virtualenvs.path)" - assert_in "false" "$(poetry config installer.parallel)" - - test-installation-arguments-version-unspecified: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - 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)" - - test-installation-arguments-version-specified: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: ./ - with: - version: 1.1.7 - installation-arguments: --git https://github.com/python-poetry/poetry.git@69bd6820e320f84900103fdf867e24b355d6aa5d - - run: | - source .github/scripts/assert.sh - assert_in "1.1.9" "$(poetry --version)" +# +# test-create-venv-false: +# name: Skip venv creation - ${{ matrix.os }} +# needs: set-env +# strategy: +# fail-fast: true +# matrix: ${{ fromJson(needs.set-env.outputs.os-matrix) }} +# defaults: +# run: +# shell: bash +# runs-on: ${{ matrix.os }} +# steps: +# - uses: actions/checkout@v2 +# - uses: ./ +# with: +# version: ${{ env.LATEST_POETRY }} +# virtualenvs-create: false +# - uses: actions/setup-python@v2 +# with: +# python-version: ${{ env.LATEST_PYTHON }} +# - name: Test no venv is created +# run: | +# output=$(poetry config virtualenvs.create) +# echo $output +# source .github/scripts/assert.sh +# assert_in "false" "$output" +# +# # Makes sure creating a venv in-project works +# # Makes sure all operating system combinations can activate venvs +# # using the custom install-poetry $VENV environment variable +# test-venv-env-var: +# needs: set-env +# strategy: +# fail-fast: true +# matrix: ${{ fromJson(needs.set-env.outputs.os-matrix) }} +# defaults: +# run: +# shell: bash +# runs-on: ${{ matrix.os }} +# steps: +# - uses: actions/checkout@v2 +# - name: Setup Poetry +# uses: ./ +# with: +# virtualenvs-in-project: true +# - uses: actions/setup-python@v2 +# with: +# python-version: ${{ env.LATEST_PYTHON }} +# - run: | +# output="$(poetry install)" +# source .github/scripts/assert.sh +# echo "$output" +# assert_in "/install-poetry/install-poetry/.venv" "$output" +# source $VENV +# pytest --version +# +# # Make sure the default version corresponds to 'latest' +# test-latest-version-when-unspecified: +# needs: set-env +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - name: Setup Poetry +# uses: ./ +# # This test will need to change every time poetry releases a new version +# # If you're submitting a PR and this fails because Poetry release a new version +# # feel free to update it +# - run: | +# source .github/scripts/assert.sh +# assert_in "${{ env.LATEST_POETRY }}" "$(poetry --version)" +# +# # Make sure scripts are not deleted. +# # If we deleted the scripts folder (or subfolders) by accident, +# # different versions of the action would fail +# test-scripts-exist: +# 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 +# +# # Make sure we're able to run the action with major and +# # minor version, not just with complete 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 +# +# test-setting-non-default-settings: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - uses: ./ +# with: +# version: 1.1.7 +# virtualenvs-create: false +# virtualenvs-in-project: true +# virtualenvs-path: ~/.cache/virtualenvs +# installer-parallel: false +# - run: | +# source .github/scripts/assert.sh +# assert_in "1.1.7" "$(poetry --version)" +# assert_in "false" "$(poetry config virtualenvs.create)" +# assert_in "true" "$(poetry config virtualenvs.in-project)" +# assert_in "/home/runner/.cache/virtualenvs" "$(poetry config virtualenvs.path)" +# assert_in "false" "$(poetry config installer.parallel)" +# +# test-installation-arguments-version-unspecified: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - 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)" +# +# test-installation-arguments-version-specified: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - uses: ./ +# with: +# version: 1.1.7 +# installation-arguments: --git https://github.com/python-poetry/poetry.git@69bd6820e320f84900103fdf867e24b355d6aa5d +# - run: | +# source .github/scripts/assert.sh +# assert_in "1.1.9" "$(poetry --version)" diff --git a/main.sh b/main.sh index 163d395d..fc742b35 100755 --- a/main.sh +++ b/main.sh @@ -1,12 +1,16 @@ #!/usr/bin/env bash +set -o errexit +set -o pipefail +set -o nounset + installation_script="$(mktemp)" curl -sSL https://install.python-poetry.org/ --output "$installation_script" if [ "${RUNNER_OS}" == "Windows" ]; then path="C:/Users/runneradmin/AppData/Roaming/Python/Scripts" else - path="$HOME/.local/" + path="$HOME/.local" fi echo -e "\n\033[33mSetting Poetry installation path as $path\033[0m\n"