discover macOS brew installed library path #631
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: Test | |
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@v3 | |
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-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
components: rustfmt, clippy | |
override: true | |
- name: Format check | |
uses: actions-rs/cargo@v1 | |
with: | |
command: fmt | |
args: -- --check | |
- name: Lint check | |
uses: actions-rs/clippy-check@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
args: -- -D warnings -A dead_code -A improper_ctypes_definitions | |
rust_test: | |
name: cargo test | |
strategy: | |
matrix: | |
channel: [ stable, "1.64" ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
- uses: actions/cache@v3 | |
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-rs/toolchain@v1 | |
with: | |
toolchain: ${{ matrix.channel }} | |
profile: minimal | |
override: true | |
- name: Run rust test | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
args: --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-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
- uses: actions/cache@v3 | |
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: Check rustup toolchain | |
run: rustup default | |
- name: Install cbindgen | |
uses: actions-rs/cargo@v1 | |
with: | |
toolchain: stable | |
command: install | |
args: cbindgen | |
- name: cargo-c-exists | |
id: cargoCCheck | |
run: test -e ~/.cargo/bin/cargo-cbuild | |
continue-on-error: true | |
- name: Install cargo-c | |
if: ${{ always() && steps.cargoCCheck.outcome == 'failure' }} | |
uses: actions-rs/cargo@v1 | |
with: | |
toolchain: stable | |
command: install | |
args: cargo-c --version 0.9.12 | |
- name: Install required libs (Ubuntu) | |
if: matrix.os == 'ubuntu-latest' | |
run: sudo apt-get install libxkbcommon-dev | |
- name: Install required libs (MacOS) | |
if: matrix.os == 'macOS-latest' | |
run: | | |
brew install --cask xquartz | |
brew install libxkbcommon | |
echo brew path: `brew --prefix` | |
ls -l `brew --prefix`/lib | |
export DYLD_FALLBACK_LIBRARY_PATH="$(brew --prefix)/lib:$DYLD_FALLBACK_LIBRARY_PATH" | |
export LIBRARY_PATH="$(brew --prefix)/lib:$LIBRARY_PATH" | |
echo dyld_lib: $DYLD_FALLBACK_LIBRARY_PATH | |
- name: Build library | |
uses: actions-rs/cargo@v1 | |
with: | |
toolchain: stable | |
command: cbuild | |
# - name: Install library | |
# uses: actions-rs/cargo@v1 | |
# with: | |
# command: cargo cinstall --prefix=/tmp --datadir=~/.local/share | |
- 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) | |
if: matrix.os == 'macOS-latest' | |
run: cp ./target/x86_64-apple-darwin/debug/libcskk.h ./tests/ | |
- name: link lib versioning (MacOS) | |
if: matrix.os == 'macOS-latest' | |
run: ln -fs libcskk.${{ steps.versions.outputs.version }}.dylib ./target/x86_64-apple-darwin/debug/libcskk.dylib | |
- name: Show built file | |
if: matrix.os == 'macOS-latest' | |
run: ls -l ./target/* | |
- name: Show built file under debug | |
if: matrix.os == 'macOS-latest' | |
run: ls -l ./target/x86_64-apple-darwin/debug/ | |
- name: Build lib test (MacOS) | |
if: matrix.os == 'macOS-latest' | |
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) | |
if: matrix.os == 'macOS-latest' | |
run: DYLD_LIBRARY_PATH=./target/x86_64-apple-darwin/debug/ ./tests/lib_test | |