Copybara import of the project:

--
c64b6fd3a44b385e1502d2057bd8709edaebaa58 by David Coles <dcoles@dcoles.net>:

Include Windows in GitHub Actions build

This also preserves the `gemma` binary as a build artefact
should folks want to grab a pre-built binary.

Dropped the use of the lukka/cmake actions due to conflicts with `--preset`.
This isn't that bad as we were mostly overriding the default behaviour anyway.

It also shaves ~2 min off the build since the GitHub builders already
have CMake pre-installed.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/gemma.cpp/pull/38 from dcoles:windows-build c64b6fd3a44b385e1502d2057bd8709edaebaa58
PiperOrigin-RevId: 610449220
This commit is contained in:
David Coles 2024-02-26 10:22:24 -08:00 committed by Copybara-Service
parent 7ab968c957
commit 7aeade5c9d
1 changed files with 30 additions and 19 deletions

View File

@ -6,17 +6,25 @@ on: [push, pull_request, workflow_dispatch]
jobs:
build:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} ${{ matrix.type }}
name: ${{ matrix.os }} (${{ matrix.preset }}) ${{ matrix.build_type }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
type: ['Release']
os: ['ubuntu-latest', 'macos-latest']
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
build_type: ['Release']
preset: ['make', 'windows']
exclude:
- os: ubuntu-latest
preset: windows
- os: macos-latest
preset: windows
- os: windows-latest
preset: make
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.type }}
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.preset }}-${{ matrix.build_type }}
cancel-in-progress: true
steps:
@ -26,20 +34,23 @@ jobs:
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
# Install CMake
- uses: lukka/get-cmake@latest
- name: Configure CMake
run: >
cmake --preset ${{ matrix.preset }}
-S ${{ github.workspace }} -B ${{ github.workspace }}/build
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }}
-D CMAKE_C_COMPILER_LAUNCHER=ccache
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache
# Build via CMake
# Reference: https://github.com/lukka/run-cmake/blob/v3/action.yml
- name: Build via cmake
uses: lukka/run-cmake@v3
- name: Build
run: cmake --build ${{ github.workspace }}/build --preset ${{ matrix.preset }} --config ${{ matrix.build_type }}
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeAppendedArgs: >
-D CMAKE_C_COMPILER_LAUNCHER=ccache
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache
buildWithCMake: true
# Explicitly list build targets here.
# Building "all" includes test executables and takes much longer.
buildWithCMakeArgs: "-- gemma"
buildDirectory: '${{ github.workspace }}/build'
name: gemma-${{ matrix.os }}-${{ matrix.preset }}-${{ matrix.build_type }}
path: |
${{ github.workspace }}/build/${{ matrix.build_type }}/gemma.exe
${{ github.workspace }}/build/${{ matrix.build_type }}/libgemma.lib
${{ github.workspace }}/build/gemma
${{ github.workspace }}/build/libgemma.a