|
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 |
10 | 3 |
|
11 | 4 | 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 |
| - |
168 | 5 | build:
|
169 | 6 | name: build
|
170 | 7 | runs-on: ubuntu-latest
|
|
0 commit comments