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