Skip to content

Commit

Permalink
Merge pull request #4 from getchoo/small-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelroses authored May 5, 2024
2 parents 6bd919b + 320cdcf commit 33319be
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 84 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/check-contacts.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
name: "Check that users contatains at least 1 point of contact"
name: Check points of contact for users

on:
workflow_dispatch:
push:
paths:
- 'users.nix'
pull_request_target:
paths:
- 'users.nix'
workflow_dispatch:

jobs:
check-contacts:
check:
name: Run check

runs-on: ubuntu-latest

steps:
- name: Checkout
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Nix
uses: cachix/install-nix-action@v12
- name: Install Nix
uses: cachix/install-nix-action@v26

- name: Check users list
run: nix-instantiate --eval checks/one-contacts.nix
- name: Evaluate checks
run: |
nix eval --show-trace --file checks/check-contacts.nix
40 changes: 40 additions & 0 deletions checks/check-contacts.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
let
users = import ../users.nix;

# This is how many contact points a user should have
# besides GitHub
requiredContactPoints = 1;

# attrset -> attrset
# We remove the GitHub attribute from all users, as we don't consider it
# as a point of contact
removeGH = userInfo: builtins.removeAttrs userInfo [ "github" ];

# attrset -> int
# Count the number of attributes in a set
# This is how we count the points of contact
attrsLength = attrs: builtins.length (builtins.attrValues attrs);

# attrset -> bool
# Check to see if a set of user information attributes has the
# number of contact points we require
hasEnoughContacts = userInfo: attrsLength (removeGH userInfo) >= requiredContactPoints;

# attrset -> attrset
# This will check the contacts for a user and throw an evaluation
# error if they don't meet our number of required contacts
checkContact =
userName: userInfo:
if (!(hasEnoughContacts userInfo)) then
throw "${userName} has less than ${toString requiredContactPoints} contact point(s)!"
else
userInfo;

# This will run our contact check on each user
checkContacts = builtins.mapAttrs checkContact users;

# string -> string
# This will evaluate our checks and display the message you give it if all goes well
evalContactsThen = builtins.deepSeq checkContacts;
in
evalContactsThen "All users have at least ${toString requiredContactPoints} contact point(s)!"
32 changes: 0 additions & 32 deletions checks/one-contact.nix

This file was deleted.

29 changes: 18 additions & 11 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
{
description =
"A project to declaratively add people to GitHub and their related SIG teams";
description = "A project to declaratively add people to GitHub and their related SIG teams";

inputs.nixpkgs.url = "github:auxolotl/nixpkgs/nixos-unstable";

outputs = { nixpkgs, ... }:
outputs =
{ nixpkgs, ... }:
let
systems =
[ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs systems;
pkgsFor = nixpkgs.legacyPackages;
in {
devShells = forAllSystems
(system: { default = pkgsFor.${system}.callPackage ./shell.nix { }; });
systems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];

formatter = forAllSystems (system: pkgsFor.${system}.nixfmt);
forAllSystems =
function: nixpkgs.lib.genAttrs systems (system: function nixpkgs.legacyPackages.${system});
in
{
devShells = forAllSystems (pkgs: {
default = pkgs.callPackage ./shell.nix { };
});

formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
};
}
54 changes: 30 additions & 24 deletions memberships.nix
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
let
sigs = import ./sigs.nix;
users = import ./users.nix;
in [{
sig = sigs.documentation;
leaders = [ users.coded users.minion ];
members = [
users.axel
users.isabel
users.ircurry
users."8bitbuddhist"
users.trespaul
users.imadnyc
users.aprl
users.dfh
users.vera
users.nova
users.blue
users.deivpaukst
users.tau
users.srestegosaurio
users.jacab
users.liketechnik
users.angryant
users.raf
];
}]
in
[
{
sig = sigs.documentation;
leaders = [
users.coded
users.minion
];
members = [
users.axel
users.isabel
users.ircurry
users."8bitbuddhist"
users.trespaul
users.imadnyc
users.aprl
users.dfh
users.vera
users.nova
users.blue
users.deivpaukst
users.tau
users.srestegosaurio
users.jacab
users.liketechnik
users.angryant
users.raf
];
}
]
6 changes: 2 additions & 4 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
{ mkShell, python3, ... }:
mkShell {
packages = [ (python3.withPackages (pyPkgs: [ pyPkgs.pydiscourse ])) ];
}
{ mkShellNoCC, python3, ... }:
mkShellNoCC { packages = [ (python3.withPackages (pyPkgs: [ pyPkgs.pydiscourse ])) ]; }
20 changes: 15 additions & 5 deletions users.nix
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,19 @@
forum = "aria";
github = "tcmal";
};
ircurry = { forum = "ircurry"; };
aprl = { forum = "aprl"; };
deivpaukst = { forum = "deivpaukst"; };
tau = { forum = "tau"; };
srestegosaurio = { forum = "srestegosaurio"; };
ircurry = {
forum = "ircurry";
};
aprl = {
forum = "aprl";
};
deivpaukst = {
forum = "deivpaukst";
};
tau = {
forum = "tau";
};
srestegosaurio = {
forum = "srestegosaurio";
};
}

0 comments on commit 33319be

Please sign in to comment.