This repository has been archived by the owner on Apr 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Eason Lu <[email protected]>
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: C++ compile tester | ||
description: Test c++ code in the repo and see if they compile. Compile in pedantic mode. | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
release: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Check for C++ files | ||
id: check_cpp_files | ||
run: | | ||
if [ -z "$(find . -name '*.cpp')" ]; then | ||
echo "No C++ files found" | ||
echo "{cpp_files}={false}" >> "$GITHUB_ENV" | ||
else | ||
echo "C++ files found" | ||
echo "{cpp_files}={true}" >> "$GITHUB_ENV" | ||
fi | ||
- name: Install C++ compilers | ||
if: ${{env.cpp_files == 'true'}} | ||
run: | | ||
sudo apt install -y g++ | ||
- name: Compile C++ code (C++14) | ||
if: ${{env.cpp_files == 'true'}} | ||
run: g++ -std=c++14 -Wall -Wextra -Werror -pedantic -c *.cpp | ||
|
||
- name: Compile C++ code (C++17) | ||
if: ${{env.cpp_files == 'true'}} | ||
run: g++ -std=c++17 -Wall -Wextra -Werror -pedantic -c *.cpp | ||
|
||
- name: Compile C++ code (C++20) | ||
if: ${{env.cpp_files == 'true'}} | ||
run: g++ -std=c++20 -Wall -Wextra -Werror -pedantic -c *.cpp | ||
|
||
- name: Compile C++ code (C++23) | ||
if: ${{env.cpp_files == 'true'}} | ||
run: g++ -std=c++23 -Wall -Wextra -Werror -pedantic -c *.cpp | ||
|
||
- name: Upload build artifact | ||
if: ${{env.cpp_files == 'true'}} && success() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: build-artifact | ||
path: . |