Skip to content

ci: Add test-each-commit task - #28279

Merged
fanquake merged 2 commits into
bitcoin:masterfrom
maflcko:2308-ci-test-each-commit-
Sep 14, 2023
Merged

fanquake merged 2 commits into
bitcoin:masterfrom
maflcko:2308-ci-test-each-commit-

Conversation

@maflcko

@maflcko maflcko commented Aug 16, 2023

Copy link
Copy Markdown
Member

Currently, if a pull request has more than one commit, previous commits may fail to compile, or may fail the tests. This is problematic, because it breaks git-bisect, or worse.

Fix this by adding a CI task for this.

@DrahtBot

DrahtBot commented Aug 16, 2023 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK dergoegge, hebasto, jonatack

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@DrahtBot DrahtBot added the Tests label Aug 16, 2023
@maflcko
maflcko force-pushed the 2308-ci-test-each-commit- branch 5 times, most recently from 05c57bc to 9656b0b Compare August 17, 2023 07:49
@maflcko

maflcko commented Aug 17, 2023

Copy link
Copy Markdown
Member Author

Will squash if there is conceptual agreement (Not sure when this concept last came up, but I think @dergoegge and @achow101 mentioned it?). Review question: Looks like the worst-case runtime is 1 hour per commit, so with GHA at most 6 commits could be tested before a timeout. Maybe a self-hosted worker with a longer timeout would be better?

@dergoegge

Copy link
Copy Markdown
Member

Concept ACK

Maybe a self-hosted worker with a longer timeout would be better?

Probably but I am wondering a bit if these task could end up clogging our self-hosted worker queue and hinder other jobs from running in their regular time?

@maflcko

maflcko commented Aug 17, 2023 •

Copy link
Copy Markdown
Member Author

Probably but I am wondering a bit if these task could end up clogging our self-hosted worker queue and hinder other jobs from running in their regular time?

Right, that is another reason for self-hosted runners, because it is possible to assign a label to them, so that they are task-specific, and not interfere with other tasks. On GHA "free" runners will stop being spun up after n total parallel running tasks.

@dergoegge

Copy link
Copy Markdown
Member

This would be a cirrus self-hosted worker though, right?

@jonatack

Copy link
Copy Markdown
Member

Concept ACK if our CI infra can handle it. I build and run the unit tests on each commit for more critical pulls, or pulls with commits that aren't clearly separate or that look interactive, or those with many commits, but often without also running the functional tests that take longer to run. Having the CI verify this would alert PR authors more quickly and save developer time for everyone.

@jonatack

jonatack commented Aug 17, 2023 •

Copy link
Copy Markdown
Member

often without also running the functional tests that take longer to run

That said, what my build+test checks most often find is a failing build before running any tests. So if infra resources are limited, just build (or build + units) might still catch most of the issues.

@maflcko
maflcko marked this pull request as ready for review August 21, 2023 11:47
@maflcko
maflcko force-pushed the 2308-ci-test-each-commit- branch from 9656b0b to fa568b4 Compare August 21, 2023 11:48
@maflcko

maflcko commented Aug 21, 2023

Copy link
Copy Markdown
Member Author

I think it is fine to use GHA for now, with a limit of 6 commits. This should cover 99% of all pull requests. If there is a need for a self-hosted runner, it can trivially be added later.

@maflcko
maflcko force-pushed the 2308-ci-test-each-commit- branch 3 times, most recently from fae902e to fac0220 Compare August 21, 2023 12:08
@hebasto

hebasto commented Aug 21, 2023

Copy link
Copy Markdown
Member

Concept ACK.

Currently, if a pull request has more than one commit, previous commits may fail to compile, or may fail the tests. This is problematic, because it breaks git-bisect, or worse.

I've encountered such cases during my reviews.

@hebasto

hebasto commented Aug 21, 2023

Copy link
Copy Markdown
Member

On GHA "free" runners will stop being spun up after n total parallel running tasks.

n == 20

@maflcko

maflcko commented Aug 22, 2023

Copy link
Copy Markdown
Member Author

On GHA "free" runners will stop being spun up after n total parallel running tasks.

n == 20

Sure, but as I said, we can use self-hosted runners if and when there is a need. This check will take a few seconds on pulls with one commit (I can reduce this, if needed), which should be the most common type of pull request. Also, there is a limit of 6 hours, so this should be fine as well, unless many pull requests with many commits are pushed to at the same time, in which case there likely is a backlog either way.

@hebasto hebasto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approach ACK fac0220.

What is the way to figure out which commit failed?

Comment thread .github/workflows/ci.yml Resolved
@maflcko

maflcko commented Aug 22, 2023

Copy link
Copy Markdown
Member Author

What is the way to figure out which commit failed?

Compile each commit locally, I guess? See the existing docs on how to do that.

@hebasto

hebasto commented Aug 22, 2023

Copy link
Copy Markdown
Member

What is the way to figure out which commit failed?

Compile each commit locally, I guess? See the existing docs on how to do that.

Yes, it is what is expected from a developer in first place before they push their branch.

But if we add a CI task that tests every commit, it is reasonable, at least for me, to expect it prints a commit hash being tested somewhere.

@maflcko
maflcko force-pushed the 2308-ci-test-each-commit- branch from fac0220 to faed0f4 Compare August 23, 2023 08:28

@hebasto hebasto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK faed0f4ed43e9416eb0620db1943c9ae083a5b50

@maflcko
maflcko requested review from dergoegge and jonatack August 28, 2023 10:48

@jonatack jonatack left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

utACK faed0f4ed43e9416eb0620db1943c9ae083a5b50

@DrahtBot DrahtBot removed the CI failed label Sep 4, 2023
@maflcko
maflcko force-pushed the 2308-ci-test-each-commit- branch from faed0f4 to fa5356c Compare September 4, 2023 16:05
@maflcko

maflcko commented Sep 4, 2023

Copy link
Copy Markdown
Member Author

Small fixup to remove the unused/disabled --interactive flag. Should be trivial to re-ACK.

@dergoegge dergoegge left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

utACK fa5356c

@hebasto hebasto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK fa5356c

Comment thread .github/workflows/ci.yml
env:
MAX_COUNT: '--max-count=6'
steps:
- uses: actions/checkout@v3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fafcd2e

Suggesting to rebase on top of the #28402 and

Suggested change
- uses: actions/checkout@v3
- uses: actions/checkout@v4

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, can be done on the next force push or in the other pull.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

#28402 has been merged; it's not clear to me if this ought to be updated to v4.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah sorry, I forgot it was already merged.

I don't think v3 or v4 are any different, so I'll follow-up with this style nit later.

Comment thread .github/workflows/ci.yml Outdated
Comment on lines +37 to +41
- run: sudo apt install ccache build-essential libtool autotools-dev automake pkg-config bsdmainutils python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libminiupnpc-dev libnatpmp-dev libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y
- run: EDITOR=true git rebase --interactive --exec "./autogen.sh && CC=clang CXX=clang++ ./configure && make clean && make -j $(nproc) check && ./test/functional/test_runner.py -j $(( $(nproc) * 2 ))" $( git log --merges -1 --format='%H' )
- run: sudo apt install clang ccache build-essential libtool autotools-dev automake pkg-config bsdmainutils python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libminiupnpc-dev libnatpmp-dev libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y
# Use clang++, because it is a bit faster and uses less memory than g++
- run: git rebase --exec "echo Running test-one-commit on \$( git log -1 ) && ./autogen.sh && CC=clang CXX=clang++ ./configure && make clean && make -j $(nproc) check && ./test/functional/test_runner.py -j $(( $(nproc) * 2 ))" "$( git log '^'$( git log --merges -1 --format='%H' ) HEAD --format='%H' ${MAX_COUNT} | tail -1 )~1"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fa5356c

Why don't combine unrelated to MAX_COUNT changes into the previous commit?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For review, it may be better to just look at the overall changes. There are two commits, so that the CI can be observed working.

@maflcko

maflcko commented Sep 12, 2023

Copy link
Copy Markdown
Member Author

rfm or is there anything left to be done here?

@jonatack

Copy link
Copy Markdown
Member

Per https://github.com/bitcoin/bitcoin/actions/runs/6075652138/job/16482267917?pr=28279

Running test-one-commit on commit fafcd2e9ef1209d614de5763a2733098537919dd Author: MarcoFalke <*~=`'#}+{/-|&$^[email protected]> Date: Wed Aug 16 16:40:42 2023 +0200 ci: Add test-each-commit task

ACK fa5356c

Modulo one question in #28279 (comment).

@DrahtBot
DrahtBot removed the request for review from jonatack September 13, 2023 21:39
@fanquake
fanquake merged commit 744e0e3 into bitcoin:master Sep 14, 2023
@maflcko
maflcko deleted the 2308-ci-test-each-commit- branch September 14, 2023 09:33
@fanquake

Copy link
Copy Markdown
Member

Looks like this is currently failing for new PRs: https://github.com/bitcoin/bitcoin/actions/runs/6184007676/job/16786866270?pr=28476

Run git rebase --exec "echo Running test-one-commit on \$( git log -1 ) && ./autogen.sh && CC=clang CXX=clang++ ./configure && make clean && make -j $(nproc) check && ./test/functional/test_runner.py -j $(( $(nproc) * 2 ))" "$( git log '^'$( git log --merges -1 --format='%H' ) HEAD --format='%H' ${MAX_COUNT} | tail -1 )~1"
fatal: invalid upstream '~1'
Error: Process completed with exit code 128.

@maflcko

maflcko commented Sep 14, 2023

Copy link
Copy Markdown
Member Author

I guess the issue is that ( git log '^'$( git log --merges -1 --format='%H' ) HEAD --format='%H' ${MAX_COUNT} | tail -1 ) prints nothing for some reason when there is only one commit in the pull request?

Not sure why, because locally it works:

$ git --version 
git version 2.41.0
$ git log -1 --format='%H'
3c99f66f8a10aa4dfc1e85c3a240cc144442eac7
$ ( git log '^'$( git log --merges -1 --format='%H' ) HEAD --format='%H' ${MAX_COUNT} | tail -1 ) 
3c99f66f8a10aa4dfc1e85c3a240cc144442eac7

maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Sep 14, 2023
This reverts commit 744e0e3, reversing
changes made to 8209e86.
fanquake added a commit to bitcoin-core/gui that referenced this pull request Sep 14, 2023
fa2cb2f Revert "Merge bitcoin/bitcoin#28279: ci: Add test-each-commit task" (MarcoFalke)

Pull request description:

  This should unbreak the GHA CI for now, and allow someone to fix the task in a follow-up. The issue is bitcoin/bitcoin#28279 (comment) .

  If no one fixes it, it can be replaced by a Cirrus CI self-hosted runner.

ACKs for top commit:
  sipa:
    ACK fa2cb2f
  dergoegge:
    ACK fa2cb2f

Tree-SHA512: d9c70915b3fb676f44054cee8033286910682ff6819d4ee71e432f7efb3043a0a9507f0052b6c24e3b0c431875f6337b1adccc5b48432970d7c29c6d6b00a2d7
Frank-GER pushed a commit to syscoin/syscoin that referenced this pull request Sep 19, 2023
fa5356c ci: Limit test-each-commit to --max-count=6 (MarcoFalke)
fafcd2e ci: Add test-each-commit task (MarcoFalke)

Pull request description:

  Currently, if a pull request has more than one commit, previous commits may fail to compile, or may fail the tests. This is problematic, because it breaks git-bisect, or worse.

  Fix this by adding a CI task for this.

ACKs for top commit:
  jonatack:
    ACK fa5356c
  dergoegge:
    utACK fa5356c
  hebasto:
    ACK fa5356c

Tree-SHA512: 304eff5545501ee499b881f0b0a0c1fe32a7c9f00d96b45bba731af08ac5ca917cef223f5c3d346e30c11a3e6e12e1da297929d3caea9644f3ec1de25dd97c37
Frank-GER pushed a commit to syscoin/syscoin that referenced this pull request Sep 19, 2023
This reverts commit 744e0e3, reversing
changes made to 8209e86.
fanquake added a commit that referenced this pull request Sep 19, 2023
27b636a ci: Reintroduce fixed "test-each-commit" job (Hennadii Stepanov)

Pull request description:

  This is a fixed version of #28279:
  > Currently, if a pull request has more than one commit, previous commits may fail to compile, or may fail the tests. This is problematic, because it breaks git-bisect, or worse.
  >
  > Fix this by adding a CI task for this.

  The new job checks at most 6 commits of a pull request, excluding the top one.

  The maximum number of tested commits is 6, which derives from the time [constrains](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes).

  For historical context, please see:
  - #28279
  - #28477
  - #28478

  **A note for reviewers:** To test scripts locally, ensure that you works with a _shallow_ copy of the repo.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 27b636a

Tree-SHA512: 0c69ced13509fa0ed2dd6ef13f4c710d678e31b294b6318b59ab1ba899086a71b5c893aaf70e143036349329167bf8e16bdca319b2c761e2aef6222d0db1470c
Frank-GER pushed a commit to syscoin/syscoin that referenced this pull request Sep 25, 2023
27b636a ci: Reintroduce fixed "test-each-commit" job (Hennadii Stepanov)

Pull request description:

  This is a fixed version of bitcoin#28279:
  > Currently, if a pull request has more than one commit, previous commits may fail to compile, or may fail the tests. This is problematic, because it breaks git-bisect, or worse.
  >
  > Fix this by adding a CI task for this.

  The new job checks at most 6 commits of a pull request, excluding the top one.

  The maximum number of tested commits is 6, which derives from the time [constrains](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes).

  For historical context, please see:
  - bitcoin#28279
  - bitcoin#28477
  - bitcoin#28478

  **A note for reviewers:** To test scripts locally, ensure that you works with a _shallow_ copy of the repo.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 27b636a

Tree-SHA512: 0c69ced13509fa0ed2dd6ef13f4c710d678e31b294b6318b59ab1ba899086a71b5c893aaf70e143036349329167bf8e16bdca319b2c761e2aef6222d0db1470c
janus pushed a commit to BitgesellOfficial/bitgesell that referenced this pull request Apr 1, 2024
This reverts commit 744e0e36703e26d06bc5cd1ef36a1c8568e71d05, reversing
changes made to 8209e86eeb4ceb6dd0e06c45fb3c799bb42834ab.
@bitcoin bitcoin locked and limited conversation to collaborators Dec 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants