Skip to content

Fix CI workflows and add POSIX feature defines #1

Fix CI workflows and add POSIX feature defines

Fix CI workflows and add POSIX feature defines #1

Workflow file for this run

name: Test CI
on:
push:
branches: [main]
paths:
- 'src/**/*.c'
- 'include/**/*.h'
- 'tests/**/*.c'
- '.github/workflows/test-ci.yml'
pull_request:
branches: [main]
paths:
- 'src/**/*.c'
- 'include/**/*.h'
- 'tests/**/*.c'
- '.github/workflows/test-ci.yml'
jobs:
format-check:
name: Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check code formatting
run: |
docker run --rm -v "$(pwd):/workspace" -w /workspace \
ghcr.io/jidicula/clang-format:15 \
--dry-run --Werror src/shell.c src/parser.c include/shell.h
cppcheck:
name: Static Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install cppcheck
run: |
sudo apt-get update
sudo apt-get install -y cppcheck
- name: Run cppcheck
run: |
if find src/ include/ -type f \( -name "*.c" -o -name "*.h" \) 2>/dev/null | grep -q .; then
cppcheck --enable=all --suppress=missingIncludeSystem \
-I include --error-exitcode=1 src/ include/
fi
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential
- name: Build shell
run: |
gcc -Wall -Wextra -std=c11 -D_POSIX_C_SOURCE=200809L -Iinclude src/shell.c src/parser.c -o shell
- name: Build tests
run: |
cd tests && make
test:
name: Test
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential
- name: Build and run tests
run: |
cd tests && make test