From 4c3ac4414892dad51aa77c6ca5fe17c3c0eb5632 Mon Sep 17 00:00:00 2001 From: John Jardine Date: Wed, 20 Nov 2019 20:53:00 -0500 Subject: [PATCH] travis ci scripts --- .travis.yml | 5 ++-- travis_scripts/ci-build.sh | 38 -------------------------- travis_scripts/validate-file.py | 48 --------------------------------- 3 files changed, 3 insertions(+), 88 deletions(-) mode change 100644 => 100755 .travis.yml delete mode 100644 travis_scripts/ci-build.sh delete mode 100644 travis_scripts/validate-file.py diff --git a/.travis.yml b/.travis.yml old mode 100644 new mode 100755 index 41564bf..a0c509a --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,8 @@ cache: - travis_cache before_install: - - chmod +x ./travis_scripts/ci-build.sh - npm install remark-cli remark-validate-links -script: ./travis_scripts/ci-build.sh +script: + - git clone https://github.com/VoronDesign/GithubScripts.git .github_scripts + - /bin/bash ./.github_scripts/travis/ci-build.sh diff --git a/travis_scripts/ci-build.sh b/travis_scripts/ci-build.sh deleted file mode 100644 index 65cd75f..0000000 --- a/travis_scripts/ci-build.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -BASE_DIR=${PWD} -CACHE_DIR=${PWD}/travis_cache - -chmod +x ${BASE_DIR}/travis_scripts/*.py - -ADMESH_DIR=${CACHE_DIR}/admesh-0.98.4 -mkdir -p ${CACHE_DIR} -cd ${CACHE_DIR} -if [ ! -d ${ADMESH_DIR} ]; then - echo "Admesh cache miss; fetching and building ..." - wget https://github.com/admesh/admesh/releases/download/v0.98.4/admesh-0.98.4.tar.gz - tar -zxf admesh-0.98.4.tar.gz - cd ${ADMESH_DIR} - ./configure - make - chmod +x admesh -fi -cd ${BASE_DIR} -sudo ln -s ${ADMESH_DIR}/admesh /usr/bin/admesh - -if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then - # Compare branch against master - git remote set-branches --add origin master - git fetch - git diff --name-only --diff-filter=AMR origin/master | xargs -n 1 -I {} ${BASE_DIR}/travis_scripts/validate-file.py ${BASE_DIR}/{} -else - # Compare head against the branch to merge into (PR) - git diff --name-only --diff-filter=AMR -R HEAD origin/${TRAVIS_BRANCH} | xargs -n 1 -I {} ${BASE_DIR}/travis_scripts/validate-file.py ${BASE_DIR}/{} -fi - -cd ${BASE_DIR} - -# Validate all markdown files (eg, README.md). -remark -u validate-links --no-stdout --frail . - - diff --git a/travis_scripts/validate-file.py b/travis_scripts/validate-file.py deleted file mode 100644 index cf8317f..0000000 --- a/travis_scripts/validate-file.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/python3 -import subprocess, re, os, sys, getopt - -def read_param(text, parameter): - matches = re.search("(" + parameter + ")\s+\:\s+(\d+)", text) - #print(matches) - if matches: - # The decimal group - return int(matches.group(2)) - else: - # Uh oh, no match - print ("Could not find {0}".format(parameter)) - exit(1) - -def assert_param_threshold(result, parameter, threshold): - param_val = read_param(result, parameter) - if param_val > threshold: - print ("!! Detected \"{0}\" value of {1}".format(parameter, param_val)) - exit(1) - #else: - #print ("{0} value OK".format(parameter)) - -def process_stl(filename): - cmd = "admesh \"{0}\"".format(filename) - print ("Validating STL {0}".format(filename)) - result = subprocess.run(cmd, shell=True, check=True, stdout=subprocess.PIPE) - output = str(result.stdout) - - assert_param_threshold(output, "Edges fixed", 0) - assert_param_threshold(output, "Backwards edges", 0) - assert_param_threshold(output, "Degenerate facets", 0) - assert_param_threshold(output, "Facets removed", 0) - assert_param_threshold(output, "Facets added", 0) - assert_param_threshold(output, "Facets reversed", 0) - -def process_markdown(filename): - cmd = "remark -u validate-links --no-stdout --frail \"{0}\"".format(filename) - print ("Validating Markdown {0}".format(filename)) - subprocess.run(cmd, shell=True, check=True) - -def main(argv): - argument = " ".join(sys.argv[1:]) - - if argument.lower().endswith(".stl"): - process_stl(argument) - -if __name__ == "__main__": - main(sys.argv[1:])