Skip to content
139 changes: 137 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ jobs:

steps:
- name: Checkout sources
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Install dependencies
shell: bash
run: |
if [[ "${RUNNER_OS}" == "Linux" ]]; then
sudo apt-get update
sudo apt-get install -y mpich
sudo apt-get install -y libopenmpi-dev openmpi-bin
else
brew update
brew install open-mpi
Expand All @@ -57,3 +57,138 @@ jobs:
- name: Run check target
run: cmake --build build --target check

code-checks:
name: Code Checks
runs-on: ubuntu-latest
needs: [require-label]
if: github.event_name != 'pull_request' || needs.require-label.result == 'success'
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libopenmpi-dev openmpi-bin astyle=3.1-3build1 autoconf automake libtool build-essential

- name: Check code formatting
working-directory: src
run: |
# Configure git to recognize the workspace
git config --global --add safe.directory ${{ github.workspace }}

# Run astyle-apply.sh to check and apply formatting
# This will modify files in place if formatting is needed
./config/astyle-apply.sh .

# Check if any source files were modified (formatting changes)
if ! git diff --exit-code -- '*.c' '*.h' '*.hpp'; then
echo "::error::Code formatting check failed. Some source files need formatting."
echo "::error::Run './config/astyle-apply.sh .' from the src directory to fix formatting issues."
echo "::error::Then commit the formatted files."
echo "::error::Modified files:"
git diff --name-only -- '*.c' '*.h' '*.hpp'
exit 1
fi
echo "Code formatting check passed"

- name: Check mixed-precision code
working-directory: src
run: |
# Run mixed-precision check
echo "Running mixed-precision code check..."
./mup_check
MUP_EXIT_CODE=$?

if [ $MUP_EXIT_CODE -ne 0 ]; then
echo "::error::Mixed-precision code check failed"
exit 1
fi
echo "Mixed-precision code check passed"
./mup_clean

- name: Check license headers
working-directory: AUTOTEST
run: |
SRC_DIR="${{ github.workspace }}/src"
./test.sh check-license.sh "$SRC_DIR/.."
if [ -s check-license.err ]; then
echo "::error::License header check failed"
cat check-license.err
exit 1
fi
echo "License header check passed"

- name: Check integer usage
working-directory: AUTOTEST
run: |
SRC_DIR="${{ github.workspace }}/src"
./test.sh check-int.sh "$SRC_DIR"
if [ -s check-int.err ]; then
echo "::error::Integer usage check failed"
cat check-int.err
exit 1
fi
echo "Integer usage check passed"

- name: Check double usage
working-directory: AUTOTEST
run: |
SRC_DIR="${{ github.workspace }}/src"
./test.sh check-double.sh "$SRC_DIR"
if [ -s check-double.err ]; then
echo "::error::Double usage check failed"
cat check-double.err
exit 1
fi
echo "Double usage check passed"

- name: Check MPI usage
working-directory: AUTOTEST
run: |
SRC_DIR="${{ github.workspace }}/src"
./test.sh check-mpi.sh "$SRC_DIR"
if [ -s check-mpi.err ]; then
echo "::error::MPI usage check failed"
cat check-mpi.err
exit 1
fi
echo "MPI usage check passed"

- name: Check memory usage
working-directory: AUTOTEST
run: |
SRC_DIR="${{ github.workspace }}/src"
./test.sh check-mem.sh "$SRC_DIR"
if [ -s check-mem.err ]; then
echo "::error::Memory usage check failed"
cat check-mem.err
exit 1
fi
echo "Memory usage check passed"

- name: Check headers
working-directory: AUTOTEST
env:
AR: "ar -rc"
run: |
SRC_DIR="${{ github.workspace }}/src"
./test.sh check-headers.sh "$SRC_DIR"
if [ -s check-headers.err ]; then
echo "::error::Headers check failed"
cat check-headers.err
exit 1
fi
echo "Headers check passed"

- name: Check case-insensitive filenames
working-directory: AUTOTEST
run: |
SRC_DIR="${{ github.workspace }}/src"
./test.sh check-case.sh "$SRC_DIR/.."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just made me wonder why we didn't catch the case issue recently reported by Paul on the ALE3D team. The current script only catches this within subdirectories. I'll look into potentially changing that (not sure yet if we should).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an interesting point... I can take a look if we decide to change anything. Let me know!

if [ -s check-case.err ]; then
echo "::error::Case-insensitive filename check failed"
cat check-case.err
exit 1
fi
echo "Case-insensitive filename check passed"