From 6a22783010454632c6833475235d96a17616a3fb Mon Sep 17 00:00:00 2001 From: Filip Szweda <68189467+filip-szweda@users.noreply.github.com> Date: Thu, 21 Sep 2023 16:04:02 +0200 Subject: [PATCH] Create GitHub actions for building and testing the project (#9) --- .../build-and-test-debug-on-push.yaml | 12 +++++ .../build-and-test-release-on-merge.yaml | 12 +++++ .github/workflows/build-and-test.yaml | 52 +++++++++++++++++++ .gitignore | 1 + 4 files changed, 77 insertions(+) create mode 100644 .github/workflows/build-and-test-debug-on-push.yaml create mode 100644 .github/workflows/build-and-test-release-on-merge.yaml create mode 100644 .github/workflows/build-and-test.yaml diff --git a/.github/workflows/build-and-test-debug-on-push.yaml b/.github/workflows/build-and-test-debug-on-push.yaml new file mode 100644 index 00000000..75128eff --- /dev/null +++ b/.github/workflows/build-and-test-debug-on-push.yaml @@ -0,0 +1,12 @@ +name: Build and test Debug binaries on push + +on: + push: + branches-ignore: + - main + +jobs: + build-debug: + uses: ./.github/workflows/build-and-test.yaml + with: + build-type: Debug diff --git a/.github/workflows/build-and-test-release-on-merge.yaml b/.github/workflows/build-and-test-release-on-merge.yaml new file mode 100644 index 00000000..5a5ddd69 --- /dev/null +++ b/.github/workflows/build-and-test-release-on-merge.yaml @@ -0,0 +1,12 @@ +name: Build and test Release binaries on merge + +on: + push: + branches: + - main + +jobs: + build-release: + uses: ./.github/workflows/build-and-test.yaml + with: + build-type: Release diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml new file mode 100644 index 00000000..d9a93492 --- /dev/null +++ b/.github/workflows/build-and-test.yaml @@ -0,0 +1,52 @@ +name: Build and test Release/Debug binaries + +on: + workflow_call: + inputs: + build-type: + description: Release or Debug + required: true + type: string + +jobs: + build-x86-64: + runs-on: ubuntu-latest + steps: + - name: Checkout source code of the repository + uses: actions/checkout@v3 + + - name: Update packages + run: | + sudo apt-get update + sudo apt-get upgrade -y + + - name: Set environment variables + run: | + buildType=${{ inputs.build-type }} + echo "CAPITALISED_BUILD_TYPE="${buildType}"" >> $GITHUB_ENV + echo "LOWERCASE_BUILD_TYPE="${buildType,,}"" >> $GITHUB_ENV + + - name: Install requirements + run: | + sudo apt-get install -y libelf-dev + sudo apt-get install -y libboost-all-dev + sudo apt-get install -y libfmt-dev + sudo apt-get install -y clang + pip install cmake==3.23.3 + pip install conan==2.0 + conan profile detect + conan install . --build=missing -s build_type=${{ env.CAPITALISED_BUILD_TYPE }} + + - name: Configure Release + run: cmake --preset conan-${{ env.LOWERCASE_BUILD_TYPE }} -DBUILD_TESTS=OFF + if: ${{ env.LOWERCASE_BUILD_TYPE == 'release' }} + + - name: Configure Debug + run: cmake --preset conan-${{ env.LOWERCASE_BUILD_TYPE }} + if: ${{ env.LOWERCASE_BUILD_TYPE == 'debug' }} + + - name: Build + run: cmake --build --preset conan-${{ env.LOWERCASE_BUILD_TYPE }} + + - name: Test + run: ctest --preset conan-${{ env.LOWERCASE_BUILD_TYPE }} diff --git a/.gitignore b/.gitignore index 642468eb..a55d082f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /.vscode/ /.venv/ +/.idea/ /.conan/ /build/ /cmake-build-debug/