Skip to content

Commit

Permalink
chore: pin forge-std in tests + CI job to bump it (foundry-rs#8308)
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr authored Jun 30, 2024
1 parent d96955d commit 82c0404
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/bump-forge-std.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Daily CI job to update forge-std version used for tests if new release has been published

name: bump-forge-std

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
update-tag:
name: update forge-std tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Fetch and update forge-std tag
run: curl 'https://api.github.com/repos/foundry-rs/forge-std/tags' | jq '.[0].commit.sha' -jr > testdata/forge-std-rev
- name: Create pull request
uses: peter-evans/create-pull-request@v5
with:
commit-message: "chore: bump forge-std version used for tests"
title: "chore(tests): bump forge-std version"
body: |
New release of forge-std has been published, bump forge-std version used in tests. Likely some fixtures need to be updated.
branch: chore/bump-forge-std
11 changes: 11 additions & 0 deletions crates/test-utils/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ use std::{

static CURRENT_DIR_LOCK: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));

/// The commit of forge-std to use.
const FORGE_STD_REVISION: &str = include_str!("../../../testdata/forge-std-rev");

/// Stores whether `stdout` is a tty / terminal.
pub static IS_TTY: Lazy<bool> = Lazy::new(|| std::io::stdout().is_terminal());

Expand Down Expand Up @@ -250,6 +253,14 @@ pub fn initialize(target: &Path) {
eprintln!("- initializing template dir in {}", prj.root().display());

cmd.args(["init", "--force"]).assert_success();
// checkout forge-std
assert!(Command::new("git")
.current_dir(prj.root().join("lib/forge-std"))
.args(["checkout", FORGE_STD_REVISION])
.output()
.expect("failed to checkout forge-std")
.status
.success());
cmd.forge_fuse().args(["build", "--use", SOLC_VERSION]).assert_success();

// Remove the existing template, if any.
Expand Down
1 change: 1 addition & 0 deletions testdata/forge-std-rev
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8948d45d3d9022c508b83eb5d26fd3a7a93f2f32

0 comments on commit 82c0404

Please sign in to comment.