cleanup and add cache overwriting #297
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: test | |
env: | |
DOWNLOAD_CACHE_VERSION: 8 | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
ubuntu: | |
permissions: | |
actions: write | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install dependencies | |
run: | | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
sudo apt update | |
sudo apt-get install -y tree clang clang-format ccache freeglut3-dev libasound2-dev libcurl4-openssl-dev libfreetype6-dev libjack-jackd2-dev libx11-dev libxcomposite-dev libxcursor-dev libxinerama-dev libxrandr-dev mesa-common-dev ladspa-sdk webkit2gtk-4.0 libgtk-3-dev xvfb libwebkit2gtk-4.1-dev | |
- name: clang-format | |
run: | | |
clang-format --dry-run --Werror src/**/*.cc include/**/*.hh | |
- name: mkdir ~/.ccache | |
run: mkdir /home/runner/.ccache | |
- name: Restore cache | |
uses: actions/cache/restore@v4 | |
id: restore-cache | |
with: | |
path: /home/runner/.ccache | |
key: ${{ runner.os }}-ccache-${{ hashFiles('**/CMakeLists.txt') }}-${{ env.DOWNLOAD_CACHE_VERSION }} | |
restore-keys: | | |
${{ runner.os }}-ccache- | |
- name: CMake Configure | |
run: > | |
cmake -B build | |
-D CMAKE_C_COMPILER_LAUNCHER=ccache | |
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache | |
-D CMAKE_BUILD_TYPE=Debug | |
-S ${{ github.workspace }} | |
- name: CMake Build | |
run: cmake --build build --parallel $(nproc) | |
- name: Overwrite existing cache | |
if: ${{ steps.restore-cache.outputs.cache-hit }} | |
continue-on-error: true | |
run: | | |
gh extension install actions/gh-actions-cache | |
gh actions-cache delete "${{ env.cache-key }}" --confirm | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Save cache | |
# if: always() && steps.restore-cache.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v4 | |
with: | |
key: ${{ steps.restore-cache.outputs.cache-primary-key }} | |
path: /home/runner/.ccache | |
- name: Run Unit tests | |
id: unit-test | |
continue-on-error: true | |
run: | | |
set -o pipefail | |
xvfb-run -a --server-args="-screen 0 1920x1080x24" ./build/UnitTests 2>&1 | tee unit_test_log.txt | |
- name: Run Fuzz test | |
id: fuzz-test | |
continue-on-error: true # Allows next steps to run even if this fails | |
run: | | |
set -o pipefail | |
xvfb-run -a --server-args="-screen 0 1920x1080x24" ./build/Fuzz_artefacts/Debug/Fuzz 2>&1 | tee fuzz_test_log.txt | |
- name: Upload test log | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-logs | |
path: "*test_log.txt" | |
- name: Check test result | |
if: always() | |
run: | | |
if [ "${{ steps.unit-test.outcome }}" != "success" ]; then | |
echo "Unit Tests failed" | |
exit 1 | |
fi | |
if [ "${{ steps.fuzz-test.outcome }}" != "success" ]; then | |
echo "Fuzz Tests failed" | |
exit 1 | |
fi | |
mac: | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install dependencies | |
run: | | |
brew install clang-format ccache cmake tree | |
- name: clang-format | |
run: | | |
clang-format --dry-run --Werror src/**/*.cc include/**/*.hh | |
- name: mkdir ~/.ccache | |
run: mkdir ~/.ccache | |
- name: Restore cache | |
uses: actions/cache/restore@v4 | |
id: restore-cache | |
with: | |
path: ~/.ccache | |
key: ${{ runner.os }}-ccache-${{ hashFiles('**/CMakeLists.txt') }}-${{ env.DOWNLOAD_CACHE_VERSION }} | |
restore-keys: | | |
${{ runner.os }}-ccache- | |
- name: CMake Configure | |
run: > | |
cmake -B build | |
-D CMAKE_C_COMPILER_LAUNCHER=ccache | |
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache | |
-D CMAKE_BUILD_TYPE=Debug | |
-S ${{ github.workspace }} | |
- name: CMake Build | |
run: cmake --build build --parallel $(sysctl -n hw.ncpu) | |
- name: Overwrite existing cache | |
if: ${{ steps.cache-restore.outputs.cache-hit }} | |
continue-on-error: true | |
run: | | |
gh extension install actions/gh-actions-cache | |
gh actions-cache delete "${{ env.cache-key }}" --confirm | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Save cache | |
if: always() && steps.restore-cache.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v4 | |
with: | |
key: ${{ steps.restore-cache.outputs.cache-primary-key }} | |
path: ~/.ccache |