From 111618cbbcd1ef06979a1ae42e9da0e61e9f59f3 Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Sat, 27 Jul 2024 00:00:29 -0400 Subject: [PATCH] Add option to specify which services to start --- action.yml | 8 ++++++-- minichris.sh | 10 +++++++--- unmake.sh | 2 +- wrapper.js | 17 +++++++++++++++-- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/action.yml b/action.yml index 1237664..d29325d 100644 --- a/action.yml +++ b/action.yml @@ -1,11 +1,15 @@ -name: "ChRIS Backend" -description: "Bring up ephemeral instances of CUBE, pfcon, pman, pfioh, swift, and ChRIS_store" +name: "miniChRIS in Docker" +description: "Bring up a local ChRIS backend." author: "FNNDSC" inputs: plugins: description: "List of plugins to register, separated by whitespace." required: false default: '' + services: + description: "Manually specify list of services to start, separated by whitespace. Setting this option can save time and memory." + required: false + default: '' runs: using: node20 diff --git a/minichris.sh b/minichris.sh index e35a7c8..1018c60 100755 --- a/minichris.sh +++ b/minichris.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash if [ "$CI" = "true" ]; then notty='-T' @@ -8,5 +8,9 @@ fi cd "$(dirname "$(readlink -f "$0")")" set -ex -docker compose up -d -exec docker compose run --rm $notty chrisomatic +docker compose up -d "$@" + +# if chris is running, run chrisomatic +if [ -n "$(docker compose ps chris -q)" ]; then + docker compose run --rm $notty chrisomatic +fi diff --git a/unmake.sh b/unmake.sh index f530a10..dd00dde 100755 --- a/unmake.sh +++ b/unmake.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # change to directory where this script lives cd "$(dirname "$(readlink -f "$0")")" diff --git a/wrapper.js b/wrapper.js index 7653d47..ede1a8e 100644 --- a/wrapper.js +++ b/wrapper.js @@ -31,14 +31,27 @@ function main() { setIsPost(); } - const script = path.join(__dirname, IS_POST ? 'unmake.sh' : 'minichris.sh'); - execFileSync(script, { stdio: 'inherit' }); + const scriptName = IS_POST ? 'unmake.sh' : 'minichris.sh'; + runScriptHere(scriptName, getInputServices()); +} + +function runScriptHere(fileName, args) { + const script = path.join(__dirname, fileName); + execFileSync(script, args, { stdio: 'inherit' }); } function setIsPost() { fs.appendFileSync(process.env['GITHUB_STATE'], 'isPost=true\n'); } +function getInputServices() { + const inputServices = process.env['INPUT_SERVICES']; + if (inputServices) { + return inputServices.split(/\s+/); + } + return []; +} + function test() { console.log('running unit tests');