From a2455d0e8c5b56cdde8af0fe90f9d1f8a3512f5b Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Mon, 14 Jun 2021 20:53:13 +0000 Subject: [PATCH] Allow overriding testing command This now runs the `commands` block defined in the YAML pipeline, and allows disabling of the default testing command by setting `run_tests` to `false`. --- hooks/command | 33 +++++++++++++++++++++------------ hooks/common | 3 ++- plugin.yml | 36 ++++++++++++++++++++++++++++-------- 3 files changed, 51 insertions(+), 21 deletions(-) diff --git a/hooks/command b/hooks/command index 0c549a0..a0a9c62 100755 --- a/hooks/command +++ b/hooks/command @@ -1,18 +1,27 @@ #!/bin/bash source $(dirname ${BASH_SOURCE})/common -echo "+++ :julia: Running tests" -julia ${bugreport_args} --project=${project} -e " - using Pkg +# Use default julia test running harness +if [[ "${run_tests}" == "true" ]]; then + echo "+++ :julia: Running tests" + julia ${bugreport_args} --project=${project} -e " + using Pkg - # We never update the registry when running tests, we assume if you wanted this done, you'd do it in the pre-command - Pkg.UPDATED_REGISTRY_THIS_SESSION[] = true + # We never update the registry when running tests, we assume if you wanted this done, you'd do it in the pre-command + Pkg.UPDATED_REGISTRY_THIS_SESSION[] = true - # In the event that you might need to fetch test-only dependencies that are private, - # we set Pkg to use SSH for cloning non-PkgServer-served packages here as well - ${USE_SSH_BLOCK} + # In the event that you might need to fetch test-only dependencies that are private, + # we set Pkg to use SSH for cloning non-PkgServer-served packages here as well + ${USE_SSH_BLOCK} - Pkg.test(; coverage=$coverage, - julia_args=\`$julia_args\`, - test_args=\`$test_args\`) -" + Pkg.test(; coverage=$coverage, + julia_args=\`$julia_args\`, + test_args=\`$test_args\`) + " +fi + +# If there is a `commands` block specified in the YAML, run that as well +if [[ -n "${BUILDKITE_COMMAND}" ]]; then + echo "+++ Running yaml-provided user commands" + eval "${BUILDKITE_COMMAND}" +fi diff --git a/hooks/common b/hooks/common index 590c234..1af0017 100644 --- a/hooks/common +++ b/hooks/common @@ -6,6 +6,7 @@ julia_args=${BUILDKITE_PLUGIN_JULIA_TEST_JULIA_ARGS:-""} test_args=${BUILDKITE_PLUGIN_JULIA_TEST_TEST_ARGS:-""} project=${BUILDKITE_PLUGIN_JULIA_TEST_PROJECT:-.} upload_rr_trace=${BUILDKITE_PLUGIN_JULIA_TEST_UPLOAD_RR_TRACE:-never} +run_tests=${BUILDKITE_PLUGIN_JULIA_TEST_RUN_TESTS:-true} CACHE_DIR=${BUILDKITE_PLUGIN_JULIA_CACHE_DIR:-${HOME}/.cache/julia-test-buildkite-plugin} export _RR_TRACE_DIR=${CACHE_DIR}/rr_traces/${BUILDKITE_BUILD_ID} @@ -52,4 +53,4 @@ fi bugreport_args="" if [[ "${upload_rr_trace}" != "never" ]]; then bugreport_args="--bug-report=rr-local --" -fi \ No newline at end of file +fi diff --git a/plugin.yml b/plugin.yml index 8d0ce85..3d12fbc 100644 --- a/plugin.yml +++ b/plugin.yml @@ -4,20 +4,40 @@ author: https://github.com/maleadt requirements: [julia] configuration: properties: - coverage: - type: boolean - julia_args: - type: string - test_args: - type: string - use_ssh: + ## Runtime testing options + # Whether to actually run the Julia test suite (defaults to `true`) + run_tests: type: boolean + # Sets the project path to be tested, defaults to `"."` project: type: string + # Whether to run within `rr` and upload a trace, takes one of the following options: + # - "never": `rr` is never used (this is the default) + # - "always": `rr` is used and a trace is unconditionally uploaded + # - "error": `rr` is used and a trace is uploaded only if testing fails. + upload_rr_trace: + type: string + + ## Project instantiation options + # Whether to update the registry before instantiating, defaults to `"true"`. update_registry: type: boolean + # Extra registries to add before instantiating as a comma-separated list extra_registries: type: string - upload_rr_trace: + # Use SSH when instantiating the projects (runs `Pkg.setprotocol!(protocol="ssh")`), defaults to `false` + use_ssh: + type: boolean + + ## Kwargs that get passed to `Pkg.test()` + # Whether to upload coverage (passes `coverage` to `Pkg.test()`), defaults to `true` + coverage: + type: boolean + # Extra julia args (passes `julia_args` to `Pkg.test()`), defaults to `""` + julia_args: + type: string + # Extra test args (passes `test_args` to `Pkg.test()`), defaults to `""` + test_args: type: string + additionalProperties: false