Skip to content

Commit 6597146

Browse files
committed
Fix GHA build test
1 parent 72ff6b1 commit 6597146

File tree

1 file changed

+52
-68
lines changed

1 file changed

+52
-68
lines changed

.github/workflows/cmake.yml

Lines changed: 52 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ env:
1818

1919
jobs:
2020
build:
21-
# The CMake configure and build commands are platform agnostic and should work equally
22-
# well on Windows or Mac. You can convert this to a matrix build if you need
23-
# cross-platform coverage.
24-
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
2521
runs-on: ubuntu-latest
2622
container: ubuntu:latest
2723

@@ -91,91 +87,79 @@ jobs:
9187
cmake .
9288
cmake --build .
9389
94-
build_2_8:
95-
# The CMake configure and build commands are platform agnostic and should work equally
96-
# well on Windows or Mac. You can convert this to a matrix build if you need
97-
# cross-platform coverage.
98-
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
90+
build_linux:
91+
strategy:
92+
fail-fast: false
93+
matrix:
94+
cmake:
95+
- 2.8.12.2
96+
- 3.10.3
97+
- latest
9998
runs-on: ubuntu-latest
100-
container: ubuntu:14.04
99+
container: ubuntu:latest
101100

102101
steps:
103102
- uses: actions/checkout@v2
104-
105-
- name: Install dependencies
106-
run: apt update && apt install -y cmake gcc libgl1-mesa-dev libx11-dev libxext-dev
107-
108-
- name: Configure CMake
109-
shell: bash
110-
run: cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE
111-
112-
- name: Build test
113-
shell: bash
114-
run: cmake --build .
115-
116-
- name: Check alias
117-
shell: bash
118-
run: test -e lib/libGLEW.a
119103

120-
build_3_10:
121-
# The CMake configure and build commands are platform agnostic and should work equally
122-
# well on Windows or Mac. You can convert this to a matrix build if you need
123-
# cross-platform coverage.
124-
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
125-
runs-on: ubuntu-latest
126-
container: ubuntu:18.04
104+
- name: Restore cached cmake
105+
uses: actions/cache/restore@v4
106+
[<0;97;19M with:
107+
path: /opt/cmake
108+
key: cmake-${{ matrix.cmake }}
127109

128-
steps:
129-
- uses: actions/checkout@v2
130-
131110
- name: Install dependencies
132-
run: apt update && apt install -y cmake gcc libgl1-mesa-dev libx11-dev libxext-dev
111+
shell: bash
112+
run: |
113+
cmake=${{ matrix.cmake }}
114+
apt update
115+
apt install -y gcc make libgl1-mesa-dev libx11-dev libxext-dev
116+
if [ -x /opt/cmake/bin/cmake ]; then
117+
echo "Found cached cmake"
118+
if [ -s "$(/opt/cmake/bin/cmake --version | grep ${cmake})" ]; then
119+
exit 0
120+
fi
121+
echo "CMake version is mismatched"
122+
rm -rf /opt/cmake
123+
fi
124+
125+
apt install -y g++ wget
126+
if [ "${cmake}" == "latest" ]; then
127+
apt install -y git
128+
cmake=$(git ls-remote --tags https://gitlab.kitware.com/cmake/cmake | cut -f 2 | sed -E "s/^refs\/tags\/v//" | tr -d "^{}" | sort -t '.' -k 1,1n -k 2,2n -k 3,3n | tail -n 1 | tr -d "\n")
129+
echo "Latest version: ${cmake}"
130+
fi
131+
short_version=$(echo "${cmake}" | sed -E "s/^([0-9]+\\.[0-9]+)\\..+$/\\1/" | tr -d "\n")
132+
wget https://cmake.org/files/v${short_version}/cmake-${cmake}.tar.gz
133+
tar -xf cmake-${cmake}.tar.gz
134+
cd cmake-${cmake}
135+
./configure --prefix=/opt/cmake
136+
make -j $(nproc) install
137+
138+
- name: Save cmake
139+
uses: actions/cache/save@v4
140+
with:
141+
path: /opt/cmake
142+
key: cmake-${{ matrix.cmake }}
133143

134144
- name: Configure CMake
135145
shell: bash
136-
run: cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE
146+
run: /opt/cmake/bin/cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE
137147

138148
- name: Build test
139149
shell: bash
140-
run: cmake --build .
141-
142-
- name: Check alias
143-
shell: bash
144-
run: test -e lib/libGLEW.a
145-
146-
build_latest:
147-
runs-on: ubuntu-latest
148-
container: ubuntu:latest
150+
run: /opt/cmake/bin/cmake --build .
149151

150-
steps:
151-
- uses: actions/checkout@v2
152-
153-
- name: Install dependencies
154-
run: apt update && apt install -y python3 python3-pip gcc libgl1-mesa-dev libx11-dev libxext-dev && pip install cmake
155-
156-
- name: Configure CMake
157-
shell: bash
158-
run: cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE
159-
160-
- name: Build test
161-
shell: bash
162-
run: cmake --build .
163-
164152
- name: Check alias
165153
shell: bash
166154
run: test -e lib/libGLEW.a
167155

168156
build_mingw:
169-
# The CMake configure and build commands are platform agnostic and should work equally
170-
# well on Windows or Mac. You can convert this to a matrix build if you need
171-
# cross-platform coverage.
172-
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
173157
runs-on: ubuntu-latest
174-
container: ubuntu:18.04
158+
container: ubuntu:latest
175159

176160
steps:
177161
- uses: actions/checkout@v2
178-
162+
179163
- name: Install dependencies
180164
run: apt update && apt install -y cmake g++-mingw-w64-x86-64 make libgl1-mesa-dev libx11-dev libxext-dev
181165

@@ -193,7 +177,7 @@ jobs:
193177

194178
steps:
195179
- uses: actions/checkout@v2
196-
180+
197181
- name: Configure CMake
198182
shell: bash
199183
run: cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE
@@ -207,7 +191,7 @@ jobs:
207191

208192
steps:
209193
- uses: actions/checkout@v2
210-
194+
211195
- name: Configure CMake
212196
shell: bash
213197
run: cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE

0 commit comments

Comments
 (0)