mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
ci: add nix and lix parse checks
Co-authored-by: Wolfgang Walther <walther@technowledgy.de> Co-authored-by: piegames <git@piegames.de>
This commit is contained in:
16
.github/workflows/test.yml
vendored
16
.github/workflows/test.yml
vendored
@@ -13,6 +13,7 @@ jobs:
|
|||||||
docs: ${{ steps.changes.outputs.docs }}
|
docs: ${{ steps.changes.outputs.docs }}
|
||||||
format: ${{ steps.changes.outputs.format }}
|
format: ${{ steps.changes.outputs.format }}
|
||||||
hm: ${{ steps.changes.outputs.hm }}
|
hm: ${{ steps.changes.outputs.hm }}
|
||||||
|
parse: ${{ steps.changes.outputs.parse }}
|
||||||
tests: ${{ steps.changes.outputs.tests }}
|
tests: ${{ steps.changes.outputs.tests }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
@@ -39,6 +40,9 @@ jobs:
|
|||||||
- 'flake.lock'
|
- 'flake.lock'
|
||||||
- 'flake.nix'
|
- 'flake.nix'
|
||||||
- 'home-manager/**'
|
- 'home-manager/**'
|
||||||
|
parse:
|
||||||
|
- '**/*.nix'
|
||||||
|
- 'flake.lock'
|
||||||
tests:
|
tests:
|
||||||
needs: changes
|
needs: changes
|
||||||
strategy:
|
strategy:
|
||||||
@@ -59,6 +63,12 @@ jobs:
|
|||||||
- name: Build docs
|
- name: Build docs
|
||||||
if: github.event_name == 'schedule' || needs.changes.outputs.docs == 'true'
|
if: github.event_name == 'schedule' || needs.changes.outputs.docs == 'true'
|
||||||
run: nix build --show-trace .#docs-jsonModuleMaintainers
|
run: nix build --show-trace .#docs-jsonModuleMaintainers
|
||||||
|
- name: Parse Nix files with latest nix
|
||||||
|
if: github.event_name == 'schedule' || needs.changes.outputs.parse == 'true'
|
||||||
|
run: nix build --show-trace .#ci-parse
|
||||||
|
- name: Parse Nix files with latest Lix
|
||||||
|
if: github.event_name == 'schedule' || needs.changes.outputs.parse == 'true'
|
||||||
|
run: nix build --show-trace .#ci-parse-lix
|
||||||
- name: Format Check
|
- name: Format Check
|
||||||
if: github.event_name == 'schedule' || needs.changes.outputs.format == 'true'
|
if: github.event_name == 'schedule' || needs.changes.outputs.format == 'true'
|
||||||
run: nix fmt -- --ci
|
run: nix fmt -- --ci
|
||||||
@@ -93,6 +103,12 @@ jobs:
|
|||||||
echo "- ☑️ **Format Check:** Skipped (no relevant files changed)" >> $GITHUB_STEP_SUMMARY
|
echo "- ☑️ **Format Check:** Skipped (no relevant files changed)" >> $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "${{ needs.changes.outputs.parse }}" == "true" ]]; then
|
||||||
|
echo "- ✅ **Nix Parse (nix + Lix):** Triggered" >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
echo "- ☑️ **Nix Parse (nix + Lix):** Skipped (no relevant files changed)" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "${{ needs.changes.outputs.hm }}" == "true" ]]; then
|
if [[ "${{ needs.changes.outputs.hm }}" == "true" ]]; then
|
||||||
echo "- ✅ **Home Manager Tests:** Triggered" >> $GITHUB_STEP_SUMMARY
|
echo "- ✅ **Home Manager Tests:** Triggered" >> $GITHUB_STEP_SUMMARY
|
||||||
else
|
else
|
||||||
|
|||||||
45
ci/parse.nix
Normal file
45
ci/parse.nix
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
nix,
|
||||||
|
runCommand,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
home-manager =
|
||||||
|
with lib.fileset;
|
||||||
|
toSource {
|
||||||
|
root = ../.;
|
||||||
|
fileset = (fileFilter (file: file.hasExt "nix") ../.);
|
||||||
|
};
|
||||||
|
parseLog = "$TMPDIR/nix-parse.log";
|
||||||
|
in
|
||||||
|
runCommand "nix-parse-${nix.name}"
|
||||||
|
{
|
||||||
|
nativeBuildInputs = [
|
||||||
|
nix
|
||||||
|
];
|
||||||
|
}
|
||||||
|
''
|
||||||
|
export NIX_STORE_DIR=$TMPDIR/store
|
||||||
|
export NIX_STATE_DIR=$TMPDIR/state
|
||||||
|
nix-store --init
|
||||||
|
|
||||||
|
cd "${home-manager}"
|
||||||
|
|
||||||
|
# This will only show the first parse error, not all of them. That's fine, because
|
||||||
|
# the other CI jobs will report in more detail. This job is about checking parsing
|
||||||
|
# across different implementations / versions, not about providing the best DX.
|
||||||
|
# Returning all parse errors requires significantly more resources.
|
||||||
|
if ! find . -type f -iname '*.nix' | xargs -P $(nproc) nix-instantiate --parse 2> "${parseLog}" > /dev/null; then
|
||||||
|
cat "${parseLog}" >&2
|
||||||
|
echo "Parse failed in nix-instantiate." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep "warning" "${parseLog}"; then
|
||||||
|
cat "${parseLog}" >&2
|
||||||
|
echo "Failing due to warnings in stderr" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
touch $out
|
||||||
|
''
|
||||||
@@ -189,6 +189,11 @@
|
|||||||
default = hmPkg;
|
default = hmPkg;
|
||||||
home-manager = hmPkg;
|
home-manager = hmPkg;
|
||||||
|
|
||||||
|
ci-parse = pkgs.callPackage ./ci/parse.nix { nix = pkgs.nixVersions.latest; };
|
||||||
|
ci-parse-lix = pkgs.callPackage ./ci/parse.nix {
|
||||||
|
nix = pkgs.lixPackageSets.latest.lix;
|
||||||
|
};
|
||||||
|
|
||||||
create-news-entry = pkgs.writeShellScriptBin "create-news-entry" ''
|
create-news-entry = pkgs.writeShellScriptBin "create-news-entry" ''
|
||||||
./modules/misc/news/create-news-entry.sh
|
./modules/misc/news/create-news-entry.sh
|
||||||
'';
|
'';
|
||||||
|
|||||||
Reference in New Issue
Block a user