Skip to content

Commit 26ef084

Browse files
authored
CI: only build without lockfile if dependencies changed (#2643)
* CI: build without lockfile if dependencies changed - Makes this job less noisy if dependencies weren't modified. - Comment on the PR in case of failure to communicate that PR can still be merged. - Add badge to readme to make failures on main or scheduled builds visible. * CI: enable path gating
1 parent 0ae9d7c commit 26ef084

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

.github/workflows/build-without-lockfile.yml

+53
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
schedule:
1212
- cron: "0 0 * * 1"
1313
pull_request:
14+
# Only run on PRs if dependencies were modified.
15+
paths:
16+
- "**/Cargo.toml"
17+
- "**/Cargo.lock"
1418
workflow_dispatch:
1519

1620
concurrency:
@@ -33,3 +37,52 @@ jobs:
3337
run: |
3438
cargo generate-lockfile
3539
cargo check --all-targets
40+
41+
- name: Comment on PR
42+
uses: actions/github-script@v7
43+
if: failure() && github.event_name == 'pull_request'
44+
with:
45+
github-token: ${{secrets.GITHUB_TOKEN}}
46+
script: |
47+
const issue_number = context.issue.number;
48+
const owner = context.repo.owner;
49+
const repo = context.repo.repo;
50+
const runUrl = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
51+
52+
const commentTitle = "Unable to build without Cargo.lock file"
53+
const commentBody = `${commentTitle}.
54+
55+
This means that after this change 3rd party projects may have
56+
difficulties using crates in this repo as a dependency. If this
57+
isn't easy to fix please open an issue so we can fix it later.
58+
59+
For the first failing build see: ${runUrl}
60+
61+
To reproduce locally run
62+
63+
\`\`\`
64+
cargo generate-lockfile
65+
cargo check --all-targets
66+
\`\`\`
67+
68+
This PR can still be merged.`;
69+
70+
// Fetch existing comments
71+
const { data: comments } = await github.rest.issues.listComments({
72+
owner,
73+
repo,
74+
issue_number,
75+
});
76+
77+
// Find existing comment
78+
const existingComment = comments.find(c => c.body.startsWith(commentTitle));
79+
if (!existingComment) {
80+
await github.rest.issues.createComment({
81+
owner,
82+
repo,
83+
issue_number,
84+
body: commentBody
85+
});
86+
} else {
87+
console.log("Already commented.")
88+
}

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
[![Lint](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/lint.yml/badge.svg)](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/lint.yml)
88
[![Audit](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/audit.yml/badge.svg)](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/audit.yml)
99
[![Ubuntu](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/ubuntu-install-without-nix.yml/badge.svg)](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/ubuntu-install-without-nix.yml)
10+
[![Build without lockfile](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/build-without-lockfile.yml/badge.svg)](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/build-without-lockfile.yml)
1011
[![Coverage Status](https://coveralls.io/repos/github/EspressoSystems/espresso-sequencer/badge.svg?branch=main)](https://coveralls.io/github/EspressoSystems/espresso-sequencer?branch=main)
1112

1213
The Espresso Sequencer offers rollups credible neutrality and enhanced interoperability, without compromising on scale.

0 commit comments

Comments
 (0)