From 7ae575006e0e63e1c64fd420bf6d63605b0e2f8d Mon Sep 17 00:00:00 2001 From: Tristan Cartledge <108070248+TristanSpeakEasy@users.noreply.github.com> Date: Mon, 6 Jan 2025 13:36:18 +1000 Subject: [PATCH 1/5] fix: install specific version of poetry as the latest version is incompatible with python 3.8 (#196) --- .github/workflows/sdk-publish.yaml | 2 +- .github/workflows/workflow-executor.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sdk-publish.yaml b/.github/workflows/sdk-publish.yaml index 15f5b97..b25ae3b 100644 --- a/.github/workflows/sdk-publish.yaml +++ b/.github/workflows/sdk-publish.yaml @@ -157,7 +157,7 @@ jobs: python-version: "3.8" - name: Install poetry run: | - curl -sSL https://install.python-poetry.org | python3 - + curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.3 python3 - poetry --version - name: Check for publish.sh id: check-publish diff --git a/.github/workflows/workflow-executor.yaml b/.github/workflows/workflow-executor.yaml index c7f65d1..c9f353a 100644 --- a/.github/workflows/workflow-executor.yaml +++ b/.github/workflows/workflow-executor.yaml @@ -260,7 +260,7 @@ jobs: python-version: "3.8" - name: Install poetry run: | - curl -sSL https://install.python-poetry.org | python3 - + curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.3 python3 - poetry --version - name: Check for publish.sh id: check-publish From 172d3dd23103d9a34e2c0461e52fc5345552e943 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Thu, 9 Jan 2025 11:45:35 -0500 Subject: [PATCH 2/5] feat: Support poetry_version input to specify Poetry tool version (#197) Reference: https://linear.app/speakeasy/issue/GEN-877/tech-debt-python-poetry-20 This change adds a `poetry_version` input to each of the workflows to specify the Poetry tool version to install and use. By default, the latest (2.0.0 as of this change) is installed, but this is being added as a compatibility layer for calling GitHub Actions workflows that pin the Speakeasy CLI to an older version, which require an older Poetry version before the major version update such as 1.8.3. --- .github/workflows/sdk-publish.yaml | 10 ++++++++-- .github/workflows/workflow-executor.yaml | 11 +++++++++-- Dockerfile | 6 +----- action.yml | 4 ++++ internal/actions/setup_environment.go | 22 ++++++++++++++++++++++ internal/environment/environment.go | 4 ++++ 6 files changed, 48 insertions(+), 9 deletions(-) diff --git a/.github/workflows/sdk-publish.yaml b/.github/workflows/sdk-publish.yaml index b25ae3b..adf650c 100644 --- a/.github/workflows/sdk-publish.yaml +++ b/.github/workflows/sdk-publish.yaml @@ -21,6 +21,10 @@ on: required: false type: string default: "5.x" + poetry_version: + description: "The version of poetry to use" + required: false + type: string target: description: "The specific target to publish" required: false @@ -154,11 +158,13 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.9" - name: Install poetry run: | - curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.3 python3 - + curl -sSL https://install.python-poetry.org | python3 - poetry --version + env: + POETRY_VERSION: ${{ inputs.poetry_version }} - name: Check for publish.sh id: check-publish run: | diff --git a/.github/workflows/workflow-executor.yaml b/.github/workflows/workflow-executor.yaml index c9f353a..1268f29 100644 --- a/.github/workflows/workflow-executor.yaml +++ b/.github/workflows/workflow-executor.yaml @@ -78,6 +78,10 @@ on: description: "Version of pnpm to install. Not recommended for use without consulting Speakeasy support." required: false type: string + poetry_version: + description: "Version of poetry to install. Not recommended for use without consulting Speakeasy support." + required: false + type: string secrets: github_access_token: description: A GitHub access token with write access to the repo @@ -208,6 +212,7 @@ jobs: set_version: ${{ inputs.set_version }} cli_environment_variables: ${{ inputs.environment }} pnpm_version: ${{ inputs.pnpm_version }} + poetry_version: ${{ inputs.poetry_version }} - uses: ravsamhq/notify-slack-action@v2 if: ${{ steps.check-label.outputs.short_circuit_label_trigger != 'true' && env.SLACK_WEBHOOK_URL != '' }} with: @@ -257,11 +262,13 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.9" - name: Install poetry run: | - curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.3 python3 - + curl -sSL https://install.python-poetry.org | python3 - poetry --version + env: + POETRY_VERSION: ${{ inputs.poetry_version }} - name: Check for publish.sh id: check-publish run: | diff --git a/Dockerfile b/Dockerfile index 123e9a5..5fe0971 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,11 +24,7 @@ RUN apk add git RUN apk add --update --no-cache nodejs npm ### Install Python -RUN apk add --update --no-cache python3 py3-pip python3-dev - -### Install Poetry and validate -RUN apk add --update --no-cache poetry -RUN poetry --version +RUN apk add --update --no-cache python3 py3-pip python3-dev pipx ### Install Java RUN apk add --update --no-cache openjdk11 gradle diff --git a/action.yml b/action.yml index 4f1538d..e1d2059 100644 --- a/action.yml +++ b/action.yml @@ -94,6 +94,9 @@ inputs: pnpm_version: description: "Version of pnpm to install. Not recommended for use without consulting Speakeasy support." required: false + poetry_version: + description: "Version of poetry to install. Not recommended for use without consulting Speakeasy support." + required: false outputs: publish_python: description: "Whether the Python SDK will be published to PyPi" @@ -199,3 +202,4 @@ runs: - ${{ inputs.set_version }} - ${{ inputs.cli_environment_variables }} - ${{ inputs.pnpm_version }} + - ${{ inputs.poetry_version }} diff --git a/internal/actions/setup_environment.go b/internal/actions/setup_environment.go index 04ef581..426bc4c 100644 --- a/internal/actions/setup_environment.go +++ b/internal/actions/setup_environment.go @@ -13,6 +13,10 @@ import ( // publishing, then an input (pnpm_version in this case) should be set to a // non-empty value and this logic will install the dependency. func SetupEnvironment() error { + if err := installPoetry(); err != nil { + return err + } + if pnpmVersion := environment.GetPnpmVersion(); pnpmVersion != "" { pnpmPackageSpec := "pnpm@" + pnpmVersion cmd := exec.Command("npm", "install", "-g", pnpmPackageSpec) @@ -24,3 +28,21 @@ func SetupEnvironment() error { return nil } + +// Installs poetry using pipx. If the INPUT_POETRY_VERSION environment variable +// is set, it will install that version. +func installPoetry() error { + poetrySpec := "poetry" + + if poetryVersion := environment.GetPoetryVersion(); poetryVersion != "" { + poetrySpec = "poetry==" + poetryVersion + } + + cmd := exec.Command("pipx", "install", poetrySpec) + + if err := cmd.Run(); err != nil { + return fmt.Errorf("error installing poetry: %w", err) + } + + return nil +} diff --git a/internal/environment/environment.go b/internal/environment/environment.go index 4f72b6e..f775f69 100644 --- a/internal/environment/environment.go +++ b/internal/environment/environment.go @@ -213,6 +213,10 @@ func GetOpenAPIDocAuthToken() string { return os.Getenv("INPUT_OPENAPI_DOC_AUTH_TOKEN") } +func GetPoetryVersion() string { + return os.Getenv("INPUT_POETRY_VERSION") +} + func GetPnpmVersion() string { return os.Getenv("INPUT_PNPM_VERSION") } From 8659c578b314c96c08e193593506b7999d8aad88 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Thu, 9 Jan 2025 16:15:05 -0500 Subject: [PATCH 3/5] fix: Remove unsupported openssl1.1-compat and .NET 5 (for Unity) from Docker image and add CI (#198) --- .github/workflows/test.yaml | 16 +++++++++++----- Dockerfile | 10 +++------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 51a4e14..325a3fe 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -20,15 +20,21 @@ jobs: id-token: "write" actions: "read" steps: - - name: Set up Go 1.x - uses: actions/setup-go@v3 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 with: - go-version: ^1.21 + go-version-file: "go.mod" - name: Configure git for private modules env: GIT_AUTH_TOKEN: ${{ secrets.BOT_REPO_TOKEN }} run: git config --global url."https://speakeasybot:${GIT_AUTH_TOKEN}@github.com".insteadOf "https://github.com" - - name: Check out code - uses: actions/checkout@v3 - name: Test run: go test -v ./... + docker-build: + name: Docker Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc # v6.11.0 + with: + push: false diff --git a/Dockerfile b/Dockerfile index 5fe0971..503a923 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,9 @@ RUN go build -o /action FROM golang:1.23-alpine3.20 RUN apk update -RUN apk add git + +### Install common tools +RUN apk add --update --no-cache bash curl git ### Install Node / NPM RUN apk add --update --no-cache nodejs npm @@ -36,12 +38,6 @@ RUN apk add --update --no-cache build-base ruby ruby-bundler ruby-dev ENV DOTNET_ROOT=/usr/lib/dotnet RUN apk add --update --no-cache dotnet6-sdk -### Install .NET5.0 -RUN apk add --update --no-cache curl bash -# openssl1.1-compat is gradually getting removed from package managers.. -RUN apk add --update --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing openssl1.1-compat -RUN curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -Channel 5.0 -InstallDir ${DOTNET_ROOT} - ### Install .NET8.0 RUN curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -Channel 8.0 -InstallDir ${DOTNET_ROOT} RUN dotnet --list-sdks From 7361172c113e2c0570d2c8664a1fa696ffbf8f3e Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Thu, 9 Jan 2025 21:30:35 -0500 Subject: [PATCH 4/5] fix: Ensure pipx install is global (#199) Otherwise, `pipx install` binaries are not on the PATH for generator commands. --- internal/actions/setup_environment.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/actions/setup_environment.go b/internal/actions/setup_environment.go index 426bc4c..ee9cb5b 100644 --- a/internal/actions/setup_environment.go +++ b/internal/actions/setup_environment.go @@ -38,7 +38,7 @@ func installPoetry() error { poetrySpec = "poetry==" + poetryVersion } - cmd := exec.Command("pipx", "install", poetrySpec) + cmd := exec.Command("pipx", "install", "--global", poetrySpec) if err := cmd.Run(); err != nil { return fmt.Errorf("error installing poetry: %w", err) From 4bd9a704f302917aaa39814c4218dce85fcfb23c Mon Sep 17 00:00:00 2001 From: Ryan Albert <42415738+ryan-timothy-albert@users.noreply.github.com> Date: Mon, 13 Jan 2025 14:46:29 -0800 Subject: [PATCH 5/5] Update test.sh --- testing/test.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/testing/test.sh b/testing/test.sh index b5dfa70..98e5021 100755 --- a/testing/test.sh +++ b/testing/test.sh @@ -11,6 +11,9 @@ function run_action() { # Default environment variables not subject to change by different tests export INPUT_DEBUG=true export INPUT_GITHUB_ACCESS_TOKEN=${GITHUB_ACCESS_TOKEN} +if [ -z "$INPUT_GITHUB_ACCESS_TOKEN" ]; then + INPUT_GITHUB_ACCESS_TOKEN=${GITHUB_TOKEN} +fi #export INPUT_SPEAKEASY_VERSION="v1.240.0" # Uncomment to test specific versions otherwise uses latest export GITHUB_SERVER_URL="https://github.com" export GITHUB_REPOSITORY_OWNER="speakeasy-api"