Skip to content

Commit

Permalink
Merge branch 'main' into signed_commits
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-h-strachan authored Jan 15, 2025
2 parents 1b542e3 + 4bd9a70 commit a0e15e4
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 20 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/sdk-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 | python3 -
poetry --version
env:
POETRY_VERSION: ${{ inputs.poetry_version }}
- name: Check for publish.sh
id: check-publish
run: |
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion .github/workflows/workflow-executor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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 | python3 -
poetry --version
env:
POETRY_VERSION: ${{ inputs.poetry_version }}
- name: Check for publish.sh
id: check-publish
run: |
Expand Down
16 changes: 4 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@ 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

### 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
Expand All @@ -40,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
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -199,3 +202,4 @@ runs:
- ${{ inputs.set_version }}
- ${{ inputs.cli_environment_variables }}
- ${{ inputs.pnpm_version }}
- ${{ inputs.poetry_version }}
22 changes: 22 additions & 0 deletions internal/actions/setup_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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", "--global", poetrySpec)

if err := cmd.Run(); err != nil {
return fmt.Errorf("error installing poetry: %w", err)
}

return nil
}
4 changes: 4 additions & 0 deletions internal/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion testing/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function run_action() {
}

# Default environment variables not subject to change by different tests
#INPUT_SPEAKEASY_VERSION="v1.240.0" # Uncomment to test specific versions otherwise uses latest
#export INPUT_SPEAKEASY_VERSION="v1.240.0" # Uncomment to test specific versions otherwise uses latest

if [ "$RUN_FINALIZE" = "true" ]; then
BRANCH_NAME=$(go run testing/getoutput.go -output branch_name)
Expand Down

0 comments on commit a0e15e4

Please sign in to comment.