From 41d807dec4f497cc7be9f329b25c409073735f5f Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 14 Mar 2021 19:07:54 +1300 Subject: [PATCH] ci(package): Add testing routine --- .github/workflows/package-pr.yaml | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/package-pr.yaml b/.github/workflows/package-pr.yaml index 8b02e50..c1087a7 100644 --- a/.github/workflows/package-pr.yaml +++ b/.github/workflows/package-pr.yaml @@ -91,13 +91,35 @@ jobs: docker run -v $(pwd)'/repo:/piston/repo' -v $(pwd)'/packages:/piston/packages' -d --name piston_fs_repo docker.pkg.github.com/engineer-man/piston/repo-builder --no-build docker run --network container:piston_fs_repo -v $(pwd)'/data:/piston' -d --name api docker.pkg.github.com/engineer-man/piston/api echo Waiting for API to start.. - docker run --network container:api appropriate/curl --retry 10 --retry-connrefused http://localhost:6969/runtimes + docker run --network container:api appropriate/curl -s --retry 10 --retry-connrefused http://localhost:6969/runtimes echo Waiting for Index to start.. - docker run --network container:piston_fs_repo appropriate/curl --retry 10 --retry-connrefused http://localhost:8000/index + docker run --network container:piston_fs_repo appropriate/curl -s --retry 10 --retry-connrefused http://localhost:8000/index echo Listing Packages - docker run --network container:api appropriate/curl http://localhost:6969/packages + PACKAGES_JSON=$(docker run --network container:api appropriate/curl -s http://localhost:6969/packages) + echo $PACKAGES_JSON + + for package in $(jq -r '.[] | "\(.language)-\(.language_version)"' <<< "$PACKAGES_JSON") + do + echo "Testing $package" + PKG_PATH=$(sed 's|-|/|' <<< $package) + PKG_NAME=$(awk -F- '{ print $1 }' <<< $package) + PKG_VERSION=$(awk -F- '{ print $2 }' <<< $package) + + echo "Installing..." + docker run --network container:api appropriate/curl -sXPOST http://localhost:6969/packages/$PKG_PATH + + TEST_SCRIPTS=packages/$PKG_PATH/test.* + echo "Tests: $TEST_SCRIPTS" + + for tscript in $TEST_SCRIPTS + do + TEST_RUNTIME=$(awk -F. '{print $2}' <<< $(basename $tscript)) + echo Running $tscript with runtime=$TEST_RUNTIME + docker run --network container:api -v "$PWD/cli:/app" -v "$PWD/$(dirname $tscript):/pkg" node:15 /app/index.js run $TEST_RUNTIME $PKG_VERSION /pkg/$(basename $tscript) | grep OK + done + done docker logs api docker logs piston_fs_repo