Merge pull request #3 from AdvancedPhotonSource/tests #4
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: Tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| # ----------------------------------------------------------------------- | |
| # Downloader tests (~1 min) | |
| # ----------------------------------------------------------------------- | |
| test-downloader: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: src/downloader | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: | | |
| pip install -r requirements.txt | |
| pip install pytest pyyaml | |
| - name: Run tests | |
| run: pytest tests/ -v --tb=short | |
| # ----------------------------------------------------------------------- | |
| # Simulator tests - pure Python logic only (~1 min) | |
| # ----------------------------------------------------------------------- | |
| test-simulator: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: src/simulator | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: pip install numpy pytest pymatgen | |
| - name: Run tests | |
| run: pytest tests/ -v --tb=short | |
| # ----------------------------------------------------------------------- | |
| # Trainer tests (~3 min) | |
| # ----------------------------------------------------------------------- | |
| test-trainer: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: src/trainer | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install CPU-only PyTorch and dependencies | |
| run: | | |
| pip install torch --index-url https://download.pytorch.org/whl/cpu | |
| pip install pytorch-lightning numpy pyyaml tqdm matplotlib scikit-learn pytest | |
| - name: Run tests | |
| run: pytest tests/ -v --tb=short | |
| # ----------------------------------------------------------------------- | |
| # UI backend tests (~3 min) | |
| # ----------------------------------------------------------------------- | |
| test-ui-backend: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: src/ui | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install CPU-only PyTorch and dependencies | |
| run: | | |
| pip install torch --index-url https://download.pytorch.org/whl/cpu | |
| pip install -r requirements.txt | |
| pip install pytest httpx | |
| - name: Run tests | |
| run: pytest tests/ -v --tb=short | |
| # ----------------------------------------------------------------------- | |
| # UI frontend tests (~2 min) | |
| # ----------------------------------------------------------------------- | |
| test-ui-frontend: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: src/ui/frontend | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "18" | |
| cache: "npm" | |
| cache-dependency-path: src/ui/frontend/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install Vitest | |
| run: npm install --save-dev vitest | |
| - name: Run tests | |
| run: npx vitest run --reporter=verbose |