Skip to content

chore(ci): add test job #52

chore(ci): add test job

chore(ci): add test job #52

Workflow file for this run

name: CI

Check failure on line 1 in .github/workflows/ci.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/ci.yaml

Invalid workflow file

(Line: 3, Col: 1): Unexpected value 'push', (Line: 7, Col: 1): Unexpected value 'pull_request'
on: workflow_dispatch
push:
branches: ["main"]
paths:
- 'src/**'
pull_request:
branches: ["main"]
paths:
- 'src/**'
jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install SDL3
uses: libsdl-org/setup-sdl@main
with:
install-linux-dependencies: true
version: 3-latest
version-sdl-image: 3-latest
- name: Install Google Test
run: sudo apt-get install -y libgtest-dev
- name: Build and run tests
run: |
SRCS=$(find src -name "*.cpp" -not -name "client.cpp" -not -name "server.cpp" | tr '\n' ' ')
SDL3_INCLUDES="-isystem $(pkg-config --variable=includedir sdl3)"
SDL3_IMAGE_INCLUDES="-isystem $(pkg-config --variable=includedir sdl3-image)"
SDL3_LIBS="$(pkg-config --libs sdl3) $(pkg-config --libs sdl3-image)"
CXXFLAGS="-std=c++23 -Isrc $SDL3_INCLUDES $SDL3_IMAGE_INCLUDES \
-Wall -Weffc++ -Wextra -Wconversion \
-Wsign-conversion -Wimplicit-fallthrough -Werror"
clang++ $CXXFLAGS $SRCS -o test_runner $SDL3_LIBS -lgtest -lgtest_main -pthread
./test_runner