Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 35 additions & 15 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: C Build and Test

on:
pull_request:
push:
branch: main
branches:
- main

env:
BUILD_TYPE: debug
Expand All @@ -12,19 +12,39 @@ env:
jobs:
build-and-test:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

container:
image: koutoftimer/oduortoni-c-http-server-actions:latest

steps:
- name: Checkout repository
uses: actions/checkout@v4 # Action to clone your repository's code

- name: Build C code
run: |
make compile_templates
make bin/server

- name: Run tests
run: |
make test # unit tests
./tests/integration-tests.sh
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT_TOKEN }} # Use PAT instead of GITHUB_TOKEN
fetch-depth: 0
ref: ${{ github.head_ref || github.ref }}

- name: Auto-format code
run: |
git config --global --add safe.directory $PWD
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
pre-commit run --all-files || true
if ! git diff --quiet; then
git add -A
git commit -m "style: auto-format code with clang-format [skip ci]"
git push
fi

- name: Build C code
run: |
make compile_templates
make bin/server

- name: Run tests
run: |
make test
./tests/integration-tests.sh
36 changes: 36 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Auto-format C code

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
clang-format:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up Python (needed for pre-commit)
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Install pre-commit
run: pip install pre-commit

- name: Run clang-format via pre-commit
run: pre-commit run --all-files --show-diff-on-failure --color=always

- name: Commit formatted files
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -u
git commit -m "chore: auto-format with clang-format" || echo "No changes to commit"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19 changes: 0 additions & 19 deletions .github/workflows/pre-commit.yml

This file was deleted.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Comprehensive documentation is available in the [docs](docs) folder. The documen
- [Core Documentation](docs/DOCUMENTATION.md) - Beginner-friendly explanation of how the server works
- [Visual Guide](docs/VISUAL_GUIDE.md) - Diagrams illustrating the server architecture
- [Practical Examples](docs/EXAMPLES.md) - Code examples for extending the server
- [Template System](docs/TEMPLATE_SYSTEM.md) - Instructions of how to use the template system
- [Routing System](docs/ROUTING.md) - Instructions on how to use the routing system

See the [docs README](docs/README.md) for more information.

Expand Down
Loading