Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script to validate test cases against the problem specifications. #450

Merged
merged 3 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bin/configlet
bin/configlet.exe
bin/canonical_data_syncer
10 changes: 10 additions & 0 deletions bin/check_test_cases
Original file line number Diff line number Diff line change
@@ -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 "$@"
52 changes: 52 additions & 0 deletions bin/fetch-canonical_data_syncer
Original file line number Diff line number Diff line change
@@ -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