Skip to content

Commit

Permalink
Merge pull request #69 from cyber-dojo/delete-dead-scripts
Browse files Browse the repository at this point in the history
Delete dead scripts
  • Loading branch information
JonJagger authored Oct 30, 2024
2 parents f29c3e6 + 77439b4 commit f50a032
Show file tree
Hide file tree
Showing 26 changed files with 211 additions and 618 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ all_client: test_client coverage_client
image_client:
${PWD}/bin/build_image.sh client

test_client:
test_client: image_client
${PWD}/bin/run_tests.sh client

coverage_client:
Expand All @@ -31,7 +31,7 @@ rubocop_lint:
demo:
${PWD}/bin/demo.sh

snyk-container: image
snyk-container:
snyk container test ${IMAGE_NAME} \
--file=Dockerfile \
--sarif \
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

- A [docker-containerized](https://registry.hub.docker.com/r/cyberdojo/runner) micro-service for [https://cyber-dojo.org](http://cyber-dojo.org).
- An http service (rack based) for running `cyber-dojo.sh` inside a docker container for at most 20 seconds and returning `[stdout,stderr,status,timed_out,colour]`
- A [Kosli CI flow](https://app.kosli.com/cyber-dojo/flows/runner-ci/trails/)
deploying, with Continuous Compliance, to [staging](https://app.kosli.com/cyber-dojo/environments/aws-beta/snapshots/) and [production](https://app.kosli.com/cyber-dojo/environments/aws-prod/snapshots/) AWS environments.
- Demonstrates a [Kosli](https://www.kosli.com/) instrumented [GitHub CI workflow](https://app.kosli.com/cyber-dojo/flows/runner-ci/trails/)
deploying, with Continuous Compliance, to [staging](https://app.kosli.com/cyber-dojo/environments/aws-beta/snapshots/) and [production](https://app.kosli.com/cyber-dojo/environments/aws-prod/snapshots/) AWS environments.
- Uses patterns from https://www.kosli.com/blog/using-kosli-attest-in-github-action-workflows-some-tips/
Expand Down
24 changes: 13 additions & 11 deletions bin/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ check_args()
show_help
exit 0
;;
'server' | 'client')
'server')
if [ -n "${CI:-}" ] ; then
stderr "In CI workflow - use previous docker/build-push-action@v6 GitHub Action"
exit 42
fi
;;
'client')
;;
'')
show_help
Expand All @@ -43,18 +49,12 @@ check_args()
build_image()
{
check_args "$@"

local -r type="${1}"

if [ -n "${CI:-}" ] && [ "${type}" == 'server' ] ; then
stderr "In CI workflow - use previous docker/build-push-action@v6 GitHub Action"
exit 42
fi

exit_non_zero_unless_installed docker
export $(echo_versioner_env_vars)
containers_down
remove_old_images

docker compose build --build-arg COMMIT_SHA="${COMMIT_SHA}" server
if [ "${type}" == 'client' ]; then
docker compose build --build-arg COMMIT_SHA="${COMMIT_SHA}" client
Expand All @@ -69,12 +69,14 @@ build_image()
exit 42
fi

# Tag image-name for local development where differs name comes from echo-versioner-env-vars
if [ "${type}" == 'server' ]; then
docker tag "${image_name}" "cyberdojo/runner:${CYBER_DOJO_RUNNER_TAG}"
# Create latest tag for image build cache
docker tag "${image_name}" "${CYBER_DOJO_RUNNER_IMAGE}:latest"
# Tag image-name for local development where differs name comes from echo-versioner-env-vars
docker tag "${image_name}" "cyberdojo/runner:latest"
echo "CYBER_DOJO_RUNNER_SHA=${CYBER_DOJO_RUNNER_SHA}"
echo "CYBER_DOJO_RUNNER_TAG=${CYBER_DOJO_RUNNER_TAG}"
fi
}

build_image "$@"
build_image "$@"
13 changes: 0 additions & 13 deletions bin/build_tag.sh

This file was deleted.

90 changes: 0 additions & 90 deletions bin/build_tagged_images.sh

This file was deleted.

30 changes: 4 additions & 26 deletions bin/check_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,39 +41,17 @@ check_args()
check_coverage()
{
check_args "$@"
local -r TYPE="${1}" # eg server

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Run tests (with coverage) inside the container.

local -r TYPE="${1}" # {server|client}
local -r TEST_LOG=test.run.log

local -r CONTAINER_REPORTS_DIR="/tmp/reports" # where tests write to.
# NB fs is read-only, tmpfs at /tmp
# NB run.sh ensures this dir exists

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Extract test-run results and coverage data from the container.
# You can't [docker cp] from a tmpfs
# https://docs.docker.com/engine/reference/commandline/cp/#extended-description
# So tar-piping out.

local -r HOST_TEST_DIR="${ROOT_DIR}/test/${TYPE}"
local -r HOST_REPORTS_DIR="${ROOT_DIR}/reports/${TYPE}" # where report files have been written be
local -r HOST_REPORTS_DIR="${ROOT_DIR}/reports/${TYPE}" # where report files have been written to
local -r CONTAINER_TMP_DIR=/tmp # where to mount to in container

# Check we generated expected files.
exit_non_zero_unless_file_exists "${HOST_REPORTS_DIR}/${TEST_LOG}"
exit_non_zero_unless_file_exists "${HOST_REPORTS_DIR}/index.html"
exit_non_zero_unless_file_exists "${HOST_REPORTS_DIR}/summary.json"

# Check metrics limits file exists
exit_non_zero_unless_file_exists "${HOST_TEST_DIR}/max_metrics.json"

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Run metrics check against test-run results and coverage data.

local -r CONTAINER_TMP_DIR=/tmp # where to mount to in container

set +e
docker run \
--rm \
Expand All @@ -96,4 +74,4 @@ check_coverage()
return "${STATUS}"
}

check_coverage "$@"
check_coverage "$@"
11 changes: 0 additions & 11 deletions bin/containers_down.sh

This file was deleted.

119 changes: 0 additions & 119 deletions bin/containers_up_healthy_and_clean.sh

This file was deleted.

Loading

0 comments on commit f50a032

Please sign in to comment.