Skip to content

Inflection 77: Adding C and C++ API for stating source grammemes and tests for the same. #327

Inflection 77: Adding C and C++ API for stating source grammemes and tests for the same.

Inflection 77: Adding C and C++ API for stating source grammemes and tests for the same. #327

# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: CMake on multiple platforms
on:
# Keep it for manual runs.
workflow_dispatch:
# Run it on all branches but ignore some paths.
pull_request:
paths:
- 'inflection/**'
- '.github/workflows/**'
- '!data/**'
- '!documents/**'
- '!fst/**'
# Run the build when we merge into main
push:
branches:
- main
paths:
- 'inflection/**'
- '.github/workflows/**'
env:
ICU_MAJOR: '77'
ICU_MINOR: '1'
jobs:
cache-icu:
runs-on: ubuntu-latest
steps:
- uses: actions/cache/restore@v4
id: cache
with:
path: ~/icu
key: ${{ runner.os }}-icu-${{ env.ICU_MAJOR }}-${{ env.ICU_MINOR }}
- name: Download and install icu
if: steps.cache.outputs.cache-hit != 'true'
run: |
wget https://github.com/unicode-org/icu/releases/download/release-${ICU_MAJOR}-${ICU_MINOR}/icu4c-${ICU_MAJOR}_${ICU_MINOR}-Ubuntu22.04-x64.tgz
export ICU=~/icu/
mkdir -p $ICU
echo "ICU directory is $ICU"
# Get the release and unpack.
cp icu4c-${ICU_MAJOR}_${ICU_MINOR}-Ubuntu22.04-x64.tgz $ICU
pushd $ICU
pwd
tar xvfz *.tgz
rm *.tgz
- uses: actions/cache/save@v4
with:
path: ~/icu
key: ${{ runner.os }}-icu-${{ env.ICU_MAJOR }}-${{ env. ICU_MINOR }}
build:
needs: cache-icu
runs-on: ${{ matrix.os }}
strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false
# Set up a matrix to run the following configurations:
# 1. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest, macos-latest]
build_type: [Release]
c_compiler: [clang]
# All [OS x compiler] items should be covered in include/exclude sections.
include:
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
- os: macos-latest
c_compiler: clang
cpp_compiler: clang++
steps:
- uses: actions/checkout@v4
- name: Create Git LFS file list
run: git lfs ls-files -l |cut -d' ' -f1 |sort >.git/lfs-hashes.txt
- name: Restore Git LFS object cache
uses: actions/cache@v4
id: lfscache
with:
path: inflection/resources/org/unicode/inflection/dictionary
key: ${{ runner.os }}-lfsdata-v1-${{ hashFiles('.git/lfs-hashes.txt') }}
restore-keys: |
${{ runner.os }}-lfsdata-v1-
${{ runner.os }}-lfsdata
- name: Fetch any needed Git LFS objects and prune extraneous ones
if: steps.lfscache.outputs.cache-hit != 'true'
run: git lfs fetch --prune
- name: Check out Git LFS content
if: steps.lfscache.outputs.cache-hit != 'true'
run: git lfs checkout
- name: Check LFS restore the files or not after checkout
run: ls -l inflection/resources/org/unicode/inflection/dictionary/*
- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "project-root-dir=${{ github.workspace }}/inflection" >> "$GITHUB_OUTPUT"
echo "build-output-dir=${{ github.workspace }}/inflection/build" >> "$GITHUB_OUTPUT"
- uses: actions/cache/restore@v4
id: cache
with:
path: ~/icu
key: ${{ runner.os }}-icu-${{ env.ICU_MAJOR }}-${{ env.ICU_MINOR }}
# Install all the required dependencies for the macos
- name: Install ICU (Ubuntu/macos)
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
echo "ICU_ROOT=~/icu/icu/usr/local" >> $GITHUB_ENV
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
brew list icu4c || brew install icu4c
echo "ICU_ROOT=$(brew --prefix icu4c)" >> $GITHUB_ENV
fi
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ steps.strings.outputs.project-root-dir }}
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} -j ${{ steps.cpu-cores.outputs.count }}
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: cmake --build . -t check -j ${{ steps.cpu-cores.outputs.count }}