Skip to content

Commit

Permalink
Merge pull request #45 from mlabs-haskell/marton/integration-test
Browse files Browse the repository at this point in the history
add integration test runner script and github workflow
  • Loading branch information
brainrake committed Mar 26, 2024
2 parents 8bedd65 + 13df7e1 commit 62e25ae
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 10 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: integration-test
on: push

jobs:
release:
runs-on: "ubuntu-22.04"
permissions:
contents: write

steps:
- uses: actions/checkout@v4

- uses: cachix/install-nix-action@v24

- uses: cachix/cachix-action@v13
with:
name: mlabs
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
skipPush: true

- name: Download / Build
run: nix build .#test

- name: Run Integration Test
run: |
[ -z "${{ secrets.TESTNET_SEED_PHRASE }}" ] && echo "Secret is available."
nix run .#test
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ nix build .#demo
nix run .#steam-run result/bin/demo
```

### Test
### Run Integration Test

```
nix build .#test
nix run .#test
```

### Develop
Expand Down
24 changes: 16 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
};
make_demo = { name ? "demo", src ? ./demo, ... }@args:
make_gd_project (args // { inherit name src; });
run_gut_test = { name ? "godot-cardano-test", src ? ./test }: pkgs.stdenv.mkDerivation {
gut_check = { name ? "godot-cardano-test", src ? ./test }: pkgs.stdenv.mkDerivation {
inherit name src;
configurePhase = ''
rm -rf ./addons/gut
Expand All @@ -113,17 +113,28 @@
'';
buildPhase = ''
mkdir -p .home
export HOME=$(pwd)/.home
HOME="$(pwd)/.home"
export HOME
echo "Reimporting resources..."
timeout 10s ${self'.packages.godot}/bin/godot4 --headless --editor || true
echo "Reimporting resources done."
echo
RESULT=$(${self'.packages.godot}/bin/godot4 --headless --script res://addons/gut/gut_cmdln.gd)
echo -e "$RESULT"
[[ $RESULT =~ '---- All tests passed! ----' ]] || (echo "Not all tests passed." && exit 1)
[[ "$RESULT" =~ '---- All tests passed! ----' ]] || (echo "Not all tests passed." && exit 1)
'';
installPhase = "touch $out";
dontFixup = true;
};
run_gut_test = { name ? "godot-cardano-test", src ? ./test }: pkgs.writeShellApplication {
inherit name;
text = ''
cd test
[ ! -f test.gd ] && echo "Could not find 'test.gd'. Please run this script from the repository root." && exit 1
${(gut_check {inherit name src; }).configurePhase}
${(gut_check {inherit name src; }).buildPhase}
'';
};
devShell = pkgs.mkShell {
buildInputs = [
self'.packages.godot
Expand All @@ -146,8 +157,8 @@
rm -rf ./addons/@mlabs-haskell/godot-cardano
ln -s ../../../addons/@mlabs-haskell/godot-cardano ./addons/@mlabs-haskell/godot-cardano
}
(cd demo && (${self'.packages.demo.configurePhase}) && link-addon)
(cd test && (${self'.packages.test.configurePhase}) && link-addon)
(cd demo && (${(make_demo {}).configurePhase}) && link-addon)
(cd test && (${(gut_check {}).configurePhase}) && link-addon)
${config.pre-commit.installationScript}
Expand All @@ -164,9 +175,6 @@
};
in
{
checks = {
test = run_gut_test { };
};
packages = rec {
default = godot-cardano;
steam-run = pkgs.steamPackages.steam-fhsenv-without-steam.run;
Expand Down

0 comments on commit 62e25ae

Please sign in to comment.