Skip to content

Run Unit Tests

Run Unit Tests #97

---
name: Run Unit Tests
on:
# run at 8am every Monday morning
schedule:
- cron: '0 8 * * 1'
# Run GitHub Actions when the main branch is modified.
# This includes after code changes are merged to main from a PR.
# Merging to main requires the Verde-based Jenkins jobs to pass.
# If this remote GitHub Action fails, it means there is a discrepancy with the
# version of hf_hydrodata installed into the hydrogen-service API.
# If this fails:
# - Trigger a manual re-build of the hydrogen-service Jenkins job to rebuild the API
# - Manually re-run the failing hf_hydrodata GitHub Actions job
push:
branches:
- main
jobs:
runscript:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# update list with desired Python versions to test
python-version: ["3.12"]
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
- name: Register hydrodata credentials as a public user
env:
TEST_EMAIL_PUBLIC: ${{ secrets.TEST_EMAIL_PUBLIC }}
TEST_PIN_PUBLIC: ${{ secrets.TEST_PIN_PUBLIC }}
run: |
python utils/set_credentials.py --public
- name: Run public-access unit tests with pytest
run: |
pytest tests/hf_hydrodata -m "not private_dataset"
- name: Register hydrodata credentials as a user with private dataset access
env:
TEST_EMAIL_PRIVATE: ${{ secrets.TEST_EMAIL_PRIVATE }}
TEST_PIN_PRIVATE: ${{ secrets.TEST_PIN_PRIVATE }}
run: |
python utils/set_credentials.py --private
# Run only the tests that require private dataset access level
- name: Run private-access unit tests with pytest
run: |
pytest tests/hf_hydrodata/test_gridded.py -m private_dataset