Refactor readme_parser to remove regex for boolean conversion and add… #526
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
| name: Test VFBquery Examples | |
| on: | |
| push: | |
| pull_request: | |
| workflow_dispatch: # Enables manual triggering | |
| schedule: | |
| - cron: '0 0 1 * *' # Runs at 00:00 UTC on the 1st day of every month | |
| jobs: | |
| test-examples: | |
| 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.8 | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install deepdiff colorama | |
| pip install . | |
| - name: Check SOLR availability | |
| run: | | |
| python -c " | |
| import os | |
| try: | |
| import vfbquery as vfb | |
| result = vfb.get_term_info('FBbt_00003748') | |
| with open(os.environ['GITHUB_ENV'], 'a') as f: | |
| f.write('SOLR_AVAILABLE=true\n') | |
| print('SOLR is available') | |
| except Exception as e: | |
| print('SOLR not available:', e) | |
| with open(os.environ['GITHUB_ENV'], 'a') as f: | |
| f.write('SOLR_AVAILABLE=false\n') | |
| exit(1) | |
| " | |
| - name: Run examples from README.md | |
| run: | | |
| cat README.md | grep -e '```python' -e '```' -e '^[^`]*$' | sed -e '/^```python/,/^```/!d' -e '/^```/d' -e 's/\(vfb\.[^(]*([^)]*)\)/print(\1)/g' > test_examples.py | |
| cat test_examples.py | |
| export VFBQUERY_CACHE_ENABLED=false | |
| python test_examples.py | |
| - name: Parse README.md and generate test files | |
| run: | | |
| python -m src.test.readme_parser | |
| env: | |
| PYTHONPATH: ${{ github.workspace }} | |
| if: env.SOLR_AVAILABLE == 'true' | |
| - name: Run examples from README.md and compare JSON outputs | |
| run: | | |
| python -m src.test.test_examples_diff | |
| env: | |
| PYTHONPATH: ${{ github.workspace }} | |
| if: env.SOLR_AVAILABLE == 'true' |