build(deps): bump actions/cache from 3 to 4 #176
Workflow file for this run
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
name: Challenges | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
env: | |
CC: clang | |
CXX: clang++ | |
BUILD_TYPE: Release | |
BUILD_DIRECTORY: cmake-build | |
ASAN_OPTIONS: alloc_dealloc_mismatch=0 | |
jobs: | |
build-targets: | |
name: Build targets | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y clang cmake | |
- name: Create build directory | |
run: cmake -E make_directory "${BUILD_DIRECTORY}" | |
- name: Download cache files | |
uses: actions/cache@v4 | |
with: | |
path: | | |
"${BUILD_DIRECTORY}/_deps" | |
key: ${{ runner.os }}-build | |
- name: Build ${{ env.TARGET }} library | |
run: | | |
cmake -S . -B "${BUILD_DIRECTORY}" -DCMAKE_BUILD_TYPE=${BUILD_TYPE} | |
cmake --build "${BUILD_DIRECTORY}" --config ${BUILD_TYPE} -- -j$(nproc) | |
- name: Create tar.gz file with cmake-build | |
run: tar -czf cmake-build.tar.gz "${BUILD_DIRECTORY}" | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cmake-build | |
path: cmake-build.tar.gz | |
unit-tests: | |
name: Unit tests | |
runs-on: ubuntu-latest | |
needs: [ build-targets ] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y --no-install-recommends llvm | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: cmake-build | |
- name: Extract cmake-build files | |
run: tar -xf cmake-build.tar.gz | |
- name: Run unit tests | |
env: | |
TARGET_DIR: ${{ env.BUILD_DIRECTORY }}/tests/unit | |
run: | | |
${TARGET_DIR}/project-euler-unit-tests \ | |
--gtest_color=yes \ | |
--gtest_brief=1 \ | |
--gtest_output=xml:unit_test_details.xml | |
- name: Generate coverage | |
run: | | |
mkdir -p coverage | |
while IFS= read -r file; do | |
llvm-cov gcov -abcfulp "${BUILD_DIRECTORY}/CMakeFiles/project-euler-library.dir/${file}" | |
done < <(find lib tests -not -path '*/tests/benchmark/*' -type f | egrep --color=never -i '\.(c|cpp)$') | |
mv *.gcov coverage | |
# https://about.codecov.io/blog/how-to-set-up-codecov-with-c-and-github-actions/ | |
- name: Upload coverage results to codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
directory: coverage | |
flags: project-euler-library | |
fail_ci_if_error: true | |
verbose: true | |
dry_run: github.actor == 'dependabot[bot]' | |
- name: Publish Unit Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
with: | |
files: unit_test_details.xml | |
benchmark-tests: | |
name: Benchmark tests | |
runs-on: ubuntu-latest | |
needs: [ build-targets ] | |
if: github.actor != 'dependabot[bot]' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: cmake-build | |
- name: Extract cmake-build files | |
run: tar -xf cmake-build.tar.gz | |
- name: Run benchmark tests | |
env: | |
TARGET_DIR: ${{ env.BUILD_DIRECTORY }}/tests/benchmark | |
run: | | |
${TARGET_DIR}/project-euler-benchmark-tests \ | |
--benchmark_format=json \ | |
| tee benchmark-results.json | |
- name: Download previous benchmark results | |
uses: actions/cache@v4 | |
with: | |
path: ./cache | |
key: ${{ runner.os }}-benchmark | |
- name: Store benchmark results | |
uses: benchmark-action/github-action-benchmark@v1 | |
with: | |
tool: googlecpp | |
output-file-path: benchmark-results.json | |
external-data-json-path: ./cache/benchmark-data.json | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
comment-on-alert: true | |
fail-on-alert: true |