Skip to content

Commit

Permalink
Fix JS github action logic (#71)
Browse files Browse the repository at this point in the history
* Fix JS github action generator logic

* Clean before regeneration

* Update node version
  • Loading branch information
jasonpaulos committed Dec 18, 2023
1 parent 88668a4 commit 61473bf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/actions/sdk-codegen/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
33 changes: 31 additions & 2 deletions .github/actions/sdk-codegen/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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 \
Expand Down Expand Up @@ -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" \
Expand Down

0 comments on commit 61473bf

Please sign in to comment.