Skip to content

fix yaml

fix yaml #238

Workflow file for this run

name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master ]
tags: [ '*' ]
pull_request:
branches: [ master ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Windows:
runs-on: windows-latest
needs: Linux
strategy:
fail-fast: true
matrix:
include:
- arch: x86
- arch: x64
steps:
- name: "Set Build Type"
id: build_type
run: |
if ("${{ github.ref }}".StartsWith("refs/tags/")) {
echo "BUILD_TYPE::Release";
echo "::set-output name=BUILD_TYPE::Release";
} else {
echo "BUILD_TYPE::Debug";
echo "::set-output name=BUILD_TYPE::Debug";
}
if ("${{ matrix.arch }}" -eq "x64") {
echo "Arch:x64";
echo "::set-output name=BUILD_ARCH::x64";
} else {
echo "Arch:Win32";
echo "::set-output name=BUILD_ARCH::Win32";
}
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# https://github.com/OpenTTD/OpenTTD/blob/master/.github/workflows/ci-build.yml
# "restore-cache" which is done by "run-vcpkg" uses Windows tar.
# A git clone on windows marks a few files as read-only; when Windows tar
# tries to extract the cache over this folder, it fails, despite the files
# being identical. This failure shows up as an warning in the logs. We
# avoid this by simply removing the read-only mark from the git folder.
# In other words: this is a hack!
# See: https://github.com/lukka/run-vcpkg/issues/61
# - name: Remove read-only flag from vcpkg git folder
# shell: powershell
# run: |
# attrib -r "c:\vcpkg\.git\*.*" /s
# - name: Prepare vcpkg (with cache)
# uses: lukka/run-vcpkg@v6
# with:
# vcpkgDirectory: 'c:/vcpkg'
# doNotUpdateVcpkg: true
# vcpkgArguments: 'liblzma libpng lzo zlib'
# vcpkgTriplet: '${{ matrix.arch }}-windows-static'
# - name: Install MSVC problem matcher
# uses: ammaraskar/msvc-problem-matcher@master
- name: 'Run CMake with VS16'
uses: lukka/run-cmake@v3
with:
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
buildDirectory: "${{ github.workspace }}/../../_temp/windows"
useVcpkgToolchainFile: true
cmakeBuildType: ${{ steps.build_type.outputs.BUILD_TYPE }}
buildWithCMake: true
cmakeGenerator: VS16Win64
cmakeAppendedArgs: -A ${{steps.build_type.outputs.BUILD_ARCH }}
buildWithCMakeArgs: --config ${{ steps.build_type.outputs.BUILD_TYPE }}
- name: "Check file existence"
uses: andstor/file-existence-action@v1
with:
allow_failure: true
files: "${{ github.workspace }}/../../_temp/windows/src/${{ steps.build_type.outputs.BUILD_TYPE }}/simple.dll, ${{ github.workspace }}/../../_temp/windows/cppjieba/src/cppjieba/dict/jieba.dict.utf8"
# can't build
# npm run
# - uses: actions/setup-node@v2
# with:
# node-version: '16'
# - name: run node example
# working-directory: ./examples/node/
# run: |
# npm install
# npm run p -- --ext_path="${{ github.workspace }}/../../_temp/windows/src/${{ steps.build_type.outputs.BUILD_TYPE }}/" --dict_path="${{ github.workspace }}/../../_temp/windows/cppjieba/src/cppjieba/dict/"
# - name: 'Run CTest'
# run: ctest -C ${{ env.BUILD_TYPE }}
# working-directory: "${{ github.workspace }}/../../_temp/windows"
# python run
# - uses: actions/setup-python@v4
# with:
# python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
# - name: run python example
# working-directory: ./examples/python3/
# run: python db_connector.py "${{ github.workspace }}/../../_temp/windows/src/${{ steps.build_type.outputs.BUILD_TYPE }}/simple"
- name: Package
if: startsWith(github.ref, 'refs/tags/')
run: |
mkdir libsimple-windows-${{ matrix.arch }}
Copy-Item -Path src/${{ steps.build_type.outputs.BUILD_TYPE }}/simple.dll,cppjieba/src/cppjieba/dict/ -Destination libsimple-windows-${{ matrix.arch }}/ -Recurse
Compress-Archive -Path libsimple-windows-${{ matrix.arch }} -DestinationPath libsimple-windows-${{ matrix.arch }}.zip
working-directory: "${{ github.workspace }}/../../_temp/windows/"
- name: Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
draft: true
files: "D:/a/_temp/windows/libsimple-windows-${{ matrix.arch }}.zip"
# files: "${{ github.workspace }}/../../_temp/windows/libsimple-windows-${{ matrix.arch }}.zip"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# copy from https://github.com/Cyan4973/xxHash/blob/dev/.github/workflows/ci.yml
# Linux ARM64
# All tests are using QEMU and gcc cross compiler.
qemu-consistency:
name: QEMU ${{ matrix.name }}
needs: Linux
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true # 'false' means Don't stop matrix workflows even if some matrix failed.
matrix:
include: [
{ name: 'ARM64', xcc_pkg: gcc-aarch64-linux-gnu, xcc: aarch64-linux-gnu-gcc, xemu_pkg: qemu-system-arm, xemu: qemu-aarch64-static, os: ubuntu-latest, },
{ name: 'ARM64, gcc-9', xcc_pkg: gcc-9-aarch64-linux-gnu, xcc: aarch64-linux-gnu-gcc-9, xemu_pkg: qemu-system-arm, xemu: qemu-aarch64-static, os: ubuntu-20.04, },
]
env: # Set environment variables
CC: ${{ matrix.xcc }}
XEMU: ${{ matrix.xemu }}
# LDFLAGS: -static
steps:
- uses: actions/checkout@v2 # https://github.com/actions/checkout
- name: apt update & install (1)
run: |
sudo apt-get update
sudo apt-get install gcc-multilib g++-multilib qemu-utils qemu-user-static
- name: Environment info (1)
run: |
echo && apt-cache search "^gcc-" | grep "linux" | sort
- name: apt update & install (2)
run: |
sudo apt-get install ${{ matrix.xcc_pkg }} ${{ matrix.xemu_pkg }}
- name: Environment info (2)
run: |
echo && which $CC
echo && $CC --version
echo && $CC -v # Show built-in specs
echo && which $XEMU
echo && $XEMU --version
- name: ARM64
uses: lukka/run-cmake@v3
with:
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
cmakeBuildType: 'Release'
buildDirectory: "${{ github.workspace }}/build"
buildWithCMake: true
buildWithCMakeArgs: --config Release
# cmakeAppendedArgs: " -DCODE_COVERAGE=OFF -DBUILD_SHELL=OFF -DBUILD_TEST_EXAMPLE=OFF -DBUILD_STATIC"
cmakeAppendedArgs: " -DCODE_COVERAGE=OFF -DBUILD_SHELL=OFF -DBUILD_TEST_EXAMPLE=OFF"
- name: "Check file existence"
uses: andstor/file-existence-action@v1
with:
allow_failure: true
# files: "${{ github.workspace }}/build/src/libsimple.a, ${{ github.workspace }}/build/src/libPINYIN_TEXT.a, ${{ github.workspace }}/build/test/dict/jieba.dict.utf8"
files: "${{ github.workspace }}/build/src/libsimple.so, ${{ github.workspace }}/build/test/dict/jieba.dict.utf8"
- name: Package
if: startsWith(github.ref, 'refs/tags/')
run: |
mkdir libsimple-${{ matrix.xcc }}
# cp -r src/libsimple.a src/libPINYIN_TEXT.a test/dict/ libsimple-linux-${{ matrix.xcc }}/
cp -r src/libsimple.so test/dict/ libsimple-${{ matrix.xcc }}/
zip -r libsimple-${{ matrix.xcc }}.zip libsimple-${{ matrix.xcc }}
working-directory: "${{ github.workspace }}/build"
- name: Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
draft: true
files: ${{ github.workspace }}/build/libsimple-${{ matrix.xcc }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Linux:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-latest
steps:
- name: "Release Build Type"
if: startsWith(github.ref, 'refs/tags/')
run: echo "BUILD_TYPE=Release" >> $GITHUB_ENV
- name: "Debug Build Type"
if: startsWith(github.ref, 'refs/tags/') != true
run: echo "BUILD_TYPE=Debug" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: Update apt-get
run: sudo apt-get update
- name: Install lcov
if: startsWith(github.ref, 'refs/tags/') != true
run: sudo apt-get install lcov
- name: Install codecov
if: startsWith(github.ref, 'refs/tags/') != true
shell: bash
run: sudo pip install codecov
- name: 'Run CMake'
uses: lukka/run-cmake@v3
if: startsWith(github.ref, 'refs/tags/') != true
with:
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
cmakeBuildType: ${{ env.BUILD_TYPE }}
buildDirectory: "${{ github.workspace }}/build"
buildWithCMake: true
buildWithCMakeArgs: --config ${{ env.BUILD_TYPE }}
cmakeAppendedArgs: " -DCODE_COVERAGE=ON "
- name: 'Run CMake without coverage'
if: startsWith(github.ref, 'refs/tags/')
uses: lukka/run-cmake@v3
with:
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
cmakeBuildType: ${{ env.BUILD_TYPE }}
buildDirectory: "${{ github.workspace }}/build"
buildWithCMake: true
buildWithCMakeArgs: --config ${{ env.BUILD_TYPE }}
cmakeAppendedArgs: " -DCODE_COVERAGE=OFF -DBUILD_SHELL=OFF -DBUILD_TEST_EXAMPLE=OFF"
- name: 'Run CTest'
if: ${{ startsWith(github.ref, 'refs/tags/') != true && matrix.os == 'ubuntu-latest' }}
run: ctest -V -C ${{ env.BUILD_TYPE }}
working-directory: "${{ github.workspace }}/build"
# CODE COVERAGE
- name: Code coverage - Capture coverage info
if: ${{ startsWith(github.ref, 'refs/tags/') != true && matrix.os == 'ubuntu-latest' }}
run: lcov --directory . --capture --output-file coverage.info
- name: Code coverage - Filter out system, external, and unit test source files
if: ${{ startsWith(github.ref, 'refs/tags/') != true && matrix.os == 'ubuntu-latest' }}
run: lcov --remove coverage.info --output-file coverage_filter.info '/Library/*' '/usr/*' '*/test/*' '*/cmrc/*' '*/entry.cc' '*/simple_highlight.*'
- name: Code coverage - Output coverage data for debugging
if: ${{ startsWith(github.ref, 'refs/tags/') != true && matrix.os == 'ubuntu-latest' }}
run: lcov --list coverage_filter.info
- name: Code coverage - Upload to CodeCov
if: ${{ startsWith(github.ref, 'refs/tags/') != true && matrix.os == 'ubuntu-latest' }}
run: bash <(curl -s https://codecov.io/bash) -f coverage_filter.info || echo "Codecov did not collect coverage reports"
- name: "Check file existence"
uses: andstor/file-existence-action@v1
with:
allow_failure: true
files: "${{ github.workspace }}/build/src/libsimple.so, ${{ github.workspace }}/build/test/dict/jieba.dict.utf8"
# npm run
- uses: actions/setup-node@v2
if: startsWith(github.ref, 'refs/tags/') != true
with:
node-version: '16'
- name: run node example
if: startsWith(github.ref, 'refs/tags/') != true
working-directory: ./examples/node/
run: |
npm install
npm run p -- --ext_path="${{ github.workspace }}/build/src/" --dict_path="${{ github.workspace }}/build/test/dict/"
npm run b -- --ext_path="${{ github.workspace }}/build/src/" --dict_path="${{ github.workspace }}/build/test/dict/"
# python run
- uses: actions/setup-python@v4
if: startsWith(github.ref, 'refs/tags/') != true
with:
python-version: '3.10' # Version range or exact version of a Python version to use, using SemVer's version range syntax
- name: run python example
if: startsWith(github.ref, 'refs/tags/') != true
working-directory: ./examples/python3/
run: python db_connector.py "${{ github.workspace }}/build/src/libsimple"
# create release
- name: "Build Changelog"
id: build_changelog
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest' }}
uses: mikepenz/release-changelog-builder-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Package
if: startsWith(github.ref, 'refs/tags/')
run: |
mkdir libsimple-linux-${{ matrix.os }}
cp -r src/libsimple.so test/dict/ libsimple-linux-${{ matrix.os }}/
zip -r libsimple-linux-${{ matrix.os }}.zip libsimple-linux-${{ matrix.os }}
working-directory: "${{ github.workspace }}/build"
- name: Release without changelog
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.os != 'ubuntu-latest' }}
uses: softprops/action-gh-release@v1
with:
draft: true
files: ${{ github.workspace }}/build/libsimple-linux-${{ matrix.os }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest' }}
uses: softprops/action-gh-release@v1
with:
draft: true
files: ${{ github.workspace }}/build/libsimple-linux-${{ matrix.os }}.zip
body: ${{steps.build_changelog.outputs.changelog}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MacOS:
runs-on: macos-latest
needs: Linux
steps:
- name: "Release Build Type"
if: startsWith(github.ref, 'refs/tags/')
run: echo "BUILD_TYPE=Release" >> $GITHUB_ENV
- name: "Debug Build Type"
if: startsWith(github.ref, 'refs/tags/') != true
run: echo "BUILD_TYPE=Debug" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: 'Run CMake'
uses: lukka/run-cmake@v3
with:
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
cmakeBuildType: ${{ env.BUILD_TYPE }}
buildDirectory: "${{ github.workspace }}/../../_temp/macos"
buildWithCMake: true
cmakeAppendedArgs: -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/../../_temp/macos/install"
buildWithCMakeArgs: --config ${{ env.BUILD_TYPE }}
- name: 'Run CTest'
run: ctest -C ${{ env.BUILD_TYPE }}
working-directory: "${{ github.workspace }}/../../_temp/macos"
- name: "Check file existence"
uses: andstor/file-existence-action@v1
with:
allow_failure: true
files: "${{ github.workspace }}/../../_temp/macos/src/libsimple.dylib, ${{ github.workspace }}/../../_temp/macos/test/dict/jieba.dict.utf8"
# npm run
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: run node example
working-directory: ./examples/node/
run: |
npm install
npm run p -- --ext_path="${{ github.workspace }}/../../_temp/macos/src/" --dict_path="${{ github.workspace }}/../../_temp/macos/test/dict/"
# don't run this as it's toooo slow
# npm run b -- --ext_path="${{ github.workspace }}/../../_temp/macos/src/" --dict_path="${{ github.workspace }}/../../_temp/macos/test/dict/"
# python run
- uses: actions/setup-python@v4
with:
python-version: '3.10' # Version range or exact version of a Python version to use, using SemVer's version range syntax
- name: run python example
working-directory: ./examples/python3/
run: python db_connector.py "${{ github.workspace }}/../../_temp/macos/src/libsimple"
- name: Package
if: startsWith(github.ref, 'refs/tags/')
run: |
mkdir libsimple-osx-x64
sudo xattr -r -d com.apple.quarantine src/libsimple.dylib
cp -r src/libsimple.dylib test/dict libsimple-osx-x64/
zip -r libsimple-osx-x64.zip libsimple-osx-x64
working-directory: "${{ github.workspace }}/../../_temp/macos"
- name: Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
draft: true
files: ${{ github.workspace }}/../../_temp/macos/libsimple-osx-x64.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: build-iOS
run: ./build-ios.sh