-
Notifications
You must be signed in to change notification settings - Fork 7
Add github workflow to validate samples #104
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ebabddc
Add github workflow to validate samples
e-lo 22593cf
remove using frictionless repository
e-lo b7bf61e
Merge remote-tracking branch 'upstream/main' into add-validation-work…
e-lo 2f6d667
lint / update pre-commit config to default to push
e-lo e2f5327
lint
e-lo a720ff2
Shifts from using frictionless framework to frictionless package
e-lo 1500b1c
Adds local testing/validation script
e-lo daf934a
Updates documentation for testing since this should fix the highlight…
e-lo ee00bcc
eliminate noisy print stmt in main.py
e-lo c2cc5a4
Move tests to separate scripts in /tests dir
e-lo 3321da5
add recommendation to use a virtual environment and include links
e-lo 77e4291
Addressed PR review comments:
e-lo 1fa7ca2
Fix glob search in validate_samples
e-lo 778c2aa
Fix test progress tracking
e-lo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| 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: 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 "{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 --schema-sync "$sample/datapackage.json" --json) | ||
| results+="$result\n" | ||
| done | ||
| 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 = '${{ 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'; | ||
| for (let i = 0; i < samples.length; i++) { | ||
| const sample = samples[i]; | ||
| const result = JSON.parse(results[i]); | ||
| let status = ''; | ||
| if (result.valid) { | ||
| status = ':heavy_check_mark:'; | ||
| } else if (result.stats.errorCount > 0) { | ||
| status = ':x:'; | ||
| } else { | ||
| status = ':warning:'; | ||
| } | ||
| comment += `| ${sample} | ${status} |\n`; | ||
| } | ||
| github.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: comment | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| -r docs/requirements.txt | ||
| pre-commit | ||
| frictionless | ||
| jsonschema | ||
| jsonschema-cli | ||
| pre-commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #!/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)) | ||
| test_num=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 | ||
| ((test_num++)) | ||
| if [ -x "$script_file" ]; then | ||
| # Update progress | ||
| 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 | ||
| 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_files: 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #!/usr/bin/env bash | ||
| echo "Validating sample data" | ||
| shopt -s nullglob | ||
| for file in samples/*/TIDES/datapackage.json; do | ||
| echo "Validating: $file" | ||
| frictionless validate --schema-sync $file | ||
| done | ||
| shopt -u nullglob |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.