From 8594eb2a53967fc2c7c5a40dd8ad40d3b830c8c2 Mon Sep 17 00:00:00 2001 From: Martin Schubert Date: Mon, 2 Dec 2024 08:21:30 -0800 Subject: [PATCH 1/3] add comments to ci/test files --- .github/dependabot.yml | 15 +++++++++++++++ .github/workflows/test.yml | 9 +++++++-- .gitignore | 6 ++++++ tests/test_parse.py | 19 ++++++++++++++++++- 4 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..27852cf91 --- /dev/null +++ b/.github/dependabot.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5b3a1e64b..07cbf440a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,3 +1,8 @@ +# 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: @@ -5,8 +10,8 @@ on: 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: diff --git a/.gitignore b/.gitignore index 11ee53dc7..95c565460 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,9 @@ $RECYCLE.BIN/ Network Trash Folder Temporary Items .apdisk + +# ========================= +# Pytest files +# ========================= + +tests/__pycache__ diff --git a/tests/test_parse.py b/tests/test_parse.py index 82ca2bd30..219abf4a0 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -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)}" From c6f365d0d7bc1ea63ddd5decc363357717bda957 Mon Sep 17 00:00:00 2001 From: Martin Schubert Date: Mon, 2 Dec 2024 08:28:18 -0800 Subject: [PATCH 2/3] fix yml file --- database/data-nk/main/ZnGeP2/Boyd-20-o.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/database/data-nk/main/ZnGeP2/Boyd-20-o.yml b/database/data-nk/main/ZnGeP2/Boyd-20-o.yml index 02c52ad7a..ead4256df 100644 --- a/database/data-nk/main/ZnGeP2/Boyd-20-o.yml +++ b/database/data-nk/main/ZnGeP2/Boyd-20-o.yml @@ -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 ZnGeP2 and CdSe. Appl. Phys. Lett., 18, 301-304 (1971)
From 683ada2074371db705ee4e6ab1c45f4cf025484b Mon Sep 17 00:00:00 2001 From: Martin Schubert Date: Mon, 2 Dec 2024 08:36:12 -0800 Subject: [PATCH 3/3] fix master branch name --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 07cbf440a..f681e5e1a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ on: pull_request: push: branches: - - main + - master # schedule: # - cron: "0 13 * * 1" # Every Monday at 9AM EST