Skip to content
Merged
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
28 changes: 19 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,25 @@ on:
- master
pull_request:
jobs:
checks:
nix:
runs-on: self-hosted
strategy:
matrix:
# TODO: Add Linux, after enabling test flake check to work without internet access.
# https://github.com/srid/haskell-flake/issues/241
system: [aarch64-darwin]
steps:
- uses: actions/checkout@v4
- name: Build Nix
id: build-nix
run: |
nixci
- name: Run test
id: test
run: |
nix run nixpkgs#bash runtest.sh
- run: nixci --build-systems "github:nix-systems/${{ matrix.system }}"
# Remove this job after doing the TODO above.
linux-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- run: bash ./runtest.sh
docs-linkcheck:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- run: bash ./doc/test.sh
5 changes: 3 additions & 2 deletions doc/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
source ../test/common.sh
SYSTEM=$(nix eval --impure --expr builtins.currentSystem)
HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

nix build ${OVERRIDE_HASKELL_FLAKE} \
nix build --override-input haskell-flake ${HERE}/.. \
--option log-lines 1000 --show-trace \
"github:hercules-ci/flake.parts-website#checks.${SYSTEM}.linkcheck"
15 changes: 10 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@
};

# https://github.com/srid/nixci
nixci.default = let overrideInputs = { "haskell-flake" = ./.; }; in {
dev = { inherit overrideInputs; dir = "dev"; };
doc.dir = "doc";
example = { inherit overrideInputs; dir = "example"; };
};
nixci.default =
let
overrideInputs = { "haskell-flake" = ./.; };
in
{
dev = { inherit overrideInputs; dir = "dev"; };
test = { inherit overrideInputs; dir = "test"; };
doc = { dir = "doc"; };
example = { inherit overrideInputs; dir = "example"; };
};
};
}
3 changes: 2 additions & 1 deletion runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ TESTS=(
./test/simple
./test/with-subdir
./test/project-module
./doc
# We run this separately, because it's a bit slow.
# ./doc
)

for testDir in "${TESTS[@]}"
Expand Down
14 changes: 5 additions & 9 deletions test/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ function logHeader {
echo -e "\n||| $@"
}

SYSTEM=$(nix show-config | grep 'system =' | nix run nixpkgs#gawk '{print $3}')
nix --version

SYSTEM=$(nix show-config | grep 'system =' | awk '{print $3}')

DIR_OF_COMMON_SH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
HASKELL_FLAKE=${DIR_OF_COMMON_SH}/..
Expand All @@ -24,12 +26,6 @@ if [ "$(printf '%s\n' "$requiredver" "$currentver" | sort -V | head -n1)" = "$re
then
echo
else
echo "!!!! Your Nix version is old ($currentver). Using newer Nix from github:nixos/nix/2.14.1"
# We use newer Nix for:
# - https://github.com/NixOS/nix/issues/7263
# - https://github.com/NixOS/nix/issues/7026
nix build --no-link github:nixos/nix/2.14.1
export PATH=$(nix eval --raw github:nixos/nix/2.14.1#default.outPath)/bin:$PATH
echo "!!!! Your Nix version is old ($currentver)."
exit 2
fi

nix --version
38 changes: 38 additions & 0 deletions test/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake = { }; # Overriden by nixci (see top-level flake.nix)
};
outputs = inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = inputs.nixpkgs.lib.systems.flakeExposed;
perSystem = { pkgs, ... }: {
checks.tests = pkgs.runCommandNoCC "tests"
{
nativeBuildInputs = with pkgs; [
coreutils
bash
nix
cacert
git
which
gawk
];
} ''
export HOME=$(mktemp -d)
cd $HOME
mkdir -p .config/nix
echo 'experimental-features = nix-command flakes' > .config/nix/nix.conf
cp -r ${inputs.haskell-flake} ./haskell-flake
chmod -R u+rw haskell-flake
cd haskell-flake
git config --global user.email "nix@localhost"
git config --global user.name "nix"
git init && git add . && git commit -m "Initial commit"
bash ./runtest.sh
touch $out
'';
};
};
}