Skip to content

Commit

Permalink
Run tests in MacOS's CI pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
mzabani committed Dec 26, 2024
1 parent 39643e1 commit 25048c1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
nix-env --uninstall codd
- name: Run tests
run: nix develop .#shellWithRunfile.x86_64-linux -c run ci-tests
run: nix develop .#shellWithRunfile -c run ci-tests

- name: Run benchmarks
run: nix run ".#x86_64-unknown-linux-musl:codd:bench:codd-bench"
Expand Down Expand Up @@ -121,6 +121,12 @@ jobs:
- name: Build codd without static linking
run: nix build --no-link ".#codd:exe:codd"

- name: Build statically linked codd's tests
run: nix build --no-link ".#codd:test:codd-test"

- name: Run tests
run: nix develop .#shellWithRunfile -c run test-no-db --nix

- name: Create macOS app bundle
run: |
nix build .#coddDarwinAppBundle.aarch64-darwin
Expand Down
18 changes: 11 additions & 7 deletions Runfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ test-no-db:
# This Run command is used insire pure Nix shells where `nix` is not available. That's why
# this option is useful.
if [ -z "$NONIXBUILD" ]; then
nix build ".#x86_64-unknown-linux-musl:codd:test:codd-test" -o local/codd-test
TARGET=".#x86_64-unknown-linux-musl:codd:test:codd-test"
[[ "$(uname -s)" == *"Darwin"* ]] && TARGET=".#codd:test:codd-test"
nix build "$TARGET" -o local/codd-test
fi

"${STRACECMD[@]}" ./local/codd-test/bin/codd-test "${TARGS[@]}"
Expand All @@ -92,12 +94,14 @@ test-with-db:

# Build the test executable only once with Nix
if [ -n "$NIX" ]; then
nix build ".#x86_64-unknown-linux-musl:codd:test:codd-test" -o local/codd-test
TARGET=".#x86_64-unknown-linux-musl:codd:test:codd-test"
[[ "$(uname -s)" == *"Darwin"* ]] && TARGET=".#codd:test:codd-test"
nix build "$TARGET" -o local/codd-test
fi

for pg in "${PG[@]}"; do
echo "Running tests on Postgres $pg"
nix develop ".#testShells.x86_64-linux.pg${pg}" "${NIXDEVARGS[@]}" -c run test-with-db-internal "${NIXA[@]}" -- "${TARGS[@]}"
nix develop ".#pg${pg}" "${NIXDEVARGS[@]}" -c run test-with-db-internal "${NIXA[@]}" -- "${TARGS[@]}"
done

##
Expand Down Expand Up @@ -130,9 +134,9 @@ test-system-resources:

if [ -n "$NIX" ]; then
nix build ".#x86_64-unknown-linux-musl:codd:test:codd-test" -o local/codd-test
nix develop ".#testShells.x86_64-linux.pg16" -i -c run test-with-db-internal --strace --nix -- --match "/SystemResourcesSpecs/RUNNING"
nix develop ".#testShells.x86_64-linux.pg16" -i -c run test-with-db-internal --nix -- --match "/SystemResourcesSpecs/CHECKING"
nix develop ".#pg16" -i -c run test-with-db-internal --strace --nix -- --match "/SystemResourcesSpecs/RUNNING"
nix develop ".#pg16" -i -c run test-with-db-internal --nix -- --match "/SystemResourcesSpecs/CHECKING"
else
nix develop ".#testShells.x86_64-linux.pg16" -c run test-with-db-internal --strace -- --match "/SystemResourcesSpecs/RUNNING"
nix develop ".#testShells.x86_64-linux.pg16" -c run test-with-db-internal -- --match "/SystemResourcesSpecs/CHECKING"
nix develop ".#pg16" -c run test-with-db-internal --strace -- --match "/SystemResourcesSpecs/RUNNING"
nix develop ".#pg16" -c run test-with-db-internal -- --match "/SystemResourcesSpecs/CHECKING"
fi
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,16 @@
# Built by `nix build .`
defaultPackage = flakeDefault.packages."codd:exe:codd";

testShells = {
devShells = flakeDefault.devShells // {
pg12 = import ./nix/test-shell-pg12.nix { inherit pkgs; };
pg13 = import ./nix/test-shell-pg13.nix { inherit pkgs; };
pg14 = import ./nix/test-shell-pg14.nix { inherit pkgs; };
pg15 = import ./nix/test-shell-pg15.nix { inherit pkgs; };
pg16 = import ./nix/test-shell-pg16.nix { inherit pkgs; };
shellWithRunfile =
pkgs.mkShell { buildInputs = [ pkgs.run pkgs.shellcheck ]; };
};

shellWithRunfile =
pkgs.mkShell { buildInputs = [ pkgs.run pkgs.shellcheck ]; };

# Having pkgs helps debug musl builds with `nix repl`. We can e.g.
# build musl packages statically to see if their "normal" builds pass
inherit pkgs;
Expand Down

0 comments on commit 25048c1

Please sign in to comment.