From defd6c86b2f8d78daf5734f48e67802da71ab4e1 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Fri, 27 Oct 2023 11:18:07 +0100 Subject: [PATCH] Add some basic devenv tests devenv v1.0 will add proper testing infrastructure, but for now this is a noddy solution. --- .ci/scripts/build-all-dev-envs.sh | 9 ++++++--- project-flakes/complement/module.nix | 1 + project-flakes/element-web/module.nix | 1 + project-flakes/synapse/module.nix | 1 + project-flakes/sytest/module.nix | 1 + 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.ci/scripts/build-all-dev-envs.sh b/.ci/scripts/build-all-dev-envs.sh index 20802dc..ac960c0 100755 --- a/.ci/scripts/build-all-dev-envs.sh +++ b/.ci/scripts/build-all-dev-envs.sh @@ -15,16 +15,19 @@ for project in "$PROJECT_FLAKES_DIR"/*/ ; do # Extract the git URL of the project. We often need the files of the # project locally in order to build the development shell: url=$(grep "^# ci.project-url:" "$PROJECT_FLAKES_DIR/$project/default.nix" | awk -F': ' '{print $2}') + # Extract the CI test command of the project. We'll use this to check + # that the development environment built successfully. + cmd=$(grep "^# ci.test-command:" "$PROJECT_FLAKES_DIR/$project/default.nix" | awk -F': ' '{print $2}') echo "Cloning repo: $url" # Clone the project to a directory with the same name. - git clone --depth 1 -q "$url" "$project" + git clone --depth 1 --single-branch -q "$url" "$project" # Enter the project directory. cd "$project" # Show the generated outputs of the flake. nix flake show .. # Attempt to build and enter the development environment, - # then immediately exit the built shell. - nix develop --impure ..#"$project" -c "true" + # then run the specified test command. + nix develop --impure ..#"$project" -c bash -c "$cmd" # Leave the project directory. cd .. # Delete the project directory. diff --git a/project-flakes/complement/module.nix b/project-flakes/complement/module.nix index 989f4f2..6342b38 100644 --- a/project-flakes/complement/module.nix +++ b/project-flakes/complement/module.nix @@ -1,4 +1,5 @@ # ci.project-url: https://github.com/matrix-org/complement +# ci.test-command: go build ./tests/... { pkgs, ... }: { diff --git a/project-flakes/element-web/module.nix b/project-flakes/element-web/module.nix index c54040d..4cebc97 100644 --- a/project-flakes/element-web/module.nix +++ b/project-flakes/element-web/module.nix @@ -1,4 +1,5 @@ # ci.project-url: https://github.com/vector-im/element-web +# ci.test-command: yarn install && yarn build { pkgs, ... }: { diff --git a/project-flakes/synapse/module.nix b/project-flakes/synapse/module.nix index 8fda9e5..41ab531 100644 --- a/project-flakes/synapse/module.nix +++ b/project-flakes/synapse/module.nix @@ -1,4 +1,5 @@ # ci.project-url: https://github.com/matrix-org/synapse +# ci.test-command: python -m synapse.app.homeserver --server-name local -c homeserver.yaml --generate-config --report-stats=no { pkgs, ... }: let diff --git a/project-flakes/sytest/module.nix b/project-flakes/sytest/module.nix index 07af257..42585e3 100644 --- a/project-flakes/sytest/module.nix +++ b/project-flakes/sytest/module.nix @@ -1,4 +1,5 @@ # ci.project-url: https://github.com/matrix-org/sytest +# ci.test-command: perl --version { pkgs, ... }: {