Skip to content

Check each commit at least builds in CI #696

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,29 @@ jobs:
token: f421b687-4dc2-4387-ac3d-dc3b2528af57
fail_ci_if_error: true

check_commits:
runs-on: ubuntu-latest
env:
TOOLCHAIN: stable
steps:
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install Rust ${{ env.TOOLCHAIN }} toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.TOOLCHAIN }}
override: true
profile: minimal
- name: Fetch full tree and rebase on upstream
run: |
git remote add upstream https://github.com/rust-bitcoin/rust-lightning
git fetch upstream
git rebase upstream/main
- name: For each commit, run cargo check (including in fuzz)
run: ci/check-each-commit.sh upstream/main

fuzz:
runs-on: ubuntu-latest
env:
Expand Down
6 changes: 6 additions & 0 deletions ci/check-compiles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
set -e
set -x

Choose a reason for hiding this comment

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

The current progress is hidden as the rebase progresses. I tested a few things locally and I think something like git log -1 --oneline at the top here is enough to let me know where we are in the stack.

I also really like the side-effect of being able to fix my issue in the middle of a rebase instead of having to create a temp branch, fix, rebase.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, if it fails it should leave it where it was when it failed, no?

Choose a reason for hiding this comment

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

Yes, when it fails it leaves it in the rebase where I can make changes which is great.

When it doesn't fail it is still nice to see the progress which explains the --oneline

echo Testing $(git log -1 --oneline)
cargo check
cd fuzz && cargo check --features=stdin_fuzz
15 changes: 15 additions & 0 deletions ci/check-each-commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

Choose a reason for hiding this comment

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

Here are the use cases as I see them:

As a developer, I want to know that every patch in my stack builds and passes "all?" tests against some remote before I push to my branch so I don't waste time later and have to backtrack when CI finally catches up to tell me I made a mistake.

As a CI tool, I want to verify every commit against main and throw an error if a single commit doesn't build so future rebase and git bisect can work cleanly.

From a developer point of view, I would love to use this tool against my own upstream branches for dependant PRs and in cases where my branch might not be in the most hygienic state, but I still get a lot of value in making sure everything builds with the current state of the world.

I also don't really want rebase done for me since I would like to control when those actions happen in the event I am in a non-clean state.

What about an API like this that allows the users to control the remotes that are used? Makes the auto-complete go away, too.

CI:
Make sure all commits pass against main. I'm not sure the CI context w.r.t. remotes available, but this is the idea.
check-each-commit.sh main

Dev:
As a dev I want to see if my current work in progress is clean against origin
check-each-commit.sh origin/main

As a dev I want to see if my current work in progress is clean against a dependant branch
check-each-commit.sh origin/pre-existing-dependant-branch

As a dev I want to see if my current work in progress is clean against upstream/main and ready for PR.
git rebase upstream/main - manual
check-each-commit.sh upstream/main

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, I suppose we could just always do a git log from a given point, but the script as-is doesn't rebase for you, it just makes sure you're built directly on top of upstream/main.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Errr, ok, it wasn't supposed to.

if [ "$1" = "" ]; then
echo "USAGE: $0 remote/head_branch"
echo "eg $0 upstream/main"
exit 1
fi

set -e
set -x

if [ "$(git log --pretty="%H %D" | grep "^[0-9a-f]*.* $1")" = "" ]; then
echo "It seems like the current checked-out commit is not based on $1"
exit 1
fi
git rebase --exec ci/check-compiles.sh $1