Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub actions to check formatting and run tests #165

Merged
merged 8 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
47 changes: 47 additions & 0 deletions .github/workflows/check-formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Code formatting check

on:
pull_request:

# Cancel previous runs if a more recent commit is pushed.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

permissions: read-all

jobs:
clang-format-check:
name: clang-format
runs-on: "ubuntu-20.04"
steps:
- name: Setup clang-format
run: |
sudo apt-get install -yqq clang-format-12
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Switch to pull request branch
run: |
git checkout ${GITHUB_SHA}
- name: Run clang-format
run: |
git diff origin/${{ github.base_ref }} -U0 --no-color -- '**/*.cpp' '**/*.cc' '**/*.h' '**/*.hh' '**/*.hpp' \
| clang-format-diff-12 -p1 >not-formatted.diff 2>&1
- name: Check formatting
run: |
if ! grep -q '[^[:space:]]' not-formatted.diff ; then
echo "Code is formatted."
else
echo "Code is not formatted."
echo "Run clang-format-diff on your changes:"
echo " git diff origin/${{ github.base_ref }} -U0 --no-color | clang-format-diff -p1 -i"
echo ""
echo "You can disable clang-format for specific code blocks. Follow https://clang.llvm.org/docs/ClangFormatStyleOptions.html#disabling-formatting-on-a-piece-of-code."
echo ""
echo "Diff:"
cat not-formatted.diff
echo ""
exit 3
fi
35 changes: 35 additions & 0 deletions .github/workflows/linux-bazel-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Linux build

on:
pull_request:

# Cancel previous runs if a more recent commit is pushed.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

permissions: read-all

jobs:
linux-build:
name: Build and run tests on Linux using CMake
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Switch to pull request branch and clone submodules
run: |
git checkout ${GITHUB_SHA}
git submodule update --init --recursive
- name: Build
run: |
mkdir build
cd build
cmake .. -DSPIRV_REFLECT_BUILD_TESTS=ON
cassiebeckley marked this conversation as resolved.
Show resolved Hide resolved
make -j $(nproc)
- name: Run unit tests
run: |
cd build
./test-spirv-reflect
36 changes: 36 additions & 0 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Windows build

on:
pull_request:

# Cancel previous runs if a more recent commit is pushed.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

permissions: read-all

jobs:
windows-build:
name: Build and run unit tests on Windows
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Switch to pull request branch and clone submodules
run: |
git checkout ${GITHUB_SHA}
git submodule update --init --recursive
- name: Build
run: |
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -A x64 -DSPIRV_REFLECT_BUILD_TESTS=ON

cmake --build . --config Release -- /nologo /verbosity:minimal /maxcpucount
- name: Run unit tests
run: |
cd build
./test-spirv-reflect.exe