Skip to content

Commit a4aed65

Browse files
authored
Refactor GitHub Actions workflow for tests
Removed unused permissions and workflow_dispatch trigger. Updated various commands for better performance and consistency.
1 parent 6587968 commit a4aed65

1 file changed

Lines changed: 211 additions & 36 deletions

File tree

‎.github/workflows/test.yml‎

Lines changed: 211 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ on:
55
push:
66
branches:
77
- develop
8-
workflow_dispatch:
9-
10-
permissions:
11-
contents: read
128

139
concurrency:
1410
group: ${{ github.workflow }}-${{ github.ref }}
@@ -21,33 +17,29 @@ defaults:
2117
jobs:
2218
test:
2319
name: Test
24-
# Do not use the generic X64 label. It also matches the legacy and GPU
25-
# runners, which was the cause of jobs landing on different machines.
2620
runs-on:
2721
- self-hosted
2822
- cpu
2923
- linux-x64
3024
if: github.repository_owner == 'deepmodeling'
31-
timeout-minutes: 70
3225
container:
3326
image: ghcr.io/deepmodeling/abacus-gnu
3427
env:
35-
# The workspace is visible to both the job container and actions/cache.
3628
CCACHE_DIR: ${{ github.workspace }}/.ccache
3729
CCACHE_BASEDIR: ${{ github.workspace }}
3830
CCACHE_COMPRESS: "true"
3931
CCACHE_MAXSIZE: 8G
40-
4132
steps:
4233
- name: Checkout repository
4334
uses: actions/checkout@v7.0.1
4435
with:
4536
fetch-depth: 0
37+
# We will handle submodules manually after fixing ownership
4638
submodules: 'false'
4739

4840
- name: Take ownership of the workspace and update submodules
4941
run: |
50-
sudo chown -R "$(whoami)" .
42+
sudo chown -R $(whoami) .
5143
git submodule update --init --recursive
5244
5345
- name: Install CI tools
@@ -87,8 +79,9 @@ jobs:
8779
- name: Install external tools from toolchain
8880
run: |
8981
cd toolchain
90-
./install_abacus_toolchain_new.sh --with-dftd4=install --dry-run -j"$(nproc)"
82+
./install_abacus_toolchain_new.sh --with-dftd4=install --dry-run -j8
9183
./scripts/stage4/install_stage4.sh
84+
cd ..
9285
9386
- name: Configure
9487
run: |
@@ -106,9 +99,20 @@ jobs:
10699
-DENABLE_PEXSI=ON \
107100
-Werror=dev
108101
102+
# Temporarily removed because no one maintains this now.
103+
# And it will break the CI test workflow.
104+
105+
# - uses: pre-commit/action@v3.0.1
106+
# with:
107+
# extra_args:
108+
# --from-ref ${{ github.event.pull_request.base.sha }}
109+
# --to-ref ${{ github.event.pull_request.head.sha }}
110+
# continue-on-error: true
111+
# - uses: pre-commit-ci/lite-action@v1.0.3
112+
109113
- name: Build
110114
run: |
111-
cmake --build build --parallel "$(nproc)"
115+
cmake --build build -j8
112116
cmake --install build
113117
114118
- name: Report compiler cache
@@ -119,17 +123,20 @@ jobs:
119123
120124
- name: Check documentation consistency
121125
run: |
122-
ABACUS_BIN="$(find build -name 'abacus_*' -type f -executable | head -1)"
126+
ABACUS_BIN=$(find build -name "abacus_*" -type f -executable | head -1)
123127
echo "Using binary: ${ABACUS_BIN}"
124128
125-
"${ABACUS_BIN}" --generate-parameters-yaml > /tmp/parameters_generated.yaml
129+
# Check 1: parameters.yaml matches C++ Input_Item definitions
130+
${ABACUS_BIN} --generate-parameters-yaml > /tmp/parameters_generated.yaml
126131
if ! diff -q docs/parameters.yaml /tmp/parameters_generated.yaml; then
127132
echo "error: docs/parameters.yaml is out of sync with C++ source"
128133
echo "Fix: ${ABACUS_BIN} --generate-parameters-yaml > docs/parameters.yaml"
129134
diff docs/parameters.yaml /tmp/parameters_generated.yaml || true
130135
exit 1
131136
fi
137+
echo " parameters.yaml: OK"
132138
139+
# Check 2: input-main.md matches regenerated markdown
133140
pip install -q pyyaml
134141
python docs/generate_input_main.py \
135142
/tmp/parameters_generated.yaml \
@@ -140,32 +147,200 @@ jobs:
140147
diff docs/advanced/input_files/input-main.md /tmp/input-main-generated.md || true
141148
exit 1
142149
fi
150+
echo " input-main.md: OK"
151+
152+
- name: Integrated Tests Preparation
153+
env:
154+
GTEST_COLOR: 'yes'
155+
OMP_NUM_THREADS: '2'
156+
run: |
157+
ctest --test-dir build -V --timeout 1700 -R integrated_test
158+
159+
- name: Module_Base Unittests
160+
env:
161+
GTEST_COLOR: 'yes'
162+
OMP_NUM_THREADS: '2'
163+
run: |
164+
ctest --test-dir build -V --timeout 1700 -R MODULE_BASE
165+
166+
- name: Module_IO Unittests
167+
env:
168+
GTEST_COLOR: 'yes'
169+
OMP_NUM_THREADS: '2'
170+
run: |
171+
ctest --test-dir build -V --timeout 1700 -R MODULE_IO
143172
144-
- name: Run integration and unit tests
173+
- name: Module_HSolver Unittests
145174
env:
146175
GTEST_COLOR: 'yes'
147176
OMP_NUM_THREADS: '2'
148177
run: |
149-
patterns=(
150-
integrated_test
151-
MODULE_BASE MODULE_IO MODULE_HSOLVER MODULE_CELL MODULE_MD
152-
MODULE_PSI MODULE_RI MODULE_ESTATE MODULE_HAMILT MODULE_PW
153-
MODULE_LCAO MODULE_AO MODULE_NAO MODULE_RELAX MODULE_LR
154-
01_PW 02_NAO_Gamma 03_NAO_multik 04_FF 05_rtTDDFT
155-
06_SDFT 07_OFDFT 08_EXX 09_DeePKS 10_others
156-
)
178+
ctest --test-dir build -V --timeout 1700 -R MODULE_HSOLVER -E PERF_MODULE_HSOLVER_KERNELS
157179
158-
for pattern in "${patterns[@]}"; do
159-
echo "::group::${pattern}"
160-
if [[ "${pattern}" == "MODULE_HSOLVER" ]]; then
161-
ctest --test-dir build --output-on-failure --timeout 1700 \
162-
-R "${pattern}" -E PERF_MODULE_HSOLVER_KERNELS
163-
else
164-
ctest --test-dir build --output-on-failure --timeout 1700 \
165-
-R "${pattern}"
166-
fi
167-
echo "::endgroup::"
168-
done
180+
- name: Module_Cell Unittests
181+
env:
182+
GTEST_COLOR: 'yes'
183+
OMP_NUM_THREADS: '2'
184+
run: |
185+
ctest --test-dir build -V --timeout 1700 -R MODULE_CELL
169186
170-
ctest --test-dir build --output-on-failure --timeout 1700 \
171-
-E 'integrated_test|01_PW|02_NAO_Gamma|03_NAO_multik|04_FF|05_rtTDDFT|06_SDFT|07_OFDFT|08_EXX|09_DeePKS|10_others|11_PW_GPU|12_NAO_Gamma_GPU|13_NAO_multik_GPU|15_rtTDDFT_GPU|16_SDFT_GPU|17_DS_DFTU|MODULE_BASE|MODULE_IO|MODULE_HSOLVER|MODULE_CELL|MODULE_MD|MODULE_PSI|MODULE_ESTATE|MODULE_RI|MODULE_HAMILT|MODULE_PW|MODULE_LCAO|MODULE_AO|MODULE_NAO|MODULE_RELAX|MODULE_LR'
187+
- name: Module_MD Unittests
188+
env:
189+
GTEST_COLOR: 'yes'
190+
OMP_NUM_THREADS: '2'
191+
run: |
192+
ctest --test-dir build -V --timeout 1700 -R MODULE_MD
193+
194+
- name: Module_Psi Unittests
195+
env:
196+
GTEST_COLOR: 'yes'
197+
OMP_NUM_THREADS: '2'
198+
run: |
199+
ctest --test-dir build -V --timeout 1700 -R MODULE_PSI
200+
201+
- name: Module_RI Unittests
202+
env:
203+
GTEST_COLOR: 'yes'
204+
OMP_NUM_THREADS: '2'
205+
run: |
206+
ctest --test-dir build -V --timeout 1700 -R MODULE_RI
207+
208+
- name: Module_Estate Unittests
209+
env:
210+
GTEST_COLOR: 'yes'
211+
OMP_NUM_THREADS: '2'
212+
run: |
213+
ctest --test-dir build -V --timeout 1700 -R MODULE_ESTATE
214+
215+
- name: Module_Hamilt Unittests
216+
env:
217+
GTEST_COLOR: 'yes'
218+
OMP_NUM_THREADS: '2'
219+
run: |
220+
ctest --test-dir build -V --timeout 1700 -R MODULE_HAMILT
221+
222+
- name: Module_PW Unittests
223+
env:
224+
GTEST_COLOR: 'yes'
225+
OMP_NUM_THREADS: '2'
226+
run: |
227+
ctest --test-dir build -V --timeout 1700 -R MODULE_PW
228+
229+
- name: Module_LCAO Unittests
230+
env:
231+
GTEST_COLOR: 'yes'
232+
OMP_NUM_THREADS: '2'
233+
run: |
234+
ctest --test-dir build -V --timeout 1700 -R MODULE_LCAO
235+
236+
- name: Module_AO Unittests
237+
env:
238+
GTEST_COLOR: 'yes'
239+
OMP_NUM_THREADS: '2'
240+
run: |
241+
ctest --test-dir build -V --timeout 1700 -R MODULE_AO
242+
243+
- name: Module_NAO Unittests
244+
env:
245+
GTEST_COLOR: 'yes'
246+
OMP_NUM_THREADS: '2'
247+
run: |
248+
ctest --test-dir build -V --timeout 1700 -R MODULE_NAO
249+
250+
- name: Module_RELAX Unittests
251+
env:
252+
GTEST_COLOR: 'yes'
253+
OMP_NUM_THREADS: '2'
254+
run: |
255+
ctest --test-dir build -V --timeout 1700 -R MODULE_RELAX
256+
257+
- name: Module_LR Unittests
258+
env:
259+
GTEST_COLOR: 'yes'
260+
OMP_NUM_THREADS: '2'
261+
run: |
262+
ctest --test-dir build -V --timeout 1700 -R MODULE_LR
263+
264+
- name: 01_PW Test
265+
env:
266+
GTEST_COLOR: 'yes'
267+
OMP_NUM_THREADS: '2'
268+
run: |
269+
ctest --test-dir build -V --timeout 1700 -R 01_PW
270+
271+
- name: 02_NAO_Gamma Test
272+
env:
273+
GTEST_COLOR: 'yes'
274+
OMP_NUM_THREADS: '2'
275+
run: |
276+
ctest --test-dir build -V --timeout 1700 -R 02_NAO_Gamma
277+
278+
- name: 03_NAO_multik Test
279+
env:
280+
GTEST_COLOR: 'yes'
281+
OMP_NUM_THREADS: '2'
282+
run: |
283+
ctest --test-dir build -V --timeout 1700 -R 03_NAO_multik
284+
285+
- name: 04_FF Test
286+
env:
287+
GTEST_COLOR: 'yes'
288+
OMP_NUM_THREADS: '2'
289+
run: |
290+
ctest --test-dir build -V --timeout 1700 -R 04_FF
291+
292+
- name: 05_rtTDDFT Test
293+
env:
294+
GTEST_COLOR: 'yes'
295+
OMP_NUM_THREADS: '2'
296+
run: |
297+
ctest --test-dir build -V --timeout 1700 -R 05_rtTDDFT
298+
299+
- name: 06_SDFT Test
300+
env:
301+
GTEST_COLOR: 'yes'
302+
OMP_NUM_THREADS: '2'
303+
run: |
304+
ctest --test-dir build -V --timeout 1700 -R 06_SDFT
305+
306+
- name: 07_OFDFT Test
307+
env:
308+
GTEST_COLOR: 'yes'
309+
OMP_NUM_THREADS: '2'
310+
run: |
311+
ctest --test-dir build -V --timeout 1700 -R 07_OFDFT
312+
313+
- name: 08_EXX Test
314+
env:
315+
GTEST_COLOR: 'yes'
316+
OMP_NUM_THREADS: '2'
317+
run: |
318+
ctest --test-dir build -V --timeout 1700 -R 08_EXX
319+
320+
- name: 09_DeePKS Test
321+
env:
322+
GTEST_COLOR: 'yes'
323+
OMP_NUM_THREADS: '2'
324+
run: |
325+
ctest --test-dir build -V --timeout 1700 -R 09_DeePKS
326+
327+
- name: 10_others Test
328+
env:
329+
GTEST_COLOR: 'yes'
330+
OMP_NUM_THREADS: '2'
331+
run: |
332+
ctest --test-dir build -V --timeout 1700 -R 10_others
333+
334+
# - name: 17_DS_DFTU Test
335+
# env:
336+
# GTEST_COLOR: 'yes'
337+
# OMP_NUM_THREADS: '2'
338+
# run: |
339+
# ctest --test-dir build -V --timeout 1700 -R 17_DS_DFTU
340+
341+
- name: Other Unittests
342+
env:
343+
GTEST_COLOR: 'yes'
344+
OMP_NUM_THREADS: '2'
345+
run: |
346+
ctest --test-dir build -V --timeout 1700 -E 'integrate_test|01_PW|02_NAO_Gamma|03_NAO_multik|04_FF|05_rtTDDFT|06_SDFT|07_OFDFT|08_EXX|09_DeePKS|10_others|11_PW_GPU|12_NAO_Gamma_GPU|13_NAO_multik_GPU|15_rtTDDFT_GPU|16_SDFT_GPU|17_DS_DFTU|MODULE_BASE|MODULE_IO|MODULE_HSOLVER|MODULE_CELL|MODULE_MD|MODULE_PSI|MODULE_ESTATE|MODULE_RI|MODULE_HAMILT|MODULE_PW|MODULE_LCAO|MODULE_AO|MODULE_NAO|MODULE_RELAX|MODULE_LR'

0 commit comments

Comments
 (0)