Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: Sdk code generation #32

Merged
merged 8 commits into from
May 27, 2022

Conversation

Eric-Warehime
Copy link
Contributor

@Eric-Warehime Eric-Warehime commented May 25, 2022

Summary

Adds a github action which can be used by SDKs to automatically generate code and open pull requests.

Currently this automation resides in https://github.com/algorand/generator/tree/master/automation as well as in some of the SDK repos themselves, but it has some issues from lack of maintenance and isn't being used.

The publish.sh file I've taken nearly exactly from what the existing script as it just works.
The entrypoint.sh is a mix of the scripts/generate_{language}.sh and the existing Dockerfile in the automation.

I've moved all of this into a Github Action so that we can have a central location that defines our code generation logic, and then utilize that across each of our SDK repos via a nightly workflow.

Testing

I've run the workflow on my personal forks (so there may be some permissions issues to sort out once we merge this), and have successful runs for generating a PR:
https://github.com/Eric-Warehime/go-algorand-sdk/actions/runs/2386518280
Eric-Warehime/go-algorand-sdk#1 (comes from an outdated indexer API spec so ignore the content)

And I have gotten a run which successfully no-ops because the branch with generated changes already exists:
https://github.com/Eric-Warehime/go-algorand-sdk/actions/runs/2386615221

Copy link
Contributor

@winder winder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really nice, I had no idea you could make a github action so easily.

Just have some very minor optional suggestions.

.github/actions/sdk-codegen/entrypoint.sh Outdated Show resolved Hide resolved
#
# ============================================================

git config credential.helper '!f() { sleep 1; echo "username=${GITHUB_USER}"; echo "password=${GITHUB_TOKEN}"; }; f'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you could also use the github cli for this:
https://cli.github.com/manual/gh_auth_login

gh auth login --with-token < ${GITHUB_TOKEN}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that seems simpler than what we have here.

- [$INDEXER_SPEC_HASH]($INDEXER_REPO_URL/commit/$INDEXER_SPEC_HASH) - $INDEXER_SPEC_COMMIT_MSG


> **Disclaimer:** I'm just a bot. Feel free to make changes to this pull request as needed."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice touch with this PR body and links to the spec

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks but I can't really take credit as I copied this over from https://github.com/algorand/generator/blob/master/automation/publish.sh#L109 😸

.github/actions/sdk-codegen/Dockerfile Outdated Show resolved Hide resolved
.github/actions/sdk-codegen/Dockerfile Outdated Show resolved Hide resolved
.github/actions/sdk-codegen/entrypoint.sh Outdated Show resolved Hide resolved
.github/actions/sdk-codegen/entrypoint.sh Outdated Show resolved Hide resolved
Eric-Warehime and others added 5 commits May 26, 2022 08:28
Co-authored-by: Will Winder <wwinder.unh@gmail.com>
Co-authored-by: Will Winder <wwinder.unh@gmail.com>
Co-authored-by: Will Winder <wwinder.unh@gmail.com>
Co-authored-by: Will Winder <wwinder.unh@gmail.com>
Co-authored-by: Will Winder <wwinder.unh@gmail.com>
@Eric-Warehime Eric-Warehime merged commit a32bb2a into algorand:master May 27, 2022
@Eric-Warehime Eric-Warehime deleted the sdk-generation branch May 27, 2022 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants