-
Notifications
You must be signed in to change notification settings - Fork 867
106 lines (91 loc) · 3.8 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Runs the complete test suite incl. many external command line dependencies (like Openbabel)
# as well as the pymatgen.ext package. Coverage used to be computed based on this workflow.
name: Tests
on:
push:
branches: [master]
paths-ignore: ["**/*.md", docs/**]
pull_request:
branches: [master]
paths-ignore: ["**/*.md", docs/**]
workflow_dispatch:
workflow_call: # make this workflow reusable by release.yml
permissions:
contents: read
jobs:
test:
# prevent this action from running on forks
if: github.repository == 'materialsproject/pymatgen'
defaults:
run:
shell: bash -l {0} # enables conda/mamba env activation by reading bash profile
strategy:
fail-fast: false
matrix:
# maximize CI coverage of different platforms and python versions while minimizing the
# total number of jobs. We run all pytest splits with the oldest supported python
# version (currently 3.9) on windows (seems most likely to surface errors) and with
# newest version (currently 3.12) on ubuntu (to get complete coverage on unix).
config:
- os: windows-latest
python: "3.9"
resolution: highest
extras: ci,optional
- os: ubuntu-latest
python: '>3.9'
resolution: lowest-direct
extras: ci,optional
- os: macos-latest
python: '3.10'
resolution: lowest-direct
extras: ci # test with only required dependencies installed
# pytest-split automatically distributes work load so parallel jobs finish in similar time
# update durations file with `pytest --store-durations --durations-path tests/files/.pytest-split-durations`
split: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
runs-on: ${{ matrix.config.os }}
env:
PMG_MAPI_KEY: ${{ secrets.PMG_MAPI_KEY }}
PMG_VASP_PSP_DIR: ${{ github.workspace }}/tests/files
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Set up micromamba
uses: mamba-org/setup-micromamba@main
- name: Create mamba environment
run: |
micromamba create -n pmg python=${{ matrix.config.python }} --yes
- name: Install uv
run: micromamba run -n pmg pip install uv
- name: Install ubuntu-only conda dependencies
if: matrix.config.os == 'ubuntu-latest'
run: |
micromamba install -n pmg -c conda-forge enumlib packmol bader openbabel openff-toolkit --yes
- name: Install pymatgen and dependencies
run: |
micromamba activate pmg
# TODO remove temporary fix. added since uv install torch is flaky.
# track https://github.com/astral-sh/uv/issues/1921 for resolution
pip install torch --upgrade
uv pip install numpy cython
uv pip install --editable '.[${{ matrix.config.extras }}]' --resolution=${{ matrix.config.resolution }}
- name: pytest split ${{ matrix.split }}
run: |
micromamba activate pmg
pytest --splits 10 --group ${{ matrix.split }} --durations-path tests/files/.pytest-split-durations tests
trigger_atomate2_ci:
needs: test
runs-on: ubuntu-latest
# only run if changes were pushed to master
if: github.ref == 'refs/heads/master'
steps:
- name: Trigger Atomate2 CI
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/materialsproject/atomate2/dispatches \
-d '{"event_type": "pymatgen-ci-trigger", "client_payload": {"pymatgen_ref": "${{ github.sha }}"}}'