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

Add CI shell scripts #4

Merged
merged 1 commit into from
May 7, 2024
Merged

Conversation

tcharding
Copy link
Member

@tcharding tcharding commented May 2, 2024

We would like to put all the CI scripts in a single place instead of copied to each repository.

Add a ci/ directory and in it a run_task.sh script as well as auxilary scripts required. Include a README to document the directory.

When the following three PRs have green CI runs then I believe we can merge this. And then I will update each of the PRs to use this repo and master (instead my fork and the PR branch 05-02-ci).

All green with one minute till my End Of Day - BOOM!

@apoelstra
Copy link
Member

I guess this is a draft til we nail down why it doesn't work on rust-bitcoincore-rpc?

Otherwise ACK.

Copy link
Contributor

@storopoli storopoli left a comment

Choose a reason for hiding this comment

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

Some comments in the README.
The script looks fine.

ci/README.md Outdated

## Lock files

All repositories MUST include a minimal and recent lock file:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
All repositories MUST include a minimal and recent lock file:
All repositories MUST include a minimal and a recent lock file:

It is two right? Not one that is minimal and recent?

Copy link
Member Author

Choose a reason for hiding this comment

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

Lol you got me, and English is even my first language :)

ci/README.md Outdated
- `Cargo-recent.lock`: A manifest with some recent versions numbers that pass CI.
- `Cargo-minimal.lock`: A manifest with some minimal version numbers that pass CI.

The `run_taks.sh` script invokes copies each to `Cargo.toml` and uses `cargo --locked`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The `run_taks.sh` script invokes copies each to `Cargo.toml` and uses `cargo --locked`.
The `run_tasks.sh` script will overwrite each of these `.lock` files to `Cargo.toml` and uses `cargo --locked`.

That was ambiguous. I tried to make more direct and clear.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice, this made me find that this text is all wrong. lock files are expected to be handled in the workflow not in the run_task.sh script.

If MSRV build requires pinning of any dependencies then a `contrib/pin.sh` script should
be present in the repository, for example:

```yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
```yaml
```bash

this is not yaml

Copy link
Member Author

Choose a reason for hiding this comment

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

I've removed pinning all together now.

ci/README.md Outdated
run: echo "nightly_version=$(cat nightly-version)" >> $GITHUB_OUTPUT
```

## run_task.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
## run_task.sh
## `run_task.sh`

ci/README.md Outdated

## run_task.sh

Used by github actions to run a CI job, can also be run from the terminal.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Used by github actions to run a CI job, can also be run from the terminal.
Used by Github actions to run a CI job, can also be run from the terminal.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sometimes I write GitHub but a little bit of me hurts at how much we rely on them so sometimes I use the slightly insulting "github", kind of like writing "god" with a small g - childish I know.

Copy link
Contributor

Choose a reason for hiding this comment

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

In other PRs in this "spawn" I've seen GitHub as well

Copy link
Member Author

@tcharding tcharding May 2, 2024

Choose a reason for hiding this comment

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

lolz, "spawn" I love it. Took me almost all day yesterday to spawn this new CI setup.

ci/README.md Outdated
EXAMPLES=""
```

`EXAMPLES` string is of format:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
`EXAMPLES` string is of format:
`EXAMPLES` string is of format:

empty line around fenced blocks

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it!

ci/README.md Outdated
Comment on lines 123 to 124
Additional, crate specific, tests can be put in an optional `contrib/extra_tests.sh` file, which is
expected to be a normal `bash` file (including exit non-zero on failure).
Copy link
Contributor

Choose a reason for hiding this comment

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

What "normal bash file means".

A file with a shebang like !#/usr/bin/env bash?
Or a file with .sh extension that can be called with bash file.sh?
Does it need to be chmod +x?
Can I use POSIX sh only or does it need to be a "bash" only file?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ha ha, I meant "normal" as in the same as all the other ones in this repo - that was, now I read it, totally unclear. Will fix, thanks.

@tcharding
Copy link
Member Author

I guess this is a draft til we nail down why it doesn't work on rust-bitcoincore-rpc?

Yes and until I fully understand pinning vs lock files.

What I don't understand is how we have a recent lock file that does not work with msrv. It seems Cargo-recent.lock include oldish versions that work with msrv because then its not that recent. Should we provide 3 lock files:

  • Cargo-minimal.lock (works with msrv and stable)
  • Cargo-recent-msrv.lock works unmodified with cargo +1.56.1 check
  • Cargo-recent.lock does not necessarily work with msrv but is actually recent

Or am I misunderstanding something?

@tcharding
Copy link
Member Author

FWIW I just added CI to the new rust-chf using this branch and it was easy peasy - that's a win.

@tcharding tcharding force-pushed the 05-02-ci branch 3 times, most recently from 3d9ebbe to b831ab2 Compare May 3, 2024 01:22
We would like to put all the CI scripts in a single place instead of
copied to each repository.

Add a `ci/` directory and in it a `run_task.sh` script as well as
auxilary scripts required. Include a README to document the directory.
@tcharding
Copy link
Member Author

ChatGPT is killing it today, finds bugs in bash scripts like a boss.

@tcharding
Copy link
Member Author

Today I re-worked the docs quite a bit. And changed the script so that it now handles duplicate dependencies (for use during upgrade).

@tcharding
Copy link
Member Author

tcharding commented May 3, 2024

Just quietly, this rust-bitcoin-maintainer-tools idea you had @apoelstra is f**cking sick.

@tcharding tcharding marked this pull request as ready for review May 3, 2024 04:59
@tcharding tcharding changed the title WIP: Add CI shell scripts Add CI shell scripts May 3, 2024
@storopoli
Copy link
Contributor

ChatGPT is killing it today, finds bugs in bash scripts like a boss.

Have you also ever experimented with shellcheck?

@tcharding
Copy link
Member Author

Yeah I try to run that on all scripts, we don't in CI though. Perhaps we should. And with all this yaml work just now I came across yamllint which taught me a few things.

@storopoli
Copy link
Contributor

And with all this yaml work just now I came across yamllint which taught me a few things.

The yaml document from hell

This is a fun read!

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

utACK 72e42b3

My one comment is that we should probably have nightly and stable do some checks that you are actually invoking the script with a nightly/stable compiler. Or alternately, we should combine the two of them into a single item and expect the user to choose a compiler out of band. (But I'd rather keep them separate, and eventually pull the nightly-version stuff into here.)

Either way can wait for a followup PR.

@apoelstra apoelstra merged commit b2ac115 into rust-bitcoin:master May 7, 2024
@tcharding
Copy link
Member Author

Yeah during one iteration somewhere I was passing the toolchain to the build_and_run shell function and using it with cargo so that the cargo command would fail if it was called with the wrong toolchain. Not too hard to add, I'll keep it in mind.

@tcharding tcharding deleted the 05-02-ci branch May 7, 2024 20:12
apoelstra added a commit to rust-bitcoin/rust-bitcoin that referenced this pull request May 9, 2024
6def5bc CI: Use run_task from maintainer tools (Tobin C. Harding)
c5af528 CI: Add docs and document start (Tobin C. Harding)
62ba105 CI: Use correct spacing (Tobin C. Harding)
0c0e881 CI: Add README file (Tobin C. Harding)
44cb225 CI: Add sanitizer script (Tobin C. Harding)
3407257 CI: Add WASM script (Tobin C. Harding)
cc14edf CI: Run the schemars job directly using cargo (Tobin C. Harding)
1fb12e1 CI: Remove recent from schemars job (Tobin C. Harding)
8d7117b CI: Use original name (Tobin C. Harding)

Pull request description:

  First we do some clean up, then we pull the stuff that is specific to this repo out into separate tests, then as the last patch we switch over to use the new script for `rust-bitcoin-maintainer-tools` that was introduced in rust-bitcoin/rust-bitcoin-maintainer-tools#4.

ACKs for top commit:
  apoelstra:
    ACK 6def5bc

Tree-SHA512: 70105d455294d49deb43461958435096d074d19ea8d9adc7036e15d74dfdab466f04b1d9e934574077ca0c32a6fe77d0e5aa11068d8c4d51acef634591227d33
apoelstra added a commit to rust-bitcoin/rust-bitcoincore-rpc that referenced this pull request May 9, 2024
93602a9 CI: Use script from rust-bitcoin-maintainer-tools (Tobin C. Harding)
41c457e CI: Reduce indentation (Tobin C. Harding)

Pull request description:

  Use the new maintainer tools test script we created in rust-bitcoin/rust-bitcoin-maintainer-tools#4

  For this repo usage of the script is a big change, the coverage does not change that much except we run one example instead of just building it and we run cargo using `cargo --locked` whereas currently for stable and nightly the dependencies used are much more recent.

  FTR:

  - We do not format (exists in current ci but is not enforced because of bug is `test.sh`)
  - We just build the examples (same as current behaviour)
  - We do not lint (same as current behaviour)
  - We do not pin, instead we commit a lock file with working dependency versions. Please note that there are two lock files as is customary but in this repo I was unable to get a set of more recent dependencies to build so both files are the same.

  This replaces #338

ACKs for top commit:
  apoelstra:
    ACK 93602a9

Tree-SHA512: 67a298fddb670714fd27736341b2aa922208d45baadffefc7a9b8dc2ebd48d551b8fc36426bea06d89cddd901ae7feeaf0ebe16ec4668cc3066056f9bb6cd580
tcharding added a commit to tcharding/rust-miniscript that referenced this pull request Aug 10, 2024
We don't want to pull the maintainer tools repo from master otherwise we
cannot patch it, we should use a specific revision.

This was an oversite in the original work when introducing the
maintainer tools `run_task` script.

Use commit:

b2ac115 Merge rust-bitcoin/rust-bitcoin-maintainer-tools#4: Add CI shell scripts
apoelstra added a commit to rust-bitcoin/rust-miniscript that referenced this pull request Aug 11, 2024
dc7ed26 CI: Use specific revision of maintainer-tools (Tobin C. Harding)

Pull request description:

  We don't want to pull the maintainer tools repo from master otherwise we cannot patch it, we should use a specific revision.

  This was an oversite in the original work when introducing the maintainer tools `run_task` script.

  Use commit:

  b2ac115 Merge rust-bitcoin/rust-bitcoin-maintainer-tools#4: Add CI shell scripts

ACKs for top commit:
  sanket1729:
    ACK dc7ed26
  apoelstra:
    ACK dc7ed26 successfully ran local tests; though once it stabilizes a bit we may want to start adding tags to maintainer-tools (maybe with just the date) to make it more visually obvious when we get out of date

Tree-SHA512: d6e7f3713c5e0f93361fd2b9ff91c3d391b929d2bfb6e31fa0e706748b1ab63ee6115fb0c31a490003e826778f441c3a8126e63484459b2bbf7d3375f51d22fa
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.

3 participants