Skip to content

Commit 1627bfa

Browse files
committed
Refactor CI YAML files
1 parent feadd04 commit 1627bfa

4 files changed

Lines changed: 67 additions & 36 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ jobs:
3636
uses: mxschmitt/action-tmate@v3.13
3737
if: ${{ inputs.debug_enabled }}
3838
- name: Setup conda environment
39-
id: setup_conda
4039
uses: conda-incubator/setup-miniconda@v2
4140
with:
4241
activate-environment: libnomp
@@ -46,9 +45,13 @@ jobs:
4645
id: cache
4746
with:
4847
path: ${{ env.NOMP_CONDA_ENV }}
49-
key: conda-${{ runner.os }}-${{ hashFiles('environment.yml') }}-${{ hashFiles('requirements.txt') }}-${{ env.NOMP_CACHE_NUMBER }}
48+
key: >-
49+
conda-
50+
${{ runner.os }}-
51+
${{ hashFiles('environment.yml') }}-
52+
${{ hashFiles('requirements.txt') }}-
53+
${{ env.NOMP_CACHE_NUMBER }}
5054
- name: Update conda environment
51-
id: update_env
5255
run: |
5356
conda env update -n libnomp -f environment.yml
5457
if: steps.cache.outputs.cache-hit != 'true'
@@ -58,17 +61,16 @@ jobs:
5861
path: ${{ env.NOMP_CONDA_ENV }}/lib/pocl
5962
key: ${{ runner.os }}-build-pocl-${{ env.POCL_CACHE_NUMBER }}
6063
- name: Install pocl
61-
id: install_pocl
6264
run: |
6365
conda install -c conda-forge pocl
64-
if: (steps.pocl_cache.outputs.cache-hit != 'true') || (steps.cache.outputs.cache-hit != 'true')
66+
if: >-
67+
steps.pocl_cache.outputs.cache-hit != 'true' ||
68+
steps.cache.outputs.cache-hit != 'true'
6569
- name: Build libnomp
66-
id: build_libnomp
6770
run: |
68-
./bin/build --enable-opencl --opencl-lib ${CONDA_PREFIX}/lib/libOpenCL.so \
71+
./bin/lnbld --enable-opencl --opencl-lib ${CONDA_PREFIX}/lib/libOpenCL.so \
6972
--enable-tests
7073
- name: Run libnomp tests
71-
id: run_libnomp
7274
run: |
7375
${NOMP_INSTALL_DIR}/bin/lnrun --test backend=opencl
7476
- name: Block to allow inspecting failures

.github/workflows/docs.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ jobs:
4040
uses: actions/cache@v3
4141
with:
4242
path: ${{ env.NOMP_CONDA_ENV }}
43-
key: conda-${{ runner.os }}-${{ hashFiles('environment-dev.yml') }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}-${{ env.NOMP_CACHE_NUMBER }}
43+
key: >-
44+
conda-
45+
${{ runner.os }}-
46+
${{ hashFiles('environment-dev.yml') }}-
47+
${{ hashFiles('requirements.txt') }}-
48+
${{ hashFiles('requirements-dev.txt') }}-
49+
${{ env.NOMP_CACHE_NUMBER }}
4450
id: cache
4551
- name: Update conda environment
4652
id: update_env
@@ -50,7 +56,7 @@ jobs:
5056
- name: Build documentation
5157
id: build_docs
5258
run: |
53-
./bin/build --install-dir ${NOMP_INSTALL_DIR} --enable-docs \
59+
./bin/lnbld --install-dir ${NOMP_INSTALL_DIR} --enable-docs \
5460
-DCMAKE_PREFIX_PATH=${CONDA_PREFIX}
5561
- name: Bypass Jekyll
5662
id: bypass_jekyll

.github/workflows/lint.yml

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ jobs:
2828
uses: mxschmitt/action-tmate@v3.13
2929
if: ${{ inputs.debug_enabled }}
3030
- name: Setup conda environment
31-
id: setup_conda
3231
uses: conda-incubator/setup-miniconda@v2
3332
with:
3433
activate-environment: libnomp-dev
@@ -37,35 +36,18 @@ jobs:
3736
uses: actions/cache@v3
3837
with:
3938
path: ${{ env.NOMP_CONDA_ENV }}
40-
key: conda-${{ runner.os }}-${{ hashFiles('environment-dev.yml') }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}-${{ env.NOMP_CACHE_NUMBER }}
39+
key: >-
40+
conda-
41+
${{ runner.os }}-
42+
${{ hashFiles('environment-dev.yml') }}-
43+
${{ hashFiles('requirements.txt') }}-
44+
${{ hashFiles('requirements-dev.txt') }}-
45+
${{ env.NOMP_CACHE_NUMBER }}
4146
id: cache
4247
- name: Update conda environment
43-
id: update_env
4448
run: |
4549
conda env update -n libnomp-dev -f environment-dev.yml
4650
if: steps.cache.outputs.cache-hit != 'true'
4751
- name: Run clang-format check
4852
run: |
49-
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX}
50-
./lnbuild --format-check
51-
- name: Run clang-tidy check
52-
run: |
53-
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX}
54-
# FIXME: Skipping the clang-tidy checks for now.
55-
# ./lnbuild --tidy-check
56-
- name: Run pylint check
57-
run: |
58-
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX}
59-
./lnbuild --pylint-check
60-
- name: Run black check
61-
run: |
62-
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX}
63-
./lnbuild --black-check
64-
- name: Run isort check
65-
run: |
66-
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX}
67-
./lnbuild --isort-check
68-
- name: Run flake8 check
69-
run: |
70-
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX}
71-
./lnbuild --flake8-check
53+
./bin/lnchk --chk-fmt

bin/lnchk

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
set -e
3+
set -o pipefail
4+
5+
: ${CLANG_FORMAT:=clang-format}
6+
7+
############################
8+
# Don't touch what follows #
9+
############################
10+
11+
CSRC=
12+
PYSRC=
13+
14+
function setup_clang_format() {
15+
if ! command -v $CLANG_FORMAT >/dev/null 2>&1; then
16+
echo "Binary $CLANG_FORMAT not found!"
17+
exit 1
18+
fi
19+
20+
BINDIR=$(dirname -- "$(realpath -- "${BASH_SOURCE[0]}")")
21+
SRCDIR=$BINDIR/..
22+
CSRC=$(find $SRCDIR -type f -name "*.[ch]")
23+
}
24+
25+
function clang_format() {
26+
setup_clang_format
27+
$CLANG_FORMAT -i $CSRC
28+
}
29+
30+
function check_clang_format() {
31+
setup_clang_format
32+
$CLANG_FORMAT --dry-run --Werror -i $CSRC
33+
}
34+
35+
if [[ "$1" == "--fmt" ]]; then
36+
clang_format
37+
elif [[ "$1" == "--chk-fmt" ]]; then
38+
check_clang_format
39+
else
40+
exit 1
41+
fi

0 commit comments

Comments
 (0)