Skip to content

ci: added treefmt workflow to gha and removed from buildbot #3611

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

c4patino
Copy link
Contributor

@c4patino c4patino commented Aug 9, 2025

Seemed like low hanging fruit in #3561

  • Migrates the treefmt foramtting check from buildbot to a dedicated Github Actions workflow.
  • Removes the buildbot treefmt check from flake/dev/fmt.nix to avoid duplicate runs with the new formatter.

Copy link
Member

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

- name: Install Nix
uses: cachix/install-nix-action@v31
- name: Run treefmt check (nix flake check)
run: nix flake check --show-trace
Copy link
Member

Choose a reason for hiding this comment

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

This should build the specific derivation, rather than all checks.

E.g. nix build .#checks.x86_64-linix.treefmt

(It may not be named treefmt, I'm on my phone and can't verify)

Copy link
Contributor Author

@c4patino c4patino Aug 9, 2025

Choose a reason for hiding this comment

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

Oh! I didn't even know you can interact with checks like that. You learn something new everyday I guess. Fixed (it is called treefmt btw; https://github.com/numtide/treefmt-nix/blob/1298185c05a56bff66383a20be0b41a307f52228/flake-module.nix#L73-L75).

Comment on lines 13 to 19
paths-ignore:
- "**.md"
- "**.svg"
- "LICENSE"
- "flake.lock"
Copy link
Member

Choose a reason for hiding this comment

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

Ignoring files should be done by the treefmt configuration, not by GHA.

Although, if this is a true subset of our treefmt excludes then it is okay as a performance optimisation... Assuming we remember to keep it up to date if the treefmt config changes.

Copy link
Contributor Author

@c4patino c4patino Aug 9, 2025

Choose a reason for hiding this comment

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

It is indeed a subset. This was actually intended to ignore changes to the filetypes which are most frequently changed. Minimum here is flake.lock imo since that changes so much.

@c4patino c4patino force-pushed the ci/treefmt branch 3 times, most recently from be9c745 to a6bfab9 Compare August 9, 2025 14:09
@c4patino
Copy link
Contributor Author

Hi @MattSturgeon is there anything else that you need on this?

Copy link
Member

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

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

This is complicated a little by merge queues and "required status checks", however I'm fine merging this initially without adding it as a "required" check.

#3611 can then be responsible for implementing the required checks for PRs and merge queues.

A few minor things to address or discuss below, then I think we can get this merged.

Thanks again!

Comment on lines +11 to +19
push:
branches:
- main
paths-ignore:
- "**.md"
- "**.svg"
- ".gitignore"
- "LICENSE"
- "flake.lock"
Copy link
Member

Choose a reason for hiding this comment

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

We don't really need to do this on push, since we require all changes go through a PR. But we should do it on merge_group so that it runs on the merge queue.

Additionally, we'll need to add this or a meta-job to our “required status checks”; cc @GaetanLepage

I'll try and look into adding a meta-job we can use for this, similar to the no pr failures job in nixpkgs.

Copy link
Member

Choose a reason for hiding this comment

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

I'll handle merge queues and required checks in #3611

For now it is fine to just remove the on: push event.

Suggested change
push:
branches:
- main
paths-ignore:
- "**.md"
- "**.svg"
- ".gitignore"
- "LICENSE"
- "flake.lock"

Comment on lines +5 to +10
paths-ignore:
- "**.md"
- "**.svg"
- ".gitignore"
- "LICENSE"
- "flake.lock"
Copy link
Member

Choose a reason for hiding this comment

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

GHA recently added support for yaml anchors and references, so we can avoid needing to write this list twice.

The first instance should declare the anchor with &ignored, then the second instance can be replaced with a reference to it with *ignored

Suggested change
paths-ignore:
- "**.md"
- "**.svg"
- ".gitignore"
- "LICENSE"
- "flake.lock"
paths-ignore: &ignored
- "**.md"
- "**.svg"
- ".gitignore"
- "LICENSE"
- "flake.lock"

Not relevant if we're removing the on: push event, though.


It'd also be nice to see a comment on this list, cross-referencing it with the treefmt-nix configuration so we remember to keep both in sync.

Choose a reason for hiding this comment

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

GHA recently added support for yaml anchors and references, so we can avoid needing to write this list twice.

whoot? TIL. That's great to hear. Although from looking into it, it seems to be pretty limited :/.

Copy link
Member

@MattSturgeon MattSturgeon Aug 18, 2025

Choose a reason for hiding this comment

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

Support is tracked in actions/runner#1182

I assume most limitations come from workflows not supporting arbitrary unknown keys?

Choose a reason for hiding this comment

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

Arbitrary keys + merge keys were what I used a lot for GitLab. Also GitLab can reference "templates" across files (different syntax, but same concepts). This would be so much better than re-usable workflows or custom actions for code reuse...


jobs:
treefmt:
name: Check formatting with treefmt
Copy link
Member

Choose a reason for hiding this comment

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

This name shows up in the status check list as Workflow name / Job name; in this case Formatting / Check formatting with treefmt.

Bike-shedding the names doesn't block this PR, because we can change them at any time in other PRs. But my personal preference would be to be less verbose and avoid redundancy between workflow & job names.

How about Formatting / treefmt or Lint / formatting or Check / Formatting?

- name: Install Nix
uses: cachix/install-nix-action@v31
- name: Run treefmt check
run: nix build .#checks.x86_64-linux.treefmt
Copy link
Member

Choose a reason for hiding this comment

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

Running with --accept-flake-config will cause the flake config to be used. That's useful here because it configures the nix-community cachix.

Alternatively, we could use a cachix GHA step, like we do in some other workflows. That way we can also push builds to cachix.

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