Skip to content
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

add comments to ci/test files #2

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This `dependabot.yml` file handles automatic security/version updates. In this repo,
# it may e.g. update the version of the checkout action used in the `test.yml` action.
# See https://github.com/dependabot/dependabot-core for additional info.

version: 2
updates:
- package-ecosystem: "pip"
directory: "/" # Location of package manifests
schedule:
interval: "daily"

- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
9 changes: 7 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# This `test.yml` file defines a GitHub action that will run for all pull requests,
# and for all pushes to main. It installs the python test libraries `parameterized`
# and `pytest`, and then runs the `pytest` command. This automatically detects
# `test_*.py` files and executes tests therein.

name: CI

on:
pull_request:
push:
branches:
- main
schedule:
- cron: "0 13 * * 1" # Every Monday at 9AM EST
# schedule:
# - cron: "0 13 * * 1" # Every Monday at 9AM EST

jobs:
test-parsing:
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,9 @@ $RECYCLE.BIN/
Network Trash Folder
Temporary Items
.apdisk

# =========================
# Pytest files
# =========================

tests/__pycache__
1 change: 1 addition & 0 deletions database/data-nk/main/ZnGeP2/Boyd-20-o.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# refractiveindex.info database is in the public domain
# copyright and related rights waived via CC0 1.0

REFERENCES: |
1) G. D. Boyd, E. Buehler, F. G Storz.
Linear and nonlinear optical properties of ZnGeP<sub>2</sub> and CdSe.
<a href="https://doi.org/10.1063/1.1653673"><i>Appl. Phys. Lett.</i>, <b>18</b>, 301-304 (1971)</a><br>
Expand Down
19 changes: 18 additions & 1 deletion tests/test_parse.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
"""Tests that all files can be parsed."""
"""Tests that all files can be parsed.

This test can be run by the command

pytest tests/test_parse.py

or simply `pytest` from the repo directory. (The latter will automatically discover
all test files.) This test recursively discovers all `.yml` files in the `database`
directory and then loads them with the python `yaml` package.

A test is generated individually for each `.yml` file, with the test name derived from
the `.yml` file path. For example, the test for file `database/data/nk/main/KBr/Li.yml`
will be `test_can_parase_database_data_nk_main_KBr_Li_yml`.
"""

import pathlib
import unittest
import yaml
from parameterized import parameterized

# Discover the paths for all `.yml` files.
DATABASE_PATH = pathlib.Path(__file__).resolve().parent.parent / "database"
PATHS = list(DATABASE_PATH.rglob("*.yml"))


def custom_name_func(testcase_func, param_num, param):
# Generate the custom test name from the test arguments.
del param_num
path = str(param.args[0])
assert "/database/" in path
path = path[path.index("/database/") :]
return f"{testcase_func.__name__}{parameterized.to_safe_name(path)}"


Expand Down