CI: Add ccache. #6
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: CMake | |
on: | |
push: | |
pull_request: | |
release: | |
types: [created] | |
env: | |
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | |
BUILD_TYPE: Release | |
jobs: | |
build: | |
name: Linux | |
runs-on: ubuntu-22.04 | |
env: | |
CI_PROJECT_ROOT: ${{ github.workspace }}/src-${{ github.sha }} | |
CI_BUILD_ROOT: ${{ github.workspace }} | |
CMAKE_C_COMPILER_LAUNCHER: ccache | |
CMAKE_CXX_COMPILER_LAUNCHER: ccache | |
steps: | |
- name: "CCache: ~/.ccache Fixup" | |
run: | | |
mkdir -p /home/runner/.ccache | |
- name: "CCache: Restore saved cache" | |
uses: actions/cache@v4 | |
with: | |
path: /home/runner/.ccache | |
key: ccache-${{ github.ref }}-${{ github.sha }} | |
restore-keys: | | |
ccache-${{ github.ref }}-${{ github.sha }} | |
ccache-${{ github.ref }} | |
- name: "CCache: Install ccache." | |
run: sudo apt update && sudo apt install ccache | |
- name: Prepare Code | |
uses: actions/checkout@v4 | |
with: | |
path: src-${{ github.sha }} | |
submodules: true | |
- name: Install Arm GNU Toolchain (arm-none-eabi-gcc) | |
uses: carlosperate/arm-none-eabi-gcc-action@v1 | |
with: | |
release: '13.3.Rel1' | |
- name: "Prepare tools & dependencies" | |
shell: bash | |
run: | | |
source $CI_PROJECT_ROOT/ci/cpp.sh && ci_debug | |
ci_prepare_all | |
- name: "CMake: Configure" | |
shell: bash | |
run: | | |
source $CI_PROJECT_ROOT/ci/cpp.sh && ci_debug | |
ci_cmake_configure | |
- name: "CMake: Build" | |
shell: bash | |
run: | | |
source $CI_PROJECT_ROOT/ci/cpp.sh && ci_debug | |
ccache --zero-stats || true | |
ci_cmake_build | |
ccache --show-stats || true | |
ci_cmake_package | |
- name: "CMake: Post" | |
shell: bash | |
run: | | |
cd ${{ env.CI_BUILD_ROOT }} | |
echo "RELEASE_FILE=$(ls *.uf2 | cut -d. -f1)" >> $GITHUB_ENV | |
- name: "Artifacts: Upload .uf2" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.RELEASE_FILE }}.uf2 | |
path: ${{ env.CI_BUILD_ROOT }}/${{ env.RELEASE_FILE }}.uf2 | |
- name: "Release: Upload Files" | |
if: github.event_name == 'release' | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
${{ env.CI_BUILD_ROOT }}/${{ env.RELEASE_FILE }}.uf2 | |
${{ env.CI_BUILD_ROOT }}/${{ env.RELEASE_FILE }}.zip | |
${{ env.CI_BUILD_ROOT }}/${{ env.RELEASE_FILE }}.tar.gz |