-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for validating schema files. (#4)
* Add tests for validating schema files. Run lint programs and try to use the latest PyDAX to load each dataset once. * Missing space * Missing license header in tox.ini * Update tox.ini Co-authored-by: Brendan Dwyer <brendan.dwyer@ibm.com> * Update tox.ini Co-authored-by: Brendan Dwyer <brendan.dwyer@ibm.com> * Only run flake8 on the tests dir * Add some assertions to ensure that dataset names and versions match so that pydax doesn't miss any datasets during this test * Load the local files instead of trying to load remote ones Otherwise this script won't be testing the new changes * Sanity check Co-authored-by: Brendan Dwyer <brendan.dwyer@ibm.com>
- Loading branch information
Showing
10 changed files
with
278 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,27 @@ | ||
# | ||
# Copyright 2020 IBM Corp. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "pip" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains 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,63 @@ | ||
# | ||
# Copyright 2020 IBM Corp. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
name: Lint | ||
|
||
on: # yamllint disable-line rule:truthy | ||
push: | ||
branches: 'master' | ||
pull_request: | ||
branches: '*' | ||
|
||
jobs: | ||
test: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.8] | ||
|
||
name: Lint | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Display Python version | ||
run: python -c "import sys; print(sys.version)" | ||
- name: Install Dependencies | ||
run: pip install -U -r requirements/tox.txt | ||
- name: Test | ||
run: tox -e lint -vv | ||
|
||
- name: Notify Slack success | ||
if: ${{ success() && github.event_name == 'push' }} | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.PYDAX_CICD_SLACK_WEBHOOK }} | ||
SLACK_COLOR: good | ||
SLACK_ICON_EMOJI: ":drake-yes:" | ||
SLACK_TITLE: Message (**Lint**) | ||
uses: rtCamp/action-slack-notify@v2 | ||
|
||
- name: Notify Slack failure | ||
if: ${{ failure() && github.event_name == 'push' }} | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.PYDAX_CICD_SLACK_WEBHOOK }} | ||
SLACK_COLOR: danger | ||
SLACK_ICON_EMOJI: ":scott-yikes:" | ||
SLACK_TITLE: Message (**Lint**) | ||
uses: rtCamp/action-slack-notify@v2 |
This file contains 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,63 @@ | ||
# | ||
# Copyright 2020 IBM Corp. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
name: PyDAX | ||
|
||
on: # yamllint disable-line rule:truthy | ||
push: | ||
branches: 'master' | ||
pull_request: | ||
branches: '*' | ||
|
||
jobs: | ||
test: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.9] | ||
|
||
name: PyDAX | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Display Python version | ||
run: python -c "import sys; print(sys.version)" | ||
- name: Install Dependencies | ||
run: pip install -U -r requirements/tox.txt | ||
- name: Test | ||
run: tox -e pydax -vv | ||
|
||
- name: Notify Slack success | ||
if: ${{ success() && github.event_name == 'push' }} | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.PYDAX_CICD_SLACK_WEBHOOK }} | ||
SLACK_COLOR: good | ||
SLACK_ICON_EMOJI: ":drake-yes:" | ||
SLACK_TITLE: Message (**PyDAX**) | ||
uses: rtCamp/action-slack-notify@v2 | ||
|
||
- name: Notify Slack failure | ||
if: ${{ failure() && github.event_name == 'push' }} | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.PYDAX_CICD_SLACK_WEBHOOK }} | ||
SLACK_COLOR: danger | ||
SLACK_ICON_EMOJI: ":scott-yikes:" | ||
SLACK_TITLE: Message (**PyDAX**) | ||
uses: rtCamp/action-slack-notify@v2 |
This file contains 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,25 @@ | ||
# | ||
# Copyright 2020 IBM Corp. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
extends: default | ||
|
||
ignore: | | ||
.tox | ||
rules: | ||
document-start: | ||
present: false | ||
line-length: disable |
This file contains 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 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,2 @@ | ||
flake8 == 3.8.4 | ||
yamllint == 1.25.0 |
This file contains 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 @@ | ||
git+https://github.com/codait/pydax |
This file contains 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 @@ | ||
tox == 3.20.1 |
This file contains 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,48 @@ | ||
#!/bin/env python | ||
|
||
# | ||
# Copyright 2020 IBM Corp. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# This scripts tests all files in CODAIT/dax-schemata. It shouldn't report any error. | ||
|
||
import yaml | ||
|
||
import pydax | ||
|
||
|
||
pydax.init( | ||
DEFAULT_DATASET_SCHEMA_URL='datasets.yaml', | ||
DEFAULT_FORMAT_SCHEMA_URL='formats.yaml', | ||
DEFAULT_LICENSE_SCHEMA_URL='licenses.yaml' | ||
) | ||
|
||
with open('datasets.yaml') as f: | ||
datasets = yaml.safe_load(f) | ||
|
||
# Datasets name are the same from the schema files. This helps ensure that PyDAX doesn't miss any dataset during the | ||
# test. | ||
assert frozenset(datasets['datasets']) == frozenset(pydax.list_all_datasets()) | ||
# Sanity check. In case of all tests being skipped because of a minor error such as in formatting. | ||
assert len(pydax.list_all_datasets()) > 0 | ||
|
||
for name, versions in pydax.list_all_datasets().items(): | ||
# Versions must be the same from the schema files. This helps ensure that PyDAX doesn't miss any dataset during the | ||
# test. | ||
assert frozenset(datasets['datasets'][name]) == frozenset(versions) | ||
# Sanity check. In case of all tests being skipped because of a minor error such as in formatting. | ||
assert len(versions) > 0 | ||
for version in versions: | ||
pydax.load_dataset(name=name, version=version, subdatasets=None) |
This file contains 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,38 @@ | ||
# | ||
# Copyright 2020 IBM Corp. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
[tox] | ||
envlist = lint, pydax | ||
skipsdist = true | ||
|
||
[testenv] | ||
download = true | ||
|
||
[testenv:lint] | ||
deps = -r requirements/lint.txt # We put them in this file so dependabot can discover it | ||
commands = | ||
yamllint -c .yamllint.yaml . | ||
flake8 tests | ||
|
||
[testenv:pydax] | ||
# We only let the latest development version of pydax to run these tests for now. After the first | ||
# release, we also need to test with the stable versions. | ||
deps = -r requirements/pydax.txt | ||
commands = {envpython} ./tests/test_pydax.py | ||
|
||
[flake8] | ||
max-line-length = 120 | ||
exclude = .eggs,.git,__pycache__,.tox |