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

Regenerate index.js with GitHub actions #334

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

rotu
Copy link
Contributor

@rotu rotu commented Sep 4, 2020

I keep forgetting to build with PRs or opening PRs from the github web interface. Worse, index.js depends on the version of packages you have locally, which causes churn. This auto-generates the js file on each commit.

@rotu rotu changed the title Ci build Regenerate index.js with GitHub actions Sep 4, 2020
@rotu rotu force-pushed the ci-build branch 4 times, most recently from 2eef133 to 49cc5a5 Compare September 4, 2020 20:43
@emersonknapp
Copy link
Contributor

emersonknapp commented Sep 4, 2020

This is really interesting - thanks for exploring it. This approach could be generically useful across all typescript Action implementations.

I wonder if instead of trying to commit on the development branch, we could have an Workflow that is triggered on push to the default branch, that builds and writes to a release branch, which is where the marketplace actually reads from. This way instead of modifying PRs, we can just run tests against PRs, then have the release artifact created after merge (and never checked into the development branch)

@rotu
Copy link
Contributor Author

rotu commented Sep 5, 2020

This is really interesting - thanks for exploring it. This approach could be generically useful across all typescript Action implementations.

You betcha!

I wonder if instead of trying to commit on the development branch, we could have an Workflow that is triggered on push to the default branch, that builds and writes to a release branch, which is where the marketplace actually reads from. This way instead of modifying PRs, we can just run tests against PRs, then have the release artifact created after merge (and never checked into the development branch)

I assumed that checking it in in the development branch was a desirable feature so I didn't question this arrangement. Let me give it a whack...

@rotu rotu force-pushed the ci-build branch 2 times, most recently from ed5abd8 to f174716 Compare September 6, 2020 02:15
@rotu
Copy link
Contributor Author

rotu commented Sep 6, 2020

@emersonknapp Done.

@rotu rotu force-pushed the ci-build branch 3 times, most recently from 49b9608 to 0136f93 Compare September 6, 2020 02:39
@rotu rotu marked this pull request as ready for review September 6, 2020 02:39
@rotu rotu requested a review from a team as a code owner September 6, 2020 02:39
@rotu rotu requested review from emersonknapp and dabonnie and removed request for a team September 6, 2020 02:39
@rotu
Copy link
Contributor Author

rotu commented Sep 7, 2020

I like that putting it on a different git ref means you don't have to merge with every push. I don't like that merging a PR isn't the full picture (and that to make this work, I'll have to modify existing tests to not simply use actions/checkout on the merge commit).

@emersonknapp, how do you see this working and how would you like to move forward?

@@ -80,7 +80,7 @@ export async function execBashCommand(
): Promise<number> {
commandPrefix = commandPrefix || "";
const bashScript = `${commandPrefix}${commandLine}`;
const message = log_message || `Invoking "bash -c '${bashScript}'`;
const message = log_message || `Invoking "bash -c '${bashScript}'`;
Copy link
Contributor

Choose a reason for hiding this comment

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

extra spaces in this file intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ha. No - I was only adding whitespace to this file to test the rebuild hook.

@@ -0,0 +1,23 @@
name: "Build"
on: push
Copy link
Contributor

Choose a reason for hiding this comment

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

limit to branches: [master]

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 think I'm not on the same page as you here. The current behavior is to build in a precommit step so that all branches have an up-to-date dist/index.js. Why should we only build some branches?

name: "Build"
on: push
jobs:
test_ros:
Copy link
Contributor

Choose a reason for hiding this comment

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

name appropriate? maybe build_and_commit_to_release

git config user.name "ROS Tooling [bot]"
git add --force dist
git commit --no-verify -m "$commitmsg" --only dist
git push origin --no-verify HEAD:refs/tags/build/${{github.sha}}
Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking we would push to a release branch. It would need a few additional files (action.yml, README, LICENSE) - I think the best way would be to have it be a pure-augmentation of the master branch. So maybe it would look something like

# dist is never checked in on master
npm run build
git checkout release
git rebase master
git add dist/index.js
git commit -m "Build artifacts for ${{ github.sha }}"
git push origin release

We would then only create tags when we actually want to release out a new version of the action, which could be manual or on an otherwise automated schedule. If release naming is confusing then maybe we call the branch staging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It won't do to have a release branch.

  1. That doesn't solve the problem for building PRs.
  2. Workflow runs are not guaranteed to be sequential

We'd basically have to have a shadow build/xxx branch for every xxx branch and ensure that they run in order even when simultaneous commits are run.

@rotu rotu marked this pull request as draft September 8, 2020 20:19
@rotu rotu force-pushed the ci-build branch 5 times, most recently from c582150 to 710e47c Compare September 9, 2020 00:00
@rotu
Copy link
Contributor Author

rotu commented Sep 9, 2020

@emersonknapp I submitted a couple alternatives for how this could work here and none of them seem as straightforward as just committing on the dev branch:
https://github.com/rotu/action-ros-ci/blob/f004fd83e43fcbce7e9641d78cc378dc6c80c48a/.github/workflows/build.yml

I think it might be more productive at this time for either you to take over dev on this or for us to hop on a phone call. I feel like I'm getting frustrated and going nowhere and you have a clearer vision of what would be an acceptable way to move forward here.

@emersonknapp
Copy link
Contributor

Hey @rotu sorry for the slow response. I should have some more time to be able to think about this starting in a couple weeks, if all goes according to plan. I can try to take over on moving it forward then, in the meantime we should probably just continue on with checking in index.js with PRs. It's a bit of an awkward situation, I agree, but I want to make sure we don't do something too awkward as the cure, is all.

@rotu
Copy link
Contributor Author

rotu commented Oct 29, 2020

@emersonknapp Thanks! I would love if you took it over - there are design choices here that I don't think I'm in a position to make

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.

None yet

2 participants