@@ -69,40 +69,46 @@ jobs:
6969 echo "Downloading artifact 'opencvsharp-linux-x64-ubuntu-20.04' from run ${RUN_ID}"
7070 gh run download -R ${{ github.repository }} $RUN_ID --name opencvsharp-linux-x64-ubuntu-20.04 --dir opencvsharp
7171 ls -lR opencvsharp
72-
73- - name : Test on CentOS 7 via Docker
72+
73+ - name : Pull centos:7 Docker image
74+ run : docker pull centos:7
75+
76+ - name : Start CentOS 7 container
77+ run : docker run -d --name centos7_test -v "$PWD":/work -w /work centos:7 tail -f /dev/null
78+
79+ - name : Reconfigure YUM cache
7480 run : |
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- "
105-
81+ docker exec centos7_test bash -c "set -eux; \
82+ sed -i 's|^mirrorlist=|#mirrorlist=|g' /etc/yum.repos.d/CentOS-*.repo && \
83+ sed -i 's|^#baseurl=|baseurl=|g' /etc/yum.repos.d/CentOS-*.repo && \
84+ sed -i 's|mirror .centos.org| vault.centos.org|g' /etc/yum.repos.d/CentOS-*.repo && \
85+ yum clean all && \
86+ yum makecache"
87+
88+ - name : Install gcc dependency
89+ run : docker exec centos7_test bash -c "set -eux; yum install -y gcc"
90+
91+ - name : Prepare test code
92+ run : |
93+ mkdir -p test
94+ echo '#include <stdio.h>
95+ int core_Mat_sizeof();
96+ int main()
97+ {
98+ int i = core_Mat_sizeof();
99+ printf("sizeof(Mat) = %d\\n", i );
100+ return 0;
101+ }' > test/test.c
102+
103+ - name : Compile test code
104+ run : docker exec centos7_test bash -c "set -eux; gcc test/test.c -L./opencvsharp/lib -lOpenCvSharpExtern -o test/test"
105+
106+ - name : Run test
107+ run : docker exec centos7_test bash -c "set -eux; LD_LIBRARY_PATH=/work/opencvsharp/lib:\$LD_LIBRARY_PATH ./test/test"
108+
109+ - name : Cleanup container
110+ run : docker stop centos7_test && docker rm centos7_test
111+
106112 - name : Upload Artifacts
107113 uses : actions/upload-artifact@v4
108114 with :
0 commit comments