GitHub Actions: Improve caching, cleanup

- Set the correct cache path, previously cache was ineffective
- Build in `${GITHUB_WORKSPACE}/build` sub-directory
- Update `actions/cache` to `v3`
- Reformat build steps
- Use CMake's `-S` and `-B` options to specify source and build directories

PiperOrigin-RevId: 439560955
Change-Id: I6b07fa4e3a6416725fa1d3d2b7174a4186648033
This commit is contained in:
Christian Blichmann 2022-04-05 06:11:54 -07:00 committed by Copybara-Service
parent 761c4ac45d
commit b29e09b4da
2 changed files with 30 additions and 14 deletions

View File

@ -25,11 +25,11 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Cache dependencies - name: Cache dependencies
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
key: ${{matrix.container}}-${{matrix.compiler}}${{matrix.compiler-version}} key: ${{matrix.container}}-${{matrix.compiler}}${{matrix.compiler-version}}
path: | path: |
${{github.workspace}}/_deps ${{github.workspace}}/build/_deps
- name: Prepare container - name: Prepare container
# Note: For the sandbox tests to work, we need a privileged, unconfined # Note: For the sandbox tests to work, we need a privileged, unconfined
@ -50,9 +50,9 @@ jobs:
- name: Install build tools - name: Install build tools
run: | run: |
$RUN_CMD dnf update -y --quiet $RUN_CMD dnf update -y --quiet
$RUN_CMD dnf install -y --quiet git make automake patch glibc-static \ $RUN_CMD dnf install -y --quiet \
libstdc++-static cmake ninja-build python3 python3-pip clang-devel \ git make automake patch glibc-static libstdc++-static cmake \
libcap-devel ninja-build python3 python3-pip clang-devel libcap-devel
- name: Create Build Environment - name: Create Build Environment
run: | run: |
@ -61,15 +61,22 @@ jobs:
- name: Configure CMake - name: Configure CMake
run: | run: |
$RUN_CMD cmake -S $GITHUB_WORKSPACE -B $GITHUB_WORKSPACE/build \ $RUN_CMD cmake \
-G Ninja -DCMAKE_BUILD_TYPE=$BUILD_TYPE -S $GITHUB_WORKSPACE \
-B $GITHUB_WORKSPACE/build \
-G Ninja \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
- name: Build - name: Build
run: | run: |
$RUN_CMD cmake --build $GITHUB_WORKSPACE/build --config $BUILD_TYPE $RUN_CMD cmake \
--build $GITHUB_WORKSPACE/build \
--config $BUILD_TYPE
- name: Test - name: Test
run: | run: |
$RUN_CMD ctest --test-dir $GITHUB_WORKSPACE/build -C $BUILD_TYPE \ $RUN_CMD ctest \
--test-dir $GITHUB_WORKSPACE/build \
-C $BUILD_TYPE \
--output-on-failure \ --output-on-failure \
-R SapiTest -R SapiTest

View File

@ -43,11 +43,11 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Cache dependencies - name: Cache dependencies
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
key: ${{matrix.os}}-${{matrix.compiler}}${{matrix.compiler-version}} key: ${{matrix.os}}-${{matrix.compiler}}${{matrix.compiler-version}}
path: | path: |
${{github.workspace}}/_deps ${{github.workspace}}/build/_deps
- name: Install ninja-build tool - name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@v3 uses: seanmiddleditch/gha-setup-ninja@v3
@ -73,13 +73,22 @@ jobs:
- name: Configure CMake - name: Configure CMake
run: | run: |
cmake $GITHUB_WORKSPACE -G Ninja -DCMAKE_BUILD_TYPE=$BUILD_TYPE cmake \
-S $GITHUB_WORKSPACE \
-B $GITHUB_WORKSPACE/build \
-G Ninja \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
- name: Build - name: Build
run: | run: |
cmake --build $GITHUB_WORKSPACE --config $BUILD_TYPE cmake \
--build $GITHUB_WORKSPACE/build \
--config $BUILD_TYPE
- name: Test - name: Test
run: | run: |
ctest $GITHUB_WORKSPACE -C $BUILD_TYPE --output-on-failure \ ctest \
--test-dir $GITHUB_WORKSPACE/build \
-C $BUILD_TYPE \
--output-on-failure \
-R SapiTest -R SapiTest