From 6371ed930de8b1465cb1afc93f643b34fd9f96dc Mon Sep 17 00:00:00 2001 From: Glenn Jackman Date: Tue, 20 Oct 2020 07:57:00 -0400 Subject: [PATCH] Script to validate test cases against the problem specifications. (#450) * Script to validate test cases against the problem specifications. Identifies test cases from the problem spec canonical data that are unimplemented. * No need to reimplement what the canonical-data-syncer does * canonical-data-syncer requires config.json to be in good shape --- .gitignore | 1 + bin/check_test_cases | 10 +++++++ bin/fetch-canonical_data_syncer | 52 +++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100755 bin/check_test_cases create mode 100755 bin/fetch-canonical_data_syncer diff --git a/.gitignore b/.gitignore index 3987e01c..439864c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ bin/configlet bin/configlet.exe +bin/canonical_data_syncer diff --git a/bin/check_test_cases b/bin/check_test_cases new file mode 100755 index 00000000..2d1cb48d --- /dev/null +++ b/bin/check_test_cases @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +die() { echo "$*" >&2; exit 1; } + +cd "$(dirname "$0")"/.. || die "cannot cd" + +bin/fetch_configlet || die "cannot fetch configlet" +bin/configlet lint . || die "resolve config.json problems first" + +bin/fetch-canonical_data_syncer || die "cannot fetch canonical_data_syncer" +bin/canonical_data_syncer --check "$@" diff --git a/bin/fetch-canonical_data_syncer b/bin/fetch-canonical_data_syncer new file mode 100755 index 00000000..ecb4e1cf --- /dev/null +++ b/bin/fetch-canonical_data_syncer @@ -0,0 +1,52 @@ +#!/bin/bash + +set -eo pipefail + +readonly LATEST='https://api.github.com/repos/exercism/canonical-data-syncer/releases/latest' + +case "$(uname)" in + (Darwin*) OS='mac' ;; + (Linux*) OS='linux' ;; + (Windows*) OS='windows' ;; + (MINGW*) OS='windows' ;; + (MSYS_NT-*) OS='windows' ;; + (*) OS='linux' ;; +esac + +case "$OS" in + (windows*) EXT='zip' ;; + (*) EXT='tgz' ;; +esac + +case "$(uname -m)" in + (*64*) ARCH='64bit' ;; + (*686*) ARCH='32bit' ;; + (*386*) ARCH='32bit' ;; + (*) ARCH='64bit' ;; +esac + +if [ -z "${GITHUB_TOKEN}" ] +then + HEADER='' +else + HEADER="authorization: Bearer ${GITHUB_TOKEN}" +fi + +FILENAME="canonical_data_syncer-${OS}-${ARCH}.${EXT}" + +get_url () { + curl --header "$HEADER" -s "$LATEST" | + awk -v filename=$FILENAME '$1 ~ /browser_download_url/ && $2 ~ filename { print $2 }' | + tr -d '"' +} + +URL=$(get_url) + +case "$EXT" in + (*zip) + curl --header "$HEADER" -s --location "$URL" -o bin/latest-canonical_data_syncer.zip + unzip bin/latest-canonical_data_syncer.zip -d bin/ + rm bin/latest-canonical_data_syncer.zip + ;; + (*) curl --header "$HEADER" -s --location "$URL" | tar xz -C bin/ ;; +esac