Skip to content

Pull in nightly rust-fmt, use vid rustfmt.toml (#2700) #1515

Pull in nightly rust-fmt, use vid rustfmt.toml (#2700)

Pull in nightly rust-fmt, use vid rustfmt.toml (#2700) #1515

name: Build without committed Cargo.lock
on:
push:
branches:
- main
- release-*
tags:
# YYYYMMDD
- "20[0-9][0-9][0-1][0-9][0-3][0-9]*"
schedule:
- cron: "0 0 * * 1"
pull_request:
# Only run on PRs if dependencies were modified.
paths:
- "**/Cargo.toml"
- "**/Cargo.lock"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-ignore-lockfile:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Enable Rust Caching
uses: Swatinem/rust-cache@v2
with:
prefix-key: v1-rust
- name: Build without committed Cargo.lock
run: |
cargo generate-lockfile
cargo check --all-targets
- name: Comment on PR
uses: actions/github-script@v7
if: failure() && github.event_name == 'pull_request'
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const issue_number = context.issue.number;
const owner = context.repo.owner;
const repo = context.repo.repo;
const runUrl = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
const commentTitle = "Unable to build without Cargo.lock file"
const commentBody = `${commentTitle}.
This means that after this change 3rd party projects may have
difficulties using crates in this repo as a dependency. If this
isn't easy to fix please open an issue so we can fix it later.
For the first failing build see: ${runUrl}
To reproduce locally run
\`\`\`
cargo generate-lockfile
cargo check --all-targets
\`\`\`
This PR can still be merged.`;
// Fetch existing comments
const { data: comments } = await github.rest.issues.listComments({
owner,
repo,
issue_number,
});
// Find existing comment
const existingComment = comments.find(c => c.body.startsWith(commentTitle));
if (!existingComment) {
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: commentBody
});
} else {
console.log("Already commented.")
}