Skip to content

Commit 5222eca

Browse files
committed
Add tests and test action
1 parent 50e5547 commit 5222eca

File tree

3 files changed

+66
-2
lines changed

3 files changed

+66
-2
lines changed

.github/workflows/python-tests.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Python Tests
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
jobs:
12+
build:
13+
if: ${{ false }}
14+
runs-on: ${{ matrix.os }}
15+
timeout-minutes: 15
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os: [ubuntu-latest, macos-latest, windows-latest]
20+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
21+
exclude:
22+
- os: macos-latest
23+
python-version: "3.7"
24+
- os: macos-latest
25+
python-version: "3.8"
26+
steps:
27+
- uses: actions/checkout@v3
28+
- name: Install apt dependencies
29+
if: matrix.os == 'ubuntu-latest'
30+
run: |
31+
sudo apt install -y libegl1 libegl1-mesa libegl-mesa0 libgl1-mesa-glx libopengl0
32+
- name: Set up Python ${{ matrix.python-version }}
33+
uses: actions/setup-python@v4
34+
with:
35+
python-version: ${{ matrix.python-version }}
36+
cache: 'pip'
37+
check-latest: true
38+
- name: Install python dependencies
39+
run: |
40+
python -m pip install --upgrade pip
41+
python -m pip install pytest
42+
python -m pip install ovito
43+
python -m pip install .
44+
- name: Test with pytest
45+
run: |
46+
pytest

README.md

+18-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,26 @@ This repository contains a template for creating your own [Python file reader](h
77
## Getting Started
88

99
1. Click the "Use this template" button to create your own repository based on this template.
10-
2. Rename `src/FileReaderName` to reflect the name of your modifier.
10+
2. Rename `src/FileReaderName` to reflect the name of your file reader.
1111
3. Implement your [file reader](https://ovito.org/docs/dev/python/introduction/custom_file_readers.html) in [`src/FileReaderName/__init__.py`](src/FileReaderName/__init__.py). Fill in the predefined functions as needed. More details on this interface can be found in the [OVITO Python docs](https://ovito.org/docs/dev/python/modules/ovito_io.html#ovito.io.FileReaderInterface).
1212
4. Fill in the [`pyproject.toml`](pyproject.toml) file. Fields that need to be replaced with your information are enclosed in descriptive `[[field]]` tags. Please make sure to include ovito>=3.9.1 as a dependency. Depending on your needs, you can add additional fields to the `pyproject.toml` file. Information can be found [here](https://setuptools.pypa.io/en/latest/userguide/index.html).
1313
5. Fill in the [`README_Template.md`](README_Template.md) file. Again, the `[[fields]]` placeholders should guide you. Feel free to add other sections like "Images", "Citation", or "References" as needed.
14-
6. Add meaningful examples and data sample files to the `Examples` directory to help others understand the use of your modifier.
14+
6. Add meaningful examples and data sample files to the `Examples` directory to help others understand the use of your file reader.
1515
7. Pick a license for your project and replace the current (MIT) [`LICENSE`](LICENSE) file with your license. If you keep the MIT license, please update the name and year in the current file.
1616
8. Once you're done, rename `README_Template.md` to `README.md`, replacing this file.
17+
18+
## Testing
19+
This repository is configured to enable automated testing using the [pytest](https://docs.pytest.org/en/7.4.x/) framework. Tests are automatically executed after each push to the main branch. To set up and activate automated testing, follow these two steps:
20+
21+
1. Write your tests in the `test/test_file_reader.py` file. You can also use other filenames that adhere to the pytest requirements.
22+
2. Open the `.github/workflows/python-tests.yml` file and remove the `if: ${{ false }}` condition on line 15.
23+
24+
If needed, you can also adjust the operating system and Python versions by modifying the following lines:
25+
```yaml
26+
os: [ubuntu-latest, macos-latest, windows-latest]
27+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
28+
```
29+
30+
An example can be found [here](https://github.com/nnn911/GenerateRandomSolution).
31+
32+
As of August 16, 2023, according to the [GitHub documentation](https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions), *"GitHub Actions usage is free for standard GitHub-hosted runners in public repositories, and for self-hosted runners."* Please refer to the GitHub documentation if you are uncertain about incurring costs.

tests/test_file_reader.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def test_example():
2+
assert True

0 commit comments

Comments
 (0)