Skip to content

Commit f4d8419

Browse files
committed
Updates to workflows
1 parent 4a01018 commit f4d8419

File tree

4 files changed

+173
-165
lines changed

4 files changed

+173
-165
lines changed

.github/workflows/build.yaml

Lines changed: 2 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -1,170 +1,7 @@
1-
name: opencosmo CI
2-
3-
on:
4-
pull_request:
5-
branches:
6-
- main
7-
push:
8-
branches:
9-
- main
1+
name: build
2+
on: workflow_call
103

114
jobs:
12-
lint-typecheck:
13-
name: Lint and Type Check
14-
runs-on: ubuntu-latest
15-
16-
steps:
17-
- name: Checkout repository
18-
uses: actions/checkout@v4
19-
- name: setup mpi
20-
uses: mpi4py/setup-mpi@v1
21-
- name: Install Poetry
22-
uses: snok/install-poetry@v1
23-
with:
24-
virtualenvs-create: true
25-
virtualenvs-in-project: true
26-
- name: Set up Python
27-
uses: actions/setup-python@v4
28-
with:
29-
python-version: '3.13'
30-
cache: poetry
31-
- name: check pyproject.toml
32-
run: cat pyproject.toml
33-
34-
- name: Install dependencies
35-
run: poetry install --with develop,mpi
36-
37-
- name: Run ruff linter
38-
run: poetry run ruff check .
39-
40-
- name: Run mypy type checker
41-
run: poetry run mypy opencosmo
42-
43-
build-docs:
44-
runs-on: ubuntu-latest
45-
steps:
46-
- uses: actions/checkout@v4
47-
- uses: ammaraskar/sphinx-action@master
48-
with:
49-
docs-folder: "docs"
50-
51-
get-test-data:
52-
runs-on: ubuntu-latest
53-
steps:
54-
- name: Setup AWS CLI
55-
uses: aws-actions/configure-aws-credentials@v1
56-
with:
57-
aws-access-key-id: ${{ secrets.TEST_DATA_ACCESS_KEY }}
58-
aws-secret-access-key: ${{ secrets.TEST_DATA_SECRET_KEY }}
59-
aws-region: us-west-2
60-
- name: check if cache exists
61-
id: check-cache
62-
uses: actions/cache@v4
63-
with:
64-
path: test_data.tar.gz
65-
key: test-data
66-
lookup-only: true
67-
restore-keys: |
68-
test-data
69-
- name: Download test data
70-
if: steps.check-cache.outputs.cache-hit != 'true'
71-
run: aws s3 cp s3://${{ secrets.TEST_DATA_BUCKET }}/test_data.tar.gz test_data.tar.gz
72-
- name: Cache test data
73-
if: steps.check-cache.outputs.cache-hit != 'true'
74-
id: cache-test-data
75-
uses: actions/cache@v4
76-
with:
77-
path: test_data.tar.gz
78-
key: test-data
79-
enableCrossOsArchive: true
80-
81-
run-tests:
82-
name: Run tests
83-
runs-on: ${{ matrix.os }}
84-
needs: [get-test-data]
85-
strategy:
86-
matrix:
87-
os: [ubuntu-latest, macos-latest, windows-latest]
88-
python-version: ['3.11', '3.12', '3.13']
89-
defaults:
90-
run:
91-
shell: bash
92-
steps:
93-
- name: Checkout repository
94-
uses: actions/checkout@v4
95-
- name: get test data
96-
uses: actions/cache@v4
97-
with:
98-
path: test_data.tar.gz
99-
key: test-data
100-
enableCrossOsArchive: true
101-
- name: Unpack test data
102-
run: |
103-
mkdir -p test/resource
104-
tar -xzf test_data.tar.gz -C test/resource
105-
- name: install poetry
106-
run: pipx install poetry
107-
108-
- name: install python
109-
uses: actions/setup-python@v4
110-
with:
111-
python-version: ${{ matrix.python-version }}
112-
cache: poetry
113-
- name: Install dependencies
114-
run: poetry install --with test
115-
116-
- name: Run tests with pytest
117-
run: |
118-
poetry run pytest --ignore=test/parallel
119-
env:
120-
OPENCOSMO_DATA_PATH : ${{ github.workspace }}/test/resource
121-
122-
run-parallel-tests:
123-
runs-on: ubuntu-latest
124-
needs: [get-test-data]
125-
strategy:
126-
matrix:
127-
python-version: ['3.11', '3.12', '3.13']
128-
steps:
129-
- name: Checkout repository
130-
uses: actions/checkout@v4
131-
- name: setup mpi
132-
uses: mpi4py/setup-mpi@v1
133-
134-
- name: install parallel hdf5
135-
run: sudo apt install -y libhdf5-mpi-dev
136-
- name: get test data
137-
uses: actions/cache@v4
138-
with:
139-
path: test_data.tar.gz
140-
key: test-data
141-
enableCrossOsArchive: true
142-
- name: Unpack test data
143-
run: |
144-
mkdir -p test/resource
145-
tar -xzf test_data.tar.gz -C test/resource
146-
- name: install poetry
147-
run: pipx install poetry
148-
- name: install python
149-
uses: actions/setup-python@v4
150-
with:
151-
python-version: ${{ matrix.python-version }}
152-
cache: pip
153-
154-
- name: build hdf5 in paralell
155-
run: |
156-
CC="mpicc" HDF5_MPI="ON" poetry run pip install --no-binary=h5py h5py
157-
158-
- name: install project
159-
run: poetry install --with test,mpi,test-mpi
160-
- name: get number of cores
161-
run: echo "Running on $(nproc) cores"
162-
- name: Run tests with pytest
163-
run: |
164-
poetry run mpiexec --use-hwthread-cpus -n 4 pytest -m parallel test/parallel
165-
env:
166-
OPENCOSMO_DATA_PATH : ${{ github.workspace }}/test/resource
167-
1685
build:
1696
name: build
1707
runs-on: ubuntu-latest

.github/workflows/ci.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: opencosmo CI
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
7+
8+
jobs:
9+
lint:
10+
uses: ./.github/workflows/test.yaml
11+
test:
12+
users: ./.github/workflows/test.yaml
13+

.github/workflows/lint.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: lint
2+
3+
on: workflow_call
4+
5+
jobs:
6+
lint-typecheck:
7+
name: Lint and Type Check
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
- name: setup mpi
14+
uses: mpi4py/setup-mpi@v1
15+
- name: Install Poetry
16+
uses: snok/install-poetry@v1
17+
with:
18+
virtualenvs-create: true
19+
virtualenvs-in-project: true
20+
- name: Set up Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: '3.13'
24+
cache: poetry
25+
- name: check pyproject.toml
26+
run: cat pyproject.toml
27+
28+
- name: Install dependencies
29+
run: poetry install --with develop,mpi
30+
31+
- name: Run ruff linter
32+
run: poetry run ruff check .
33+
34+
- name: Run mypy type checker
35+
run: poetry run mypy opencosmo
36+
37+

.github/workflows/test.yaml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: test opencosmo
2+
on: workflow_call
3+
4+
jobs:
5+
get-test-data:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Setup AWS CLI
9+
uses: aws-actions/configure-aws-credentials@v1
10+
with:
11+
aws-access-key-id: ${{ secrets.TEST_DATA_ACCESS_KEY }}
12+
aws-secret-access-key: ${{ secrets.TEST_DATA_SECRET_KEY }}
13+
aws-region: us-west-2
14+
- name: check if cache exists
15+
id: check-cache
16+
uses: actions/cache@v4
17+
with:
18+
path: test_data.tar.gz
19+
key: test-data
20+
lookup-only: true
21+
restore-keys: |
22+
test-data
23+
- name: Download test data
24+
if: steps.check-cache.outputs.cache-hit != 'true'
25+
run: aws s3 cp s3://${{ secrets.TEST_DATA_BUCKET }}/test_data.tar.gz test_data.tar.gz
26+
- name: Cache test data
27+
if: steps.check-cache.outputs.cache-hit != 'true'
28+
id: cache-test-data
29+
uses: actions/cache@v4
30+
with:
31+
path: test_data.tar.gz
32+
key: test-data
33+
enableCrossOsArchive: true
34+
35+
run-tests:
36+
name: Run tests
37+
runs-on: ${{ matrix.os }}
38+
needs: [get-test-data]
39+
strategy:
40+
matrix:
41+
os: [ubuntu-latest, macos-latest, windows-latest]
42+
python-version: ['3.11', '3.12', '3.13']
43+
defaults:
44+
run:
45+
shell: bash
46+
steps:
47+
- name: Checkout repository
48+
uses: actions/checkout@v4
49+
- name: get test data
50+
uses: actions/cache@v4
51+
with:
52+
path: test_data.tar.gz
53+
key: test-data
54+
enableCrossOsArchive: true
55+
- name: Unpack test data
56+
run: |
57+
mkdir -p test/resource
58+
tar -xzf test_data.tar.gz -C test/resource
59+
- name: install poetry
60+
run: pipx install poetry
61+
62+
- name: install python
63+
uses: actions/setup-python@v4
64+
with:
65+
python-version: ${{ matrix.python-version }}
66+
cache: poetry
67+
- name: Install dependencies
68+
run: poetry install --with test
69+
70+
- name: Run tests with pytest
71+
run: |
72+
poetry run pytest --ignore=test/parallel
73+
env:
74+
OPENCOSMO_DATA_PATH : ${{ github.workspace }}/test/resource
75+
76+
run-parallel-tests:
77+
runs-on: ubuntu-latest
78+
needs: [get-test-data]
79+
strategy:
80+
matrix:
81+
python-version: ['3.11', '3.12', '3.13']
82+
steps:
83+
- name: Checkout repository
84+
uses: actions/checkout@v4
85+
- name: setup mpi
86+
uses: mpi4py/setup-mpi@v1
87+
88+
- name: install parallel hdf5
89+
run: sudo apt install -y libhdf5-mpi-dev
90+
- name: get test data
91+
uses: actions/cache@v4
92+
with:
93+
path: test_data.tar.gz
94+
key: test-data
95+
enableCrossOsArchive: true
96+
- name: Unpack test data
97+
run: |
98+
mkdir -p test/resource
99+
tar -xzf test_data.tar.gz -C test/resource
100+
- name: install poetry
101+
run: pipx install poetry
102+
- name: install python
103+
uses: actions/setup-python@v4
104+
with:
105+
python-version: ${{ matrix.python-version }}
106+
cache: pip
107+
108+
- name: build hdf5 in paralell
109+
run: |
110+
CC="mpicc" HDF5_MPI="ON" poetry run pip install --no-binary=h5py h5py
111+
112+
- name: install project
113+
run: poetry install --with test,mpi,test-mpi
114+
- name: get number of cores
115+
run: echo "Running on $(nproc) cores"
116+
- name: Run tests with pytest
117+
run: |
118+
poetry run mpiexec --use-hwthread-cpus -n 4 pytest -m parallel test/parallel
119+
env:
120+
OPENCOSMO_DATA_PATH : ${{ github.workspace }}/test/resource
121+

0 commit comments

Comments
 (0)