Skip to content

Commit c303fe4

Browse files
committed
try fix centos7
1 parent 68e6fbe commit c303fe4

File tree

1 file changed

+33
-22
lines changed

1 file changed

+33
-22
lines changed

.github/workflows/test-opencvsharp.yml

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,10 @@ jobs:
5656
path: test
5757

5858
centos7-test:
59-
name: Test OpenCvSharp on CentOS7
59+
name: Test OpenCvSharp on CentOS 7
6060
runs-on: ubuntu-latest
6161
steps:
62-
- uses: actions/checkout@v3
63-
64-
- name: Download OpenCvSharp Artifact
62+
- name: Download OpenCvSharp Artifacts
6563
env:
6664
GH_TOKEN: ${{ github.token }}
6765
run: |
@@ -72,25 +70,38 @@ jobs:
7270
gh run download -R ${{ github.repository }} $RUN_ID --name opencvsharp-linux-x64-ubuntu-20.04 --dir opencvsharp
7371
ls -lR opencvsharp
7472
75-
- name: Create test.c
76-
run: |
77-
mkdir -p test && cd test && echo '#include <stdio.h>
78-
int core_Mat_sizeof();
79-
int main()
80-
{
81-
int i = core_Mat_sizeof();
82-
printf("sizeof(Mat) = %d\n", i);
83-
return 0;
84-
}' > test.c
85-
cat test.c
86-
87-
- name: Build and Run Test in CentOS7 Docker Container
73+
- name: Test on CentOS 7 via Docker
8874
run: |
89-
docker run --rm \
90-
-v ${{ github.workspace }}/opencvsharp:/opencvsharp \
91-
-v ${{ github.workspace }}/test:/test \
92-
centos:7 \
93-
bash -c "yum install -y gcc && cd /test && gcc test.c -L/opencvsharp/lib -lOpenCvSharpExtern -o test && export LD_LIBRARY_PATH=/opencvsharp/lib && ./test"
75+
docker run --rm -v $PWD:/work -w /work centos:7 /bin/bash -c "
76+
set -eux
77+
78+
# 将 mirrorlist.centos.org 改为 vault.centos.org
79+
sed -i 's|^mirrorlist=|#mirrorlist=|g' /etc/yum.repos.d/CentOS-*.repo
80+
sed -i 's|^#baseurl=|baseurl=|g' /etc/yum.repos.d/CentOS-*.repo
81+
sed -i 's|mirror.centos.org|vault.centos.org|g' /etc/yum.repos.d/CentOS-*.repo
82+
83+
# 清理并重新生成缓存
84+
yum clean all
85+
yum makecache
86+
87+
# 安装 gcc 或其它需要的包
88+
yum install -y gcc
89+
90+
# 准备测试代码
91+
mkdir -p test
92+
echo '#include <stdio.h>
93+
int core_Mat_sizeof();
94+
int main()
95+
{
96+
int i = core_Mat_sizeof();
97+
printf(\"sizeof(Mat) = %d\\n\", i);
98+
return 0;
99+
}' > test/test.c
100+
101+
# 编译和运行测试
102+
gcc test/test.c -L./opencvsharp/lib -lOpenCvSharpExtern -o test/test
103+
LD_LIBRARY_PATH=/work/opencvsharp/lib:\$LD_LIBRARY_PATH ./test/test
104+
"
94105
95106
- name: Upload Artifacts
96107
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)