From 4a34acd613a1f25d99fc1215ec4b1069ebde777f Mon Sep 17 00:00:00 2001 From: Gabriel Gonzalez Date: Fri, 8 May 2020 09:04:45 -0700 Subject: [PATCH] Remove dead code (#118) These scripts are obsolete and have been replaced by Nix code in `./nix/nixpkgs.nix` --- scripts/build-examples.py | 73 --------------------------------------- scripts/build-readme.sh | 9 ----- scripts/check-source.py | 34 ------------------ scripts/update-nixpkgs.sh | 4 --- 4 files changed, 120 deletions(-) delete mode 100755 scripts/build-examples.py delete mode 100755 scripts/build-readme.sh delete mode 100755 scripts/check-source.py delete mode 100755 scripts/update-nixpkgs.sh diff --git a/scripts/build-examples.py b/scripts/build-examples.py deleted file mode 100755 index 1d161328..00000000 --- a/scripts/build-examples.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env python3 -# -# Build YAML files from the example Dhall sources. -# -# An optional second argument determines the directory to write the YAML -# files to. Defaults to the exmaples directory. -# -# Also checks that the generated files do not differ from what is -# checked into source control. We list all generated files that differ -# and exit with status code 1 if the list is non-empty. - -import os -from subprocess import run, DEVNULL -import sys - -examples_dir = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', 'examples')) -examples = [ - 'deploymentSimple', - 'deployment', - 'ingress', - 'service' -] - -TERM_FAIL = '\033[91m' -TERM_CLEAR = '\033[0m' - - -def check_clean(path_1, path_2): - if path_1 == path_2: - cmd = ['git', 'diff', '--exit-code', '--', path_1] - else: - cmd = ['diff', '--unified', '--', path_1, path_2] - - result = run(cmd, check=False, stdout=DEVNULL) - if result.returncode == 0: - return True - elif result.returncode == 1: - return False - else: - # Raises a `CalledProcessError` - result.check_returncode() - - -def build_yaml (example, out_dir): - source = os.path.join(examples_dir, example + '.dhall') - print('Building {}'.format(source)) - target = os.path.join(out_dir, example + '.yaml') - expected = os.path.join(examples_dir, 'out', example + '.yaml') - cmd = 'dhall-to-yaml --omitEmpty <<< "./{source}" >{target}'.format(source=source, target=target) - run(cmd, shell=True, executable='bash', check=True) - return check_clean(expected, target) - - -def main(): - if len(sys.argv) >= 2: - out_dir = sys.argv[1] - else: - out_dir = os.path.join(examples_dir, 'out') - - clean_failures = [] - for example in examples: - is_clean = build_yaml(example, out_dir) - if is_clean == False: - clean_failures.append(example + '.yaml') - - if len(clean_failures) > 0: - print(TERM_FAIL + 'Clean check failed. The following files differ' + TERM_CLEAR) - for failure in clean_failures: - print(' ' + failure) - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/scripts/build-readme.sh b/scripts/build-readme.sh deleted file mode 100755 index 0afe7f74..00000000 --- a/scripts/build-readme.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -if [[ -z $1 ]]; then - output=README.md -else - output="$1" -fi - -LC_ALL=en_US.UTF-8 dhall text <<< './docs/README.md.dhall' > $output diff --git a/scripts/check-source.py b/scripts/check-source.py deleted file mode 100755 index 097e7b84..00000000 --- a/scripts/check-source.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 -# -# Typecheck and resolve all Dhall files in the ./default directory. -# -# Exit with 1 if at least one file fails to check. -# -# Some files are ingnored because they have existing errors. - -import sys -from glob import glob -from subprocess import run, DEVNULL, PIPE - -# We skip tests for the following set of files -ignored_failures = { -} - -default_files = glob('./defaults/*.dhall') -failure_files = set() -for default_file in default_files: - if default_file in ignored_failures: - print('Skipping {}'.format(default_file)) - continue - print('Checking {}'.format(default_file)) - cmd = 'dhall resolve <<< {file}'.format(file=default_file) - result = run(cmd, shell=True, executable='bash', stdout=DEVNULL, stderr=PIPE) - if result.returncode != 0: - print(result.stderr.decode('utf-8')) - failure_files.add(default_file) - -if len(failure_files) > 0: - print('The following files failed to check:') - for failure_file in failure_files: - print(' ' + failure_file) - sys.exit(1) diff --git a/scripts/update-nixpkgs.sh b/scripts/update-nixpkgs.sh deleted file mode 100755 index ae6d332d..00000000 --- a/scripts/update-nixpkgs.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -i bash -p nix-prefetch-git - -nix-prefetch-git https://github.com/nixos/nixpkgs-channels.git --rev refs/heads/nixos-unstable > ./nix/nixpkgs.json