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

Setup action to create a Pull Request that will trigger publishing to npm when merged #6

Merged
merged 13 commits into from
Jan 9, 2023

Conversation

joewagner
Copy link
Contributor

No description provided.

# The can be run manually via the github website if needed.
# Normally the go-tableland repo should run an action that triggers
# this to run when there is a release of the Validator.
name: Release PR manual run
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is nearly the same workflow as release-pr.yml, but it enables using the github UI to manually create and publish a version of the validator binaries. We can potentially remove this in the long run, but for now it should be convenient to fix any failures in runs of the release pr that will be triggered automatically.

- name: Setup Node Environment ⬢
uses: actions/setup-node@v3
with:
node-version: 18
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using node 18. This is required because the build script uses web streams and fetch.

Copy link
Member

Choose a reason for hiding this comment

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

Ah gotcha

run: npm install

- name: Build 🔧
run: npm run build
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The npm run build script is where the actual binaries are being downloaded unzipped and committed to git.

Copy link
Member

Choose a reason for hiding this comment

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

Why do we want to commit them, versus just including them in the build?

Copy link
Contributor Author

@joewagner joewagner Jan 3, 2023

Choose a reason for hiding this comment

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

The idea is that we can both have a automated build release process, and still have a chance to manually build if needed.
e.g. If someone on the team wants to build a bin for there Apple M1 they can do that.

name: Create Release PR
with:
# TODO: I need help setting up permissions for this
github-token: ${{secrets.TEXTILEIO_MACHINE_ACCESS_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.

Not sure how this secret gets added. cc: @asutula

Copy link
Member

Choose a reason for hiding this comment

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

We have it as an org wide secret. So if we have already added it and named it that, you can access it here.

src/build.ts Outdated
console.log(
`installing validator binaries: ${platarchs
.map((pa) => `${pa.name}${pa.filetype}`)
.join(", ")} for version: ${version as string}`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure exactly why, but the ts compiler is complaining unless I use version as string 😞

Copy link
Member

Choose a reason for hiding this comment

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

This is because in new versions of ts, it doesn't like having anything other than a strict string in formatted strings. So you need to explicitly define it to be string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried defining the return type as a string, but I think that the cjs/ems module specific files aren't letting the ts compiler know.
ref: https://github.com/tablelandnetwork/js-validator/pull/6/files#diff-7203482ae83495c0be48d2b5a97a8e4294ed314141d5c047d9ade6347feb8f63

src/build.ts Outdated
console.log(`fetching: ${url}`);

const res = await fetch(url);
// TODO: Seems to be a bug in the fetch typings?
// @ts-ignore
// @ts-expect-error
const downloadReadstream = Readable.fromWeb(res.body);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found a few other reports of this, and I think that this api is so new the typings aren't figured out quite yet.

@joewagner joewagner marked this pull request as ready for review January 3, 2023 00:21
@joewagner joewagner requested a review from asutula January 3, 2023 00:21
carsonfarmer
carsonfarmer previously approved these changes Jan 3, 2023
Copy link
Member

@carsonfarmer carsonfarmer left a comment

Choose a reason for hiding this comment

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

I left a few comments in here with questions and minor nits and concerns. I've still going to approve this though because I think you could merge "as is" and we'd be fine!

@@ -23,7 +23,7 @@ jobs:
- name: Setup Node Environment ⬢
uses: actions/setup-node@v1
with:
node-version: 16
node-version: 18
Copy link
Member

Choose a reason for hiding this comment

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

should we be using a version "matrix" now? it might be nice to support testing on 16-18?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thats a good idea. If you're good with it lets scope a different piece of work build better tests and run them on all the different combos of system + node version

Copy link
Member

Choose a reason for hiding this comment

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

Awesome, we should probably just add that matrix setup to ts-template and use that across the board for tests etc.

- name: Setup Node Environment ⬢
uses: actions/setup-node@v3
with:
node-version: 18
Copy link
Member

Choose a reason for hiding this comment

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

Ah gotcha

with:
node-version: 18

- name: Update version in package.json
Copy link
Member

Choose a reason for hiding this comment

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

Wait, should we be using this in our other repos? This seems like it solves some problems we've had with trying to publish and update package.json based on a git tag?!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like that idea, It's a pretty simple and it could save a step

Copy link
Member

Choose a reason for hiding this comment

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

Awesome, ok, let's add this to ts-template, and then also into js-tableland and friends. Seems like a nicer pattern than I was able to come up with!

Copy link
Member

Choose a reason for hiding this comment

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

run: npm install

- name: Build 🔧
run: npm run build
Copy link
Member

Choose a reason for hiding this comment

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

Why do we want to commit them, versus just including them in the build?

name: Create Release PR
with:
# TODO: I need help setting up permissions for this
github-token: ${{secrets.TEXTILEIO_MACHINE_ACCESS_TOKEN}}
Copy link
Member

Choose a reason for hiding this comment

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

We have it as an org wide secret. So if we have already added it and named it that, you can access it here.

src/build.ts Outdated
console.log(
`installing validator binaries: ${platarchs
.map((pa) => `${pa.name}${pa.filetype}`)
.join(", ")} for version: ${version as string}`
Copy link
Member

Choose a reason for hiding this comment

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

This is because in new versions of ts, it doesn't like having anything other than a strict string in formatted strings. So you need to explicitly define it to be string.

@joewagner
Copy link
Contributor Author

Ended up making a few more changes to how this works to streamline things.

There is now only one workflow, which can be triggered via the go tableland binaries.yml workflow, or manually via the github ui.
This repo will need access to secrets.TEXTILEIO_MACHINE_ACCESS_TOKEN I believe that is setup now, but I can't tell for sure.
@asutula @carsonfarmer when you have a chance please look this over again 🙏

@joewagner joewagner requested a review from carsonfarmer January 5, 2023 00:48
@joewagner
Copy link
Contributor Author

cc: @carsonfarmer I made a few updates after your first review, and this needs another 👍 before merge

Copy link
Member

@carsonfarmer carsonfarmer left a comment

Choose a reason for hiding this comment

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

Updates look good @joewagner.

with:
node-version: 18

- name: Update version in package.json
Copy link
Member

Choose a reason for hiding this comment

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

@joewagner joewagner merged commit 572aa82 into main Jan 9, 2023
@joewagner joewagner deleted the joe/release branch January 9, 2023 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants