ci: request subsystem maintainers review (#1053)
Link: https://github.com/nix-community/stylix/pull/1053 Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com> Reviewed-by: Daniel Thwaites <danth@danth.me> Reviewed-by: Matt Sturgeon <matt@sturgeon.me.uk> Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
This commit is contained in:
parent
4bfd32c8f9
commit
b4e1daad3b
4 changed files with 101 additions and 1 deletions
81
.github/workflows/request-reviewers.yml
vendored
Normal file
81
.github/workflows/request-reviewers.yml
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
||||||
|
---
|
||||||
|
name: Request Reviewers
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types: [opened, ready_for_review, reopened, synchronize]
|
||||||
|
paths:
|
||||||
|
- 'modules/'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
request-reviewers:
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
if: vars.APP_ID
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4.2.2
|
||||||
|
with:
|
||||||
|
ref: ${{ github.base_ref }}
|
||||||
|
|
||||||
|
- uses: cachix/install-nix-action@v31
|
||||||
|
|
||||||
|
- uses: cachix/cachix-action@v16
|
||||||
|
with:
|
||||||
|
name: nix-community
|
||||||
|
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- uses: actions/create-github-app-token@v2
|
||||||
|
id: app-token
|
||||||
|
with:
|
||||||
|
app-id: ${{ vars.APP_ID }}
|
||||||
|
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||||
|
permission-contents: read
|
||||||
|
permission-pull-requests: write
|
||||||
|
|
||||||
|
- run: nix build .#subsystem-maintainers
|
||||||
|
|
||||||
|
- id: get-reviewers
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
MAX_REVIEWERS: 5
|
||||||
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||||
|
run: |
|
||||||
|
printf \
|
||||||
|
'reviewers=%s\n' \
|
||||||
|
"$(
|
||||||
|
gh pr diff --name-only "$PR_NUMBER" |
|
||||||
|
jq \
|
||||||
|
--argjson max_reviewers "$MAX_REVIEWERS" \
|
||||||
|
--raw-input \
|
||||||
|
--raw-output \
|
||||||
|
--slurp \
|
||||||
|
--slurpfile maintainers result '
|
||||||
|
($maintainers[0] | keys_unsorted) as $subsystems |
|
||||||
|
split("\n") as $changed_files |
|
||||||
|
[
|
||||||
|
$changed_files[] as $changed_file |
|
||||||
|
(
|
||||||
|
$maintainers[0][
|
||||||
|
$subsystems[] |
|
||||||
|
select(
|
||||||
|
. as $subsystem |
|
||||||
|
$changed_file |
|
||||||
|
startswith($subsystem)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)[]
|
||||||
|
] |
|
||||||
|
unique |
|
||||||
|
if length <= $max_reviewers then
|
||||||
|
. | join(",")
|
||||||
|
else
|
||||||
|
""
|
||||||
|
end
|
||||||
|
'
|
||||||
|
)" \
|
||||||
|
>>"$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- uses: AveryCameronUofR/add-reviewer-gh-action@1.0.3
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
reviewers: ${{ steps.get-reviewers.outputs.reviewers }}
|
||||||
|
|
@ -4,7 +4,8 @@
|
||||||
./dev-shell.nix
|
./dev-shell.nix
|
||||||
./packages.nix
|
./packages.nix
|
||||||
./pre-commit.nix
|
./pre-commit.nix
|
||||||
./treefmt.nix
|
|
||||||
./public-and-dev-version-consistency.nix
|
./public-and-dev-version-consistency.nix
|
||||||
|
./subsystem-maintainers.nix
|
||||||
|
./treefmt.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
17
flake/dev/subsystem-maintainers.nix
Normal file
17
flake/dev/subsystem-maintainers.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
{
|
||||||
|
perSystem =
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
packages.subsystem-maintainers = pkgs.writeText "subsystem-maintainers" (
|
||||||
|
lib.pipe ../../stylix/meta.nix [
|
||||||
|
(lib.flip pkgs.callPackage { })
|
||||||
|
(lib.mapAttrs (
|
||||||
|
_: meta: map (maintainer: maintainer.github) (meta.maintainers or [ ])
|
||||||
|
))
|
||||||
|
(lib.mapAttrs' (name: lib.nameValuePair "modules/${name}/"))
|
||||||
|
builtins.toJSON
|
||||||
|
]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
{
|
{
|
||||||
inherit (config.partitions.dev.module.flake.packages.${system})
|
inherit (config.partitions.dev.module.flake.packages.${system})
|
||||||
all-maintainers
|
all-maintainers
|
||||||
|
subsystem-maintainers
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
(lib.mkIf pkgs.stdenv.hostPlatform.isLinux (
|
(lib.mkIf pkgs.stdenv.hostPlatform.isLinux (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue