From 61473bf1f921da37039b374c8a67e1a0872f2208 Mon Sep 17 00:00:00 2001 From: Jason Paulos Date: Mon, 18 Dec 2023 16:51:33 -0500 Subject: [PATCH] Fix JS github action logic (#71) * Fix JS github action generator logic * Clean before regeneration * Update node version --- .github/actions/sdk-codegen/Dockerfile | 2 +- .github/actions/sdk-codegen/entrypoint.sh | 33 +++++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/.github/actions/sdk-codegen/Dockerfile b/.github/actions/sdk-codegen/Dockerfile index efeaa56..b9a4f29 100644 --- a/.github/actions/sdk-codegen/Dockerfile +++ b/.github/actions/sdk-codegen/Dockerfile @@ -3,7 +3,7 @@ FROM golang:1.17.9-bullseye ARG GITHUB_CLI_URL="https://github.com/cli/cli/releases/download/v1.8.1/gh_1.8.1_linux_amd64.tar.gz" # Manually install npm -RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - +RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y maven openjdk-17-jdk nodejs diff --git a/.github/actions/sdk-codegen/entrypoint.sh b/.github/actions/sdk-codegen/entrypoint.sh index 059df00..2b3a6d6 100755 --- a/.github/actions/sdk-codegen/entrypoint.sh +++ b/.github/actions/sdk-codegen/entrypoint.sh @@ -31,15 +31,26 @@ function generate_js { TEMPLATE_DIR=$GENERATOR_DIR/typescript_templates export GH_REPO=$JS_SDK_REPO git clone --depth 1 https://github.com/algorand/js-algorand-sdk $JS_SDK_DIR + + # Clean previously (stale) generated files before regenerating them. + find $JS_SDK_DIR/src/client/v2/algod/models/* $JS_SDK_DIR/src/client/v2/indexer/models/* -delete + # Generate algod. $TEMPLATE \ -s "$ALGOD_SPEC" \ -t "$TEMPLATE_DIR" \ -m "$JS_SDK_DIR/src/client/v2/algod/models" \ - -p "$TEMPLATE_DIR/common_config.properties,$TEMPLATE_DIR/parameter_order_overrides.properties" + -p "$TEMPLATE_DIR/algod_config.properties,$TEMPLATE_DIR/parameter_order_overrides.properties" + + # Generate indexer. + $TEMPLATE \ + -s "$INDEXER_SPEC" \ + -t "$TEMPLATE_DIR" \ + -m "$JS_SDK_DIR/src/client/v2/indexer/models" \ + -p "$TEMPLATE_DIR/indexer_config.properties" pushd $JS_SDK_DIR - npm install + npm ci make format /publish.sh } @@ -49,6 +60,16 @@ function generate_go { TEMPLATE_DIR=$GENERATOR_DIR/go_templates export GH_REPO=$GO_SDK_REPO git clone https://github.com/algorand/go-algorand-sdk $GO_SDK_DIR + + # Clean previously (stale) generated files before regenerating them. + # Some files are hand-written instead of generated, so preserve those files here. + find $GO_SDK_DIR/client/v2/common/models/* $GO_SDK_DIR/client/v2/algod/* $GO_SDK_DIR/client/v2/indexer/* \ + \! -name 'account_error_response.go' \ + \! -name 'blockRaw.go' \ + \! -name 'dryrun.go' \ + \! -name 'shim.go' \ + -delete + # Generate algod. $TEMPLATE \ -s $ALGOD_SPEC \ @@ -77,6 +98,14 @@ function generate_java { export GH_REPO=$JAVA_SDK_REPO git clone https://github.com/algorand/java-algorand-sdk $JAVA_SDK_DIR + # Clean previously (stale) generated files before regenerating them. + # Hand-written files are confined to algosdk/v2/client/common, + # except AlgodClient, which will be re-generated according to the specs. + find $JAVA_SDK_DIR/src/main/java/com/algorand/algosdk/v2/client/model/* \ + $JAVA_SDK_DIR/src/main/java/com/algorand/algosdk/v2/client/algod/* \ + $JAVA_SDK_DIR/src/main/java/com/algorand/algosdk/v2/client/indexer/* \ + -delete + $GENERATOR \ java \ -c "$JAVA_SDK_DIR/src/main/java/com/algorand/algosdk/v2/client/common" \