-
Notifications
You must be signed in to change notification settings - Fork 8
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 8 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 "::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) | ||
|
e-lo marked this conversation as resolved.
Outdated
|
||
| results+="$result\n" | ||
|
botanize marked this conversation as resolved.
|
||
| done | ||
| echo "::set-output name=results::$results" | ||
|
e-lo marked this conversation as resolved.
Outdated
|
||
| - 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 = ''; | ||
| } else if (result.stats.errorCount > 0) { | ||
| status = ''; | ||
| } else { | ||
| status = ''; | ||
|
botanize marked this conversation as resolved.
Outdated
|
||
| } | ||
| 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
| 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,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 | ||
|
botanize marked this conversation as resolved.
Outdated
botanize marked this conversation as resolved.
Outdated
|
||
|
|
||
| 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 | ||
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.