diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 0000000..889b4aa --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,67 @@ +# GH actions + +name: unittest + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +env: + BUILD_TYPE: Release + +jobs: + build: + runs-on: ${{ matrix.image }} + strategy: + matrix: + image: [ 'windows-latest', 'ubuntu-latest', 'macos-latest' ] + include: + - image: windows-latest + cmake_type: -Dgtest_force_shared_crt=ON -G "Visual Studio 16 2019" -A x64 + build_with: -G "Visual Studio 16 2019" -A x64 + - image: ubuntu-latest + cmake_type: -G Ninja + build_with: -G Ninja + - image: macos-latest + cmake_type: -G Ninja + build_with: -G Ninja + fail-fast: false + + steps: + - name: Clone repository + uses: actions/checkout@v2 + + - name: Setup Ninja + uses: seanmiddleditch/gha-setup-ninja@v3 + + - name: cache-googletest + id: cache-googletest + uses: actions/cache@v2.1.6 + with: + path: googletest-install-${{ matrix.image }} + key: cache-googletest-${{ matrix.image }} + + - name: Install googletest + shell: bash + if: steps.cache-googletest.outputs.cache-hit != 'true' + run: | + git clone https://github.com/google/googletest --depth 1 + cd googletest + mkdir build && cd build + cmake .. -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_INSTALL_PREFIX='${{ github.workspace }}'/googletest-install-${{ matrix.image }} ${{ matrix.cmake_type }} + cmake --build . --config ${{ env.BUILD_TYPE }} -j 2 + cmake --install . --config ${{ env.BUILD_TYPE }} + + - name: Configure with CMake + shell: bash + run: | + mkdir build + cd build + cmake ${{ matrix.build_with }} .. -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DSHUFACV_TEST=ON -DGTest_DIR='${{ github.workspace }}'/googletest-install-${{ matrix.image }}/lib/cmake/GTest + - name: Building + run: cmake --build build --config ${{ env.BUILD_TYPE }} + - name: Testing + working-directory: ${{ github.workspace }}/build + run: ctest -C ${{ env.BUILD_TYPE }} --output-on-failure diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml deleted file mode 100644 index bd4c3c7..0000000 --- a/.github/workflows/unit_test.yml +++ /dev/null @@ -1,69 +0,0 @@ -# GH actions - -name: unittest - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -env: - BUILD_TYPE: Release - -jobs: - build: - runs-on: ${{ matrix.image }} - strategy: - matrix: - image: [ 'windows-latest', 'ubuntu-latest', 'macos-latest' ] - fail-fast: false - - steps: - - name: Clone repository - uses: actions/checkout@v2 - - - name: Setup Ninja - uses: seanmiddleditch/gha-setup-ninja@v3 - - - name: cache-googletest - id: cache-googletest - uses: actions/cache@v2.1.6 - with: - path: googletest-install-${{ matrix.image }} - key: cache-googletest-${{ matrix.image }} - - - name: Install googletest - shell: bash - if: steps.cache-googletest.outputs.cache-hit != 'true' - run: | - git clone https://github.com/google/googletest --depth 1 - cd googletest - mkdir build && cd build - if [ '${{runner.os}}' == 'Windows' ]; then - echo "Yes, this is on Windows" - cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX='${{github.workspace}}'/googletest-install-${{ matrix.image }} -Dgtest_force_shared_crt=ON -G "Visual Studio 16 2019" -A x64 - else - echo "Ohh, this is not on Windows" - cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX='${{github.workspace}}'/googletest-install-${{ matrix.image }} -G Ninja - fi - cmake --build . --config ${{env.BUILD_TYPE}} -j 2 - cmake --install . --config ${{env.BUILD_TYPE}} - - - name: Configure with CMake - shell: bash - run: | - mkdir build - cd build - if [ '${{runner.os}}' == 'Windows' ]; then - echo "Yes, this is on Windows" - cmake -G "Visual Studio 16 2019" -A x64 .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DSHUFACV_TEST=ON -DGTest_DIR='${{github.workspace}}'/googletest-install-${{ matrix.image }}/lib/cmake/GTest - else - echo "Ohh, this is not on Windows" - cmake -G Ninja .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DSHUFACV_TEST=ON -DGTest_DIR=${{github.workspace}}/googletest-install-${{ matrix.image }}/lib/cmake/GTest - fi - - name: Building - run: cmake --build build --config ${{env.BUILD_TYPE}} - - name: Testing - working-directory: ${{github.workspace}}/build - run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure diff --git a/README.md b/README.md index a319584..f800895 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ - - # shufaCV (书法CV) [![License](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg)](.LICENSE) -[![unittest](https://github.com/scarsty/shufaCV/actions/workflows/unit_test.yml/badge.svg)](https://github.com/scarsty/shufaCV/actions/workflows/unit_test.yml) +[![unittest](https://github.com/scarsty/shufaCV/actions/workflows/unit-test.yml/badge.svg)](https://github.com/scarsty/shufaCV/actions/workflows/unit-test.yml) [![codecov](https://codecov.io/gh/scarsty/shufacv/branch/main/graph/badge.svg)](https://codecov.io/gh/scarsty/shufacv) ![Widows](https://img.shields.io/badge/Windows-gray?logo=windows&logoColor=blue) ![Ubuntu](https://img.shields.io/badge/Ubuntu-gray?logo=ubuntu) @@ -16,6 +14,6 @@ QQ 群: 822911263 ## 授权 -``` +```bash 以 BSD 3-Clause License 授权发布。若将其商业应用,我们建议您提交一张书法照到官方 QQ 群。 ```