ci: Add buildcache to all CI builds (#828)

This commit is contained in:
Tyler Wilding 2021-09-06 14:29:34 -04:00 committed by GitHub
parent 7c25b721f1
commit b95ec1062e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 57 additions and 103 deletions

View file

@ -20,7 +20,6 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v2
# just do a sed for now
- name: Update Line Count
run: python ./scripts/update-file-progress.py

View file

@ -27,69 +27,29 @@ jobs:
# Set some sort of timeout in the event of run-away builds. We are limited on concurrent jobs so, get rid of them.
timeout-minutes: 20
steps:
# NOTE - useful for debugging
# - name: Dump GitHub context
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: |
# echo "$GITHUB_CONTEXT"
env: # overrides: https://github.com/mbitsnbites/buildcache/blob/master/doc/configuration.md
BUILDCACHE_MAX_CACHE_SIZE: 1000000000 # 1gb
BUILDCACHE_COMPRESS_FORMAT: ZSTD
BUILDCACHE_COMPRESS_LEVEL: 19
BUILDCACHE_DIRECT_MODE: true
BUILDCACHE_LOG_FILE: ${{ github.workspace }}/buildcache.log
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Cache Submodules
id: cache-submodules
uses: actions/cache@v2
with:
key: submodules-${{ hashFiles('./.gitmodules') }}
path: |
./third-party/googletest
./third-party/zydis
./third-party/glfw
./.git/modules/
- name: Checkout Submodules
if: steps.cache-submodules.outputs.cache-hit != 'true'
run: git submodule update --init --recursive --jobs 2
- name: Prepare Artifact Git Info
id: git-vars
shell: bash
run: |
echo "##[set-output name=branch;]${GITHUB_REF#refs/heads/}"
ARTIFACT_NAME="commit-$(git rev-parse --short "$GITHUB_SHA")"
if [ ${{ github.event_name == 'pull_request' }} ]; then
echo "##[set-output name=short-sha;]$(git rev-parse --short "${{ github.event.pull_request.head.sha }}")"
if [ ! -z "${{ github.event.pull_request.number }}" ]; then
ARTIFACT_NAME="pr-${{ github.event.pull_request.number }}-commit-$(git rev-parse --short "${{ github.event.pull_request.head.sha }}")"
fi
else
echo "##[set-output name=short-sha;]$(git rev-parse --short "$GITHUB_SHA")"
fi
echo "##[set-output name=artifact-metadata;]${ARTIFACT_NAME}"
run: git submodule update --init --recursive -j 2
- name: Get Package Dependencies
run: sudo apt install build-essential cmake ccache clang gcc g++ lcov make nasm libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev
run: sudo apt install build-essential cmake clang gcc g++ lcov make nasm libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev
# # -- SETUP CCACHE - https://cristianadam.eu/20200113/speeding-up-c-plus-plus-github-actions-using-ccache/
# - name: Prepare ccache timestamp
# id: ccache_cache_timestamp
# shell: cmake -P {0}
# run: |
# string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
# message("::set-output name=timestamp::${current_date}")
- name: Setup Buildcache
uses: mikehardy/buildcache-action@v1.2.2
with:
cache_key: ${{ matrix.os }}-${{ matrix.config }}-${{ matrix.compiler }}
# - name: ccache cache files
# uses: actions/cache@v2
# with:
# path: .ccache
# key: ${{ matrix.config }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
# restore-keys: |
# ${{ matrix.config }}-ccache-
- name: CMake Generation
# run: cmake -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache -B build -DCODE_COVERAGE=ON
- name: CMake Generation
run: |
if [ "${{ matrix.compiler }}" == 'clang' ]; then
export CC=clang
@ -98,22 +58,16 @@ jobs:
else
export CC=gcc
export CXX=g++
cmake -B build -DCODE_COVERAGE=ON
cmake -B build \
-DCMAKE_C_COMPILER_LAUNCHER="${{ github.workspace }}"/buildcache/bin/buildcache \
-DCMAKE_CXX_COMPILER_LAUNCHER="${{ github.workspace }}"/buildcache/bin/buildcache \
-DCODE_COVERAGE=ON
fi
- name: Build Project
working-directory: ./build
# env:
# CCACHE_BASEDIR: ${GITHUB_WORKSPACE}
# CCACHE_DIR: ${GITHUB_WORKSPACE}/.ccache
# CCACHE_COMPRESS: "true"
# CCACHE_COMPRESSLEVEL: "6"
# CCACHE_MAXSIZE: "400M"
# ccache -p
# ccache -z
# make -j4
# ccache -s
run: make -j4
run: |
make -j4
- name: Run Tests
run: |

View file

@ -26,6 +26,13 @@ jobs:
# Set some sort of timeout in the event of run-away builds. We are limited on concurrent jobs so, get rid of them.
timeout-minutes: 20
env: # overrides: https://github.com/mbitsnbites/buildcache/blob/master/doc/configuration.md
BUILDCACHE_MAX_CACHE_SIZE: 1000000000 # 1gb
BUILDCACHE_COMPRESS_FORMAT: ZSTD
BUILDCACHE_COMPRESS_LEVEL: 19
BUILDCACHE_DIRECT_MODE: true
BUILDCACHE_LOG_FILE: ${{ github.workspace }}/buildcache.log
steps:
# NOTE - useful for debugging
# - name: Dump GitHub context
@ -37,46 +44,22 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Cache Submodules
id: cache-submodules
uses: actions/cache@v2
with:
key: submodules-${{ hashFiles('./.gitmodules') }}
path: |
./third-party/googletest
./third-party/zydis
./third-party/glfw
./.git/modules/
- name: Checkout Submodules
if: steps.cache-submodules.outputs.cache-hit != 'true'
run: git submodule update --init --recursive --jobs 2
run: git submodule update --init --recursive -j 2
- name: Prepare Artifact Git Info
shell: bash
run: |
echo "##[set-output name=branch;]${GITHUB_REF#refs/heads/}"
ARTIFACT_NAME="commit-$(git rev-parse --short "$GITHUB_SHA")"
if [ ${{ github.event_name == 'pull_request' }} ]; then
echo "##[set-output name=short-sha;]$(git rev-parse --short "${{ github.event.pull_request.head.sha }}")"
if [ ! -z "${{ github.event.pull_request.number }}" ]; then
ARTIFACT_NAME="pr-${{ github.event.pull_request.number }}-commit-$(git rev-parse --short "${{ github.event.pull_request.head.sha }}")"
fi
else
echo "##[set-output name=short-sha;]$(git rev-parse --short "$GITHUB_SHA")"
fi
echo "##[set-output name=artifact-metadata;]${ARTIFACT_NAME}"
id: git-vars
- name: Install Dependencies
run: choco install nasm
# https://github.com/ilammy/setup-nasm
- uses: ilammy/setup-nasm@v1
- name: Setup Buildcache
uses: mikehardy/buildcache-action@v1.2.2
with:
cache_key: ${{ matrix.os }}-${{ matrix.config }}
- name: CMake Generation
shell: cmd # ideally id like everything to be powershell but running this bat file is finicky
run: |
call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
cmake --version
cmake -B build -DCMAKE_BUILD_TYPE=Release -G "NMake Makefiles" .
cmake -B build -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER="${{ github.workspace }}"/buildcache/bin/buildcache.exe -DCMAKE_CXX_COMPILER_LAUNCHER="${{ github.workspace }}"/buildcache/bin/buildcache.exe .
- name: Build Project
working-directory: ./build
@ -88,7 +71,7 @@ jobs:
- name: Run Tests
timeout-minutes: 5
run: |
$env:NEXT_DIR = $pwd
$env:FAKE_ISO_PATH = "/game/fake_iso.txt"
./build/bin/goalc-test.exe --gtest_color=yes
env:
NEXT_DIR: ${{ github.workspace }}
FAKE_ISO_PATH: ${{ github.workspace }}/game/fake_iso.txt
run: ./build/bin/goalc-test.exe --gtest_color=yes

View file

@ -45,6 +45,24 @@ if(ASAN_BUILD)
message(STATUS "Doing ASAN build")
endif()
# if(WIN32)
# find_program(buildcache_program buildcache ${PROJECT_SOURCE_DIR}/bin/windows/)
# if(buildcache_program)
# message("Found Windows BuildCache, gonna use it!")
# set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${buildcache_program}")
# else()
# message("Windows Buildcache not found!")
# endif()
# else()
# find_program(buildcache_program buildcache ${PROJECT_SOURCE_DIR}/bin/linux/)
# if(buildcache_program)
# message("Found Linux BuildCache, gonna use it!")
# set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${buildcache_program}")
# else()
# message("Linux Buildcache not found!")
# endif()
# endif()
option(CODE_COVERAGE "Enable Code Coverage Compiler Flags" OFF)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/third-party/cmake/modules/)

BIN
bin/linux/buildcache Executable file

Binary file not shown.

BIN
bin/windows/buildcache.exe Normal file

Binary file not shown.