try fix centos7 #9
This file contains hidden or 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-OpenCvSharp | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths: [ '.github/workflows/test-opencvsharp.yml' ] | |
| workflow_dispatch: | |
| jobs: | |
| ubuntu-test: | |
| name: Test OpenCvSharp | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04] | |
| steps: | |
| - name: Download OpenCvSharp Artifacts | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| echo "Fetching lastest run of opencvsharp.yml on branch ${{ github.ref_name }}" | |
| RUN_ID=$(gh run list -R ${{ github.repository }} --workflow=opencvsharp.yml --branch=${{ github.ref_name }} --status=success --limit=1 --json databaseId | jq -r '.[0].databaseId') | |
| echo "Latest opencvsharp run ID: $RUN_ID" | |
| echo "Downloading artifact 'opencvsharp' from run ${RUN_ID}" | |
| gh run download -R ${{ github.repository }} $RUN_ID --name opencvsharp-linux-x64-${{ matrix.os }} --dir opencvsharp | |
| ls -lR opencvsharp | |
| - name: Create test.c | |
| run: | | |
| mkdir test && cd test && echo '#include <stdio.h> | |
| int core_Mat_sizeof(); | |
| int main() | |
| { | |
| int i = core_Mat_sizeof(); | |
| printf("sizeof(Mat) = %d\n", i); | |
| return 0; | |
| }' > test.c | |
| cat test.c | |
| - name: Build Test | |
| run: | | |
| cd test | |
| gcc test.c -L../opencvsharp/lib -lOpenCvSharpExtern -o test | |
| - name: Run Test | |
| run: | | |
| export LD_LIBRARY_PATH=${{ github.workspace }}/opencvsharp/lib:$LD_LIBRARY_PATH | |
| cd test && ./test | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-linux-x64-${{ matrix.os }} | |
| path: test | |
| centos7-test: | |
| name: Test OpenCvSharp on CentOS 7 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download OpenCvSharp Artifacts | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| echo "Fetching latest run of opencvsharp.yml on branch ${{ github.ref_name }}" | |
| RUN_ID=$(gh run list -R ${{ github.repository }} --workflow=opencvsharp.yml --branch=${{ github.ref_name }} --status=success --limit=1 --json databaseId | jq -r '.[0].databaseId') | |
| echo "Latest opencvsharp run ID: $RUN_ID" | |
| echo "Downloading artifact 'opencvsharp-linux-x64-ubuntu-20.04' from run ${RUN_ID}" | |
| gh run download -R ${{ github.repository }} $RUN_ID --name opencvsharp-linux-x64-ubuntu-20.04 --dir opencvsharp | |
| ls -lR opencvsharp | |
| - name: Test on CentOS 7 via Docker | |
| run: | | |
| docker run --rm -v $PWD:/work -w /work centos:7 /bin/bash -c " | |
| set -eux | |
| # 将 mirrorlist.centos.org 改为 vault.centos.org | |
| sed -i 's|^mirrorlist=|#mirrorlist=|g' /etc/yum.repos.d/CentOS-*.repo | |
| sed -i 's|^#baseurl=|baseurl=|g' /etc/yum.repos.d/CentOS-*.repo | |
| sed -i 's|mirror.centos.org|vault.centos.org|g' /etc/yum.repos.d/CentOS-*.repo | |
| # 清理并重新生成缓存 | |
| yum clean all | |
| yum makecache | |
| # 安装 gcc 或其它需要的包 | |
| yum install -y gcc | |
| # 准备测试代码 | |
| mkdir -p test | |
| echo '#include <stdio.h> | |
| int core_Mat_sizeof(); | |
| int main() | |
| { | |
| int i = core_Mat_sizeof(); | |
| printf(\"sizeof(Mat) = %d\\n\", i); | |
| return 0; | |
| }' > test/test.c | |
| # 编译和运行测试 | |
| gcc test/test.c -L./opencvsharp/lib -lOpenCvSharpExtern -o test/test | |
| LD_LIBRARY_PATH=/work/opencvsharp/lib:\$LD_LIBRARY_PATH ./test/test | |
| " | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-linux-x64-centos7 | |
| path: test |