cskk 3.1.4

C ABIから使う事を目的とした SKK(Simple Kana Kanji henkan)方式のかな漢字変換ライブラリ
Documentation
name: Continuous branch tests before merge
on: [push, workflow_dispatch]

concurrency:
  group: ${{ github.ref_name }}
  cancel-in-progress: true

jobs:
  lint:
    name: lint and format check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
      - name: Install cargo
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: stable
          components: rustfmt, clippy
          rustflags: ""
          override: true
      - name: Lint and format
        uses: ./.github/actions/lint_format
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
  rust_test:
    name: cargo test
    strategy:
      matrix:
        channel: [ stable, "1.64" ]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target
          key: ${{ runner.os }}-cargo-${{ matrix.channel }}-${{ hashFiles('**/Cargo.lock') }}
      - name: Install required libs (Ubuntu)
        run: sudo apt-get install libxkbcommon-dev
      - name: Install cargo
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: ${{ matrix.channel }}
          rustflags: ""
          override: true
      - name: Run rust test
        run: cargo test --features capi
  library_test:
    name: library test
    strategy:
      matrix:
        os: [ ubuntu-latest, macos-latest ]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@master
      - name: check version
        id: versions
        run: |
          echo version=`bin/version.sh` >> ${GITHUB_OUTPUT}
          echo major-version=`bin/major_version.sh` >> ${GITHUB_OUTPUT}
      - name: output version
        run: | 
          echo Version: ${{ steps.versions.outputs.version }} 
          echo MajorVersion: ${{ steps.versions.outputs.major-version }}
      - name: Install cargo
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: stable
          rustflags: ""
          override: true
      - uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target
          key: ${{ runner.os }}-cargo-libtest-v6-${{ hashFiles('**/Cargo.lock') }}-cargo-c-v0.9.6
      - name: Install required rust tools
        uses: ./.github/actions/install_required_cargo_bins
      - name: Install required libs (Ubuntu)
        if: matrix.os == 'ubuntu-latest'
        run: sudo apt-get install libxkbcommon-dev
      - name: Install required libs (MacOS M1 and intel)
        if: matrix.os == 'macos-latest' || matrix.os == 'macos-12'
        run: |
          brew install --cask xquartz
          brew install libxkbcommon
          echo `brew --prefix`
      - name: Build library
        run: cargo +stable cbuild
      - name: copy shared data
        run: mkdir -p ~/.local/share/libcskk && cp -r ./assets/* ~/.local/share/libcskk
      # TODO: Use variable in github actions? Only target directory is different here.
      - name: copy header file (Ubuntu)
        if: matrix.os == 'ubuntu-latest'
        run: cp ./target/x86_64-unknown-linux-gnu/debug/libcskk.h ./tests/
      - name: link lib versioning (Ubuntu)
        if: matrix.os == 'ubuntu-latest'
        run: ln -fs libcskk.so ./target/x86_64-unknown-linux-gnu/debug/libcskk.so.${{ steps.versions.outputs.major-version }}
      - name: Show built file
        if: matrix.os == 'ubuntu-latest'
        run: ls -l ./target/*
      - name: Show built file under debug
        if: matrix.os == 'ubuntu-latest'
        run: ls -l ./target/x86_64-unknown-linux-gnu/debug/
      - name: Build lib test (Ubuntu)
        if: matrix.os == 'ubuntu-latest'
        run: gcc ./tests/c_shared_lib_test.c -L ./target/x86_64-unknown-linux-gnu/debug/ -lcskk -o ./tests/lib_test
      - name: Run lib test (Ubuntu)
        if: matrix.os == 'ubuntu-latest'
        run: LD_LIBRARY_PATH=./target/x86_64-unknown-linux-gnu/debug ./tests/lib_test
#      - name: copy header file (MacOS intel)
#        if: matrix.os == 'macos-12'
#        run: cp ./target/x86_64-apple-darwin/debug/libcskk.h ./tests/
#      - name: link lib versioning (MacOS intel)
#        if: matrix.os == 'macos-12'
#        run: ln -fs libcskk.${{ steps.versions.outputs.version }}.dylib ./target/x86_64-apple-darwin/debug/libcskk.dylib
#      - name: Show built file (MacOS intel)
#        if: matrix.os == 'macos-12'
#        run: ls -l ./target/*
#      - name: Show built file under debug (MacOS intel)
#        if: matrix.os == 'macos-12'
#        run: ls -l ./target/x86_64-apple-darwin/debug/
#      - name: Build lib test (MacOS intel)
#        if: matrix.os == 'macos-12'
#        run: gcc ./tests/c_shared_lib_test.c -L./target/x86_64-apple-darwin/debug/ -lcskk -lxkbcommon -o ./tests/lib_test
#      - name: Run lib test (MacOS intel)
#        if: matrix.os == 'macos-12'
#        run: DYLD_LIBRARY_PATH=./target/x86_64-apple-darwin/debug/ ./tests/lib_test
      - name: copy header file (MacOS M1)
        if: matrix.os == 'macos-latest'
        run: cp ./target/aarch64-apple-darwin/debug/libcskk.h ./tests/
      - name: link lib versioning (MacOS M1)
        if: matrix.os == 'macos-latest'
        run: ln -fs libcskk.${{ steps.versions.outputs.version }}.dylib ./target/aarch64-apple-darwin/debug/libcskk.dylib
      - name: Show built file (MacOS M1)
        if: matrix.os == 'macos-latest'
        run: ls -l ./target/*
      - name: Show built file under debug (MacOS M1)
        if: matrix.os == 'macos-latest'
        run: ls -l ./target/aarch64-apple-darwin/debug/
      - name: Build lib test (MacOS M1)
        if: matrix.os == 'macos-latest'
        run: gcc ./tests/c_shared_lib_test.c -L./target/aarch64-apple-darwin/debug/ "-L$(brew --prefix)/lib/" -lcskk -lxkbcommon -o ./tests/lib_test
      - name: Run lib test (MacOS M1)
        if: matrix.os == 'macos-latest'
        run: DYLD_LIBRARY_PATH=./target/aarch64-apple-darwin/debug/:$(brew --prefix)/lib/ ./tests/lib_test