From ebabddcdea9d660b06f70d031f3f858d70b967bb Mon Sep 17 00:00:00 2001 From: Elizabeth Sall Date: Wed, 1 Feb 2023 09:39:11 -0800 Subject: [PATCH 01/13] Add github workflow to validate samples Uses frictionlessdata/repository - which doesn't allow flag `--schema-sync` so will likely need to modify --- .github/workflows/validate_samples.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/validate_samples.yml diff --git a/.github/workflows/validate_samples.yml b/.github/workflows/validate_samples.yml new file mode 100644 index 00000000..6aed602f --- /dev/null +++ b/.github/workflows/validate_samples.yml @@ -0,0 +1,24 @@ +name: Validate-Samples + +on: + push: + paths: + - 'samples/*/TIDES/*' + - 'spec/*' + pull_request: + paths: + - 'samples/*/TIDES/*' + - 'spec/*' + workflow_dispatch: + create: + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Validate sample data + uses: frictionlessdata/repository@v2 + with: + packages: "samples/*/TIDES/datapackage.json" From 22593cfbc4f37faef46b7f76558aac56575ed18b Mon Sep 17 00:00:00 2001 From: Elizabeth Sall Date: Tue, 11 Jul 2023 13:41:13 -0700 Subject: [PATCH 02/13] remove using frictionless repository --- .github/workflows/validate_samples.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/validate_samples.yml b/.github/workflows/validate_samples.yml index 6aed602f..5d367d47 100644 --- a/.github/workflows/validate_samples.yml +++ b/.github/workflows/validate_samples.yml @@ -18,7 +18,5 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v2 - - name: Validate sample data - uses: frictionlessdata/repository@v2 - with: - packages: "samples/*/TIDES/datapackage.json" + - name: + run: pip install frictionless[excel,json]>=5.0.0 From 2f6d6673c7a5d8389bffa0a50f7fc9f9febf0441 Mon Sep 17 00:00:00 2001 From: Elizabeth Sall Date: Tue, 11 Jul 2023 15:21:09 -0700 Subject: [PATCH 03/13] lint / update pre-commit config to default to push --- .github/workflows/docs.yml | 4 ++-- .pre-commit-config.yaml | 9 +++++++++ mkdocs.yml | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 55ebb430..166775d6 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -22,9 +22,9 @@ jobs: echo "Slug=$(echo "${{ github.head_ref }}" | sed "s/\//\-/g")" >> "$GITHUB_ENV" - name: If no github.head_ref, use last chunk of github.ref as Slug if: github.head_ref == '' - run: | + run: | IFS="\/"; - read -a strarr <<< "${{ github.ref }}"; + read -a strarr <<< "${{ github.ref }}"; last_ref="${strarr[${#strarr[*]}-1]}"; echo "Slug=$(echo $last_ref)" >> "$GITHUB_ENV" - name: Document which reference diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f6a2c278..4ac8cd89 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,24 +1,33 @@ +default_stages: [push] repos: - repo: https://github.com/psf/black rev: 22.8.0 hooks: - id: black + stages: [commit] - repo: https://github.com/pycqa/flake8 rev: 5.0.4 hooks: - id: flake8 + stages: [commit] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 hooks: - id: trailing-whitespace args: [--markdown-linebreak-ext=md] + stages: [commit] - id: end-of-file-fixer + stages: [commit] - id: check-yaml args: ["--unsafe"] + stages: [commit] - id: check-added-large-files - id: check-json + stages: [commit] - id: requirements-txt-fixer + stages: [commit] - id: mixed-line-ending + stages: [commit] - repo: https://github.com/igorshubovych/markdownlint-cli rev: v0.32.2 hooks: diff --git a/mkdocs.yml b/mkdocs.yml index bec3855a..aae3d55c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -58,7 +58,7 @@ markdown_extensions: - pymdownx.tasklist: custom_checkbox: true - pymdownx.tabbed: - alternate_style: true + alternate_style: true - pymdownx.superfences: custom_fences: - name: mermaid From e2f5327eaab97d031946c23d21921d340150e1a6 Mon Sep 17 00:00:00 2001 From: Elizabeth Sall Date: Tue, 11 Jul 2023 15:21:44 -0700 Subject: [PATCH 04/13] lint --- .github/workflows/clean-docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clean-docs.yml b/.github/workflows/clean-docs.yml index e975519b..9b1b2c05 100644 --- a/.github/workflows/clean-docs.yml +++ b/.github/workflows/clean-docs.yml @@ -14,9 +14,9 @@ jobs: echo "Slug=$(echo "${{ github.head_ref }}" | sed "s/\//\-/g")" >> "$GITHUB_ENV" - name: If no github.head_ref, use last chunk of github.ref as Slug if: github.head_ref == '' - run: | + run: | IFS="\/"; - read -a strarr <<< "${{ github.ref }}"; + read -a strarr <<< "${{ github.ref }}"; last_ref="${strarr[${#strarr[*]}-1]}"; echo "Slug=$(echo $last_ref)" >> "$GITHUB_ENV" - name: Document which reference From a720ff21ec5991fc69af821eb2b92cb9c5c49430 Mon Sep 17 00:00:00 2001 From: Elizabeth Sall Date: Tue, 11 Jul 2023 15:23:06 -0700 Subject: [PATCH 05/13] Shifts from using frictionless framework to frictionless package ...so we can use --schema-sync Also publishes a comment with the validation of sample data. Need sample data really to test effectively. --- .github/workflows/validate_samples.yml | 52 +++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/.github/workflows/validate_samples.yml b/.github/workflows/validate_samples.yml index 5d367d47..2de19748 100644 --- a/.github/workflows/validate_samples.yml +++ b/.github/workflows/validate_samples.yml @@ -18,5 +18,55 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v2 - - name: + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + - name: Install Frictionless run: pip install frictionless[excel,json]>=5.0.0 + - name: Find Sample Folders + id: sample_folders + run: | + pwd + samples=$(find ./samples -type d -name 'TIDES') + echo "::set-output name=samples::$samples" + - name: Validate Sample Data + id: validation + run: | + samples=(${{ steps.sample_folders.outputs.samples }}) + results="" + for sample in "${samples[@]}"; do + result=$(frictionless validate "$sample/datapackage.json" --json) + results+="$result\n" + done + echo "::set-output name=results::$results" + - name: Comment on PR + if: github.event_name == 'pull_request' + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const samples = '${{ steps.sample_folders.outputs.samples }}'.trim().split('\n'); + const results = '${{ steps.validation.outputs.results }}'.trim().split('\n'); + let comment = `**Data Validation Report**\n\n`; + comment += '| Sample | Status |\n'; + comment += '| ------ | ------ |\n'; + for (let i = 0; i < samples.length; i++) { + const sample = samples[i]; + const result = JSON.parse(results[i]); + let status = ''; + if (result.valid) { + status = '![passing](https://via.placeholder.com/20/00ff00/000000?text=+)'; + } else if (result.stats.errorCount > 0) { + status = '![failing](https://via.placeholder.com/20/ff0000/000000?text=+)'; + } else { + status = '![warning](https://via.placeholder.com/20/ffff00/000000?text=+)'; + } + comment += `| ${sample} | ${status} |\n`; + } + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment + }); From 1500b1c0985ed0609eb480495477a603b9b220fd Mon Sep 17 00:00:00 2001 From: Elizabeth Sall Date: Tue, 11 Jul 2023 15:23:42 -0700 Subject: [PATCH 06/13] Adds local testing/validation script So you don't need to copy/paste from documentation --- requirements.txt | 4 +++- test | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 test diff --git a/requirements.txt b/requirements.txt index 7043a64b..39184e02 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ -r docs/requirements.txt -pre-commit frictionless +jsonschema +jsonschema-cli +pre-commit diff --git a/test b/test new file mode 100755 index 00000000..3af9f108 --- /dev/null +++ b/test @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# Local validation workflows and try to build documentation locally +echo "1/5 Running precommit" +pre-commit run --all-files + +echo "2/5 Validating table schemas" +pre-commit run --all-files +echo "Processing file: $file" +for file in spec/*schema.json; do + echo "Validating: $file" + frictionless validate $file +done + +echo "3/5 Validating datapackage" +json-schema-cli validate https://specs.frictionlessdata.io/schemas/data-package.json spec/datapackage.json + +echo "4/5 Validating sample data" +for file in samples/**/TIDES/datapackage.json; do + echo "Validating: $file" + frictionless validate --schema-sync $file +done + +echo "5/5 Building documentation" +mkdocs build From daf934a5ba791fc07c23fe3848cdde65d4b3d309 Mon Sep 17 00:00:00 2001 From: Elizabeth Sall Date: Tue, 11 Jul 2023 15:24:00 -0700 Subject: [PATCH 07/13] Updates documentation for testing since this should fix the highlighted issues. --- CONTRIBUTING.md | 46 +++------------------------------------------- 1 file changed, 3 insertions(+), 43 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fddf83c5..449f2f0c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,49 +30,9 @@ By making any contribution to the projects, contributors self-certify to the [Co 1. [Create a branch](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository) to work on a new issue (or checkout an existing one where the issue is being worked on). 2. Make your changes. -3. Run `pre-commit run --all` to check and fix formatting. -4. Validate schemas if you have changed them using either [act](https://github.com/nektos/act) or [frictionless framework](https://framework.frictionlessdata.io/). -5. [Commit](#commits) your work in `git` -6. `push` your changes to Github and submit a [`pull request`](#pull-requests) - -!!! bug - - Right now some github actions are broken due to some dependencies issues, so please validate changes to schemas using the [frictionless framework](https://framework.frictionlessdata.io/) - -??? tip "Manually Validating TIDES Schema Files with Frictionless" - - === "CLI" - - ```sh - frictionless validate spec/devices.schema.json - frictionless validate spec/fare_transactions.schema.json - frictionless validate spec/operators.schema.json - frictionless validate spec/passenger_events.schema.json - frictionless validate spec/station_activities.schema.json - frictionless validate spec/stop_visits.schema.json - frictionless validate spec/train_cars.schema.json - frictionless validate spec/trips_performed.schema.json - frictionless validate spec/vehicle_locations.schema.json - frictionless validate spec/vehicle_train_cars.schema.json - frictionless validate spec/vehicles.schema.json - ``` - - === "python" - - ```python - import glob - from pprint import pprint - from frictionless import validate - - schema_paths = glob.glob("spec/**.schema.json") - for p in schema_paths: - report = validate(p) - if not report['valid']: - print(f"!!! Invalid:{p}") - pprint(report) - else: - print(f"Valid:{p}") - ``` +3. Run `./test` script to check and fix formatting, validate schemas, and build documentation locally to preview +4. [Commit](#commits) your work in `git` +5. `push` your changes to Github and submit a [`pull request`](#pull-requests) ### Issues From ee00bccca556c9ddb24be7cec79dd8c025fb8a87 Mon Sep 17 00:00:00 2001 From: Elizabeth Sall Date: Wed, 12 Jul 2023 10:51:02 -0700 Subject: [PATCH 08/13] eliminate noisy print stmt in main.py --- main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main.py b/main.py index 820c0711..fada5b1f 100644 --- a/main.py +++ b/main.py @@ -57,9 +57,8 @@ def include_file( 4: re.compile(r"(#{4}\s)(.*)"), 5: re.compile(r"(#{5}\s)(.*)"), } - print(f"???before downshifting! {full_filename}") + if md_heading_re[1].search(content) and downshift_h1: - print("!!!downshifting!") content = re.sub(md_heading_re[5], r"#\1\2", content) content = re.sub(md_heading_re[4], r"#\1\2", content) content = re.sub(md_heading_re[3], r"#\1\2", content) From c2cc5a41a0352c327bd6ac20c1224d56e1217642 Mon Sep 17 00:00:00 2001 From: Elizabeth Sall Date: Wed, 12 Jul 2023 10:52:43 -0700 Subject: [PATCH 09/13] Move tests to separate scripts in /tests dir Script will find all executables in /tests and run them. validate_profile script now downloads the json-schema for profiles from URL Also: - update docs - fix script --- CONTRIBUTING.md | 2 +- test | 24 ------------------ tests/test_all | 47 ++++++++++++++++++++++++++++++++++++ tests/validate_profile | 18 ++++++++++++++ tests/validate_samples | 6 +++++ tests/validate_table_schemas | 9 +++++++ 6 files changed, 81 insertions(+), 25 deletions(-) delete mode 100755 test create mode 100755 tests/test_all create mode 100755 tests/validate_profile create mode 100755 tests/validate_samples create mode 100755 tests/validate_table_schemas diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 449f2f0c..a562b12d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,7 +30,7 @@ By making any contribution to the projects, contributors self-certify to the [Co 1. [Create a branch](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository) to work on a new issue (or checkout an existing one where the issue is being worked on). 2. Make your changes. -3. Run `./test` script to check and fix formatting, validate schemas, and build documentation locally to preview +3. Run `/tests/test_all` script to check and fix formatting, validate schemas, and build documentation locally to preview 4. [Commit](#commits) your work in `git` 5. `push` your changes to Github and submit a [`pull request`](#pull-requests) diff --git a/test b/test deleted file mode 100755 index 3af9f108..00000000 --- a/test +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash -# Local validation workflows and try to build documentation locally -echo "1/5 Running precommit" -pre-commit run --all-files - -echo "2/5 Validating table schemas" -pre-commit run --all-files -echo "Processing file: $file" -for file in spec/*schema.json; do - echo "Validating: $file" - frictionless validate $file -done - -echo "3/5 Validating datapackage" -json-schema-cli validate https://specs.frictionlessdata.io/schemas/data-package.json spec/datapackage.json - -echo "4/5 Validating sample data" -for file in samples/**/TIDES/datapackage.json; do - echo "Validating: $file" - frictionless validate --schema-sync $file -done - -echo "5/5 Building documentation" -mkdocs build diff --git a/tests/test_all b/tests/test_all new file mode 100755 index 00000000..419e5406 --- /dev/null +++ b/tests/test_all @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# Runs pre-commit, then all the scripts in this dir, and then builds documentaiton locally + +# Get the list of script files in the directory +script_files=("$(dirname "$(realpath "$0")")"/*) +num_files=$((${#script_files[@]} + 1)) +error_scripts=() + +echo "Found $num_files tests" + +echo "----- Running test 1 of $num_files: pre-commit" +pre-commit run --all-files + +# Iterate over script files in the directory +for script_file in "${script_files[@]}"; do + + # Exclude the current script and non-executable files from execution + if [ "$(basename "$script_file")" != "test_all" ]; then + if [ -x "$script_file" ]; then + # Update progress + echo "----- Running test $((i + 1)) of $num_files: $script_file" + + # Execute the script and capture errors if there are any + if output=$("$script_file" 2>&1); then + echo ":-) $script_file ran successfully." + else + echo "!!! $script_file encountered an error." + error_scripts+=("$script_file") + echo "$output" >&2 + fi + else + # Notify non-executable files + echo "!!! File is not executable so was not run: $script_file." + echo + fi + fi +done +echo "----- Running test $num_files/$num_file: Building documentation locally" +mkdocs build --quiet + +if [ ${#error_scripts[@]} -gt 0 ]; then + echo "The following scripts executed with errors:" + for script in "${error_scripts[@]}"; do + echo "$script" + done +fi diff --git a/tests/validate_profile b/tests/validate_profile new file mode 100755 index 00000000..81f4ddd1 --- /dev/null +++ b/tests/validate_profile @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +echo "Validating tides-data-package.json profile" + +# Set the temporary directory path +temp_dir=$(mktemp -d) + +# Download the schema file to the temporary directory +schema_url="https://specs.frictionlessdata.io/schemas/data-package.json" +schema_file="$temp_dir/data-package.json" +curl -o "$schema_file" "$schema_url" + +# Validate datapackage against the downloaded schema +datapackage_file="spec/tides-data.json" +jsonschema-cli validate "$schema_file" "$datapackage_file" + +# Clean up the temporary directory +rm -rf "$temp_dir" diff --git a/tests/validate_samples b/tests/validate_samples new file mode 100755 index 00000000..bcaa5f94 --- /dev/null +++ b/tests/validate_samples @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +echo "Validating sample data" +for file in samples/**/TIDES/datapackage.json; do + echo "Validating: $file" + frictionless validate --schema-sync $file +done diff --git a/tests/validate_table_schemas b/tests/validate_table_schemas new file mode 100755 index 00000000..7af96f9c --- /dev/null +++ b/tests/validate_table_schemas @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +echo "Validating table schemas" + +echo "Processing file: $file" +for file in spec/*schema.json; do + echo "Validating: $file" + frictionless validate $file +done From 3321da59c83a78b6750d10a9c63ece01af794a15 Mon Sep 17 00:00:00 2001 From: Elizabeth Sall Date: Wed, 12 Jul 2023 10:59:42 -0700 Subject: [PATCH 10/13] add recommendation to use a virtual environment and include links --- CONTRIBUTING.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a562b12d..38c82a11 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,7 +24,11 @@ By making any contribution to the projects, contributors self-certify to the [Co 1. Make sure you have a [GitHub](https://github.com/) account. 2. Make sure you have [git](https://git-scm.com/downloads), a terminal (e.g. Mac Terminal, CygWin, etc.), and a text editor installed on your local machine. Optionally, you will likely find it easier to use [GitHub Desktop](https://desktop.github.com/), an IDE instead of a simple text editor like [VSCode](https://code.visualstudio.com/), [Eclipse](https://www.eclipse.org/), [Sublime Text](https://www.sublimetext.com/), etc. 3. [Fork the repository](https://github.com/TIDES-transit/TIDES/fork) into your own GitHub account and [clone it locally](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository). -4. Install development requirements packages `pip install -r requirements.txt` +4. Install development requirements packages `pip install -r requirements.txt` or in a virtual environment. + +!!! tip "Using a virtual environment" + + It is often helpful to install requirements for vairous projects inside a virtual environment rather than in your main python installation. Some virtual environments to consider include: [`conda`](https://docs.conda.io/),[`pipenv`](https://pipenv.pypa.io/en/latest/index.html),[`poetry`](https://python-poetry.org/), and [`rye`](https://github.com/mitsuhiko/rye). ### Contribution Workflow From 77e4291387791321f092fc26f21eb8dfddbfab81 Mon Sep 17 00:00:00 2001 From: Elizabeth Sall Date: Wed, 12 Jul 2023 11:54:30 -0700 Subject: [PATCH 11/13] Addressed PR review comments: set-output --> $GITHUB_ENV external placeholder.com --> octocons + schema-sync --- .github/workflows/validate_samples.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/validate_samples.yml b/.github/workflows/validate_samples.yml index 2de19748..6e05dc2e 100644 --- a/.github/workflows/validate_samples.yml +++ b/.github/workflows/validate_samples.yml @@ -29,25 +29,25 @@ jobs: run: | pwd samples=$(find ./samples -type d -name 'TIDES') - echo "::set-output name=samples::$samples" + echo "{name}={value}" >> $GITHUB_OUTPUT - name: Validate Sample Data id: validation run: | samples=(${{ steps.sample_folders.outputs.samples }}) results="" for sample in "${samples[@]}"; do - result=$(frictionless validate "$sample/datapackage.json" --json) + result=$(frictionless validate --schema-sync "$sample/datapackage.json" --json) results+="$result\n" done - echo "::set-output name=results::$results" + echo "{name}=${results}" >> $GITHUB_ENV - name: Comment on PR if: github.event_name == 'pull_request' uses: actions/github-script@v4 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const samples = '${{ steps.sample_folders.outputs.samples }}'.trim().split('\n'); - const results = '${{ steps.validation.outputs.results }}'.trim().split('\n'); + const samples = '${{ env.samples }}'.trim().split('\n'); + const results = '${{ env.results }}'.trim().split('\n'); let comment = `**Data Validation Report**\n\n`; comment += '| Sample | Status |\n'; comment += '| ------ | ------ |\n'; @@ -56,17 +56,17 @@ jobs: const result = JSON.parse(results[i]); let status = ''; if (result.valid) { - status = '![passing](https://via.placeholder.com/20/00ff00/000000?text=+)'; + status = ':heavy_check_mark:'; } else if (result.stats.errorCount > 0) { - status = '![failing](https://via.placeholder.com/20/ff0000/000000?text=+)'; + status = ':x:'; } else { - status = '![warning](https://via.placeholder.com/20/ffff00/000000?text=+)'; + status = ':warning:'; } comment += `| ${sample} | ${status} |\n`; } github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: comment - }); + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment + }); From 1fa7ca2eacf43d07a38236d4d1d8b80f152807d5 Mon Sep 17 00:00:00 2001 From: Elizabeth Sall Date: Wed, 12 Jul 2023 12:04:50 -0700 Subject: [PATCH 12/13] Fix glob search in validate_samples + nullglob ** --> * --- tests/validate_samples | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/validate_samples b/tests/validate_samples index bcaa5f94..cac8c226 100755 --- a/tests/validate_samples +++ b/tests/validate_samples @@ -1,6 +1,8 @@ #!/usr/bin/env bash echo "Validating sample data" -for file in samples/**/TIDES/datapackage.json; do +shopt -s nullglob +for file in samples/*/TIDES/datapackage.json; do echo "Validating: $file" frictionless validate --schema-sync $file done +shopt -u nullglob From 778c2aafcc0d1670236f4827218b04689873f98a Mon Sep 17 00:00:00 2001 From: Elizabeth Sall Date: Wed, 12 Jul 2023 12:12:12 -0700 Subject: [PATCH 13/13] Fix test progress tracking --- tests/test_all | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_all b/tests/test_all index 419e5406..cfd886da 100755 --- a/tests/test_all +++ b/tests/test_all @@ -5,6 +5,7 @@ # Get the list of script files in the directory script_files=("$(dirname "$(realpath "$0")")"/*) num_files=$((${#script_files[@]} + 1)) +test_num=1 error_scripts=() echo "Found $num_files tests" @@ -17,9 +18,10 @@ for script_file in "${script_files[@]}"; do # Exclude the current script and non-executable files from execution if [ "$(basename "$script_file")" != "test_all" ]; then + ((test_num++)) if [ -x "$script_file" ]; then # Update progress - echo "----- Running test $((i + 1)) of $num_files: $script_file" + echo "----- Running test $test_num of $num_files: $script_file" # Execute the script and capture errors if there are any if output=$("$script_file" 2>&1); then @@ -36,7 +38,7 @@ for script_file in "${script_files[@]}"; do fi fi done -echo "----- Running test $num_files/$num_file: Building documentation locally" +echo "----- Running test $num_files/$num_files: Building documentation locally" mkdocs build --quiet if [ ${#error_scripts[@]} -gt 0 ]; then