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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/treefmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Formatting

on:
pull_request:
paths-ignore:
- "**.md"
- "**.svg"
- ".gitignore"
- "LICENSE"
- "flake.lock"
Comment on lines +5 to +10
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...

push:
branches:
- main
paths-ignore:
- "**.md"
- "**.svg"
- ".gitignore"
- "LICENSE"
- "flake.lock"
Comment on lines +11 to +19
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"


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?

runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- 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.

4 changes: 0 additions & 4 deletions flake/dev/fmt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
perSystem =
{ config, pkgs, ... }:
{
ci.buildbot = {
inherit (config.checks) treefmt;
};

treefmt.config = {
projectRootFile = "flake.nix";
flakeCheck = true;
Expand Down