Skip to content

Commit d9e70e3

Browse files
committed
add catalog of releases for cmake and ninja
1 parent fc1be1d commit d9e70e3

20 files changed

Lines changed: 4062 additions & 595 deletions

.github/workflows/build-test.yml

Lines changed: 93 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ on:
77
- cron: '0 1 * * SUN'
88
workflow_dispatch:
99

10-
env:
11-
CMAKE_LATEST: 3.24.3
12-
NINJA_LATEST: 1.11.1
13-
1410
jobs:
1511
build_and_test:
1612
name: '${{ matrix.os }}: build and test'
@@ -29,17 +25,21 @@ jobs:
2925
node-version: '16.x'
3026
- run: |
3127
npm install
28+
npm run generate-catalog
3229
npm run test
30+
env:
31+
GITHUB_TOKEN: ${{ github.token }}
3332
name: build and test
3433
- uses: ./
3534
name: validation test by running get-cmake
3635
- name: CMake version check
3736
run: |
3837
which cmake
3938
cmake --version
39+
CMAKE_LATEST=`cat .latest_cmake_version`
4040
CMAKE_VER="$(cmake --version)"
4141
if ! [[ "$CMAKE_VER" =~ .*"${CMAKE_LATEST}".* ]]; then
42-
echo "ASSERTION FAILED! Instead of ${CMAKE_LATEST}, found: "
42+
echo "ASSERTION FAILED! Instead of '${CMAKE_LATEST}', found: "
4343
echo "$CMAKE_VER"
4444
exit -1
4545
fi
@@ -48,34 +48,51 @@ jobs:
4848
run: |
4949
which ninja
5050
ninja --version
51+
NINJA_LATEST=`cat .latest_ninja_version`
5152
NINJA_VER="$(ninja --version)"
5253
if ! [[ "$NINJA_VER" =~ .*"${NINJA_LATEST}".* ]]; then
53-
echo "ASSERTION FAILED! Instead of ${NINJA_LATEST}, found: "
54+
echo "ASSERTION FAILED! Instead of '${NINJA_LATEST}', found: "
5455
echo "$NINJA_VER"
5556
exit -1
5657
fi
5758
shell: bash
59+
- uses: actions/upload-artifact@v3
60+
with:
61+
name: catalog
62+
path: |
63+
.latest_ninja_version
64+
.latest_cmake_version
65+
src/releases-catalog.ts
5866
5967
test_user_provided_version:
6068
name: '${{ matrix.os }}: functional test (${{ matrix.cmake }}, ${{ matrix.ninja }})'
6169
runs-on: ${{ matrix.os }}
70+
needs: build_and_test
6271
strategy:
6372
fail-fast: false
6473
matrix:
6574
os: [ubuntu-latest, macos-latest, windows-latest]
66-
cmake: ["", "3.22.6", "3.5.2", "3.25.0-rc4", "3.25.0-rc3"]
67-
ninja: ["", "1.11.0"]
75+
cmake: ["", "3.22.6", "3.25.0-rc4", "latest", "latestrc", "~3.25.0"]
76+
ninja: ["", "1.11.0", "latest", "~1.11.1"]
6877

6978
steps:
7079
- uses: actions/checkout@v3
7180
with:
7281
submodules: true
82+
token: ${{ github.token }}
83+
- uses: actions/download-artifact@v3
84+
with:
85+
name: catalog
7386
- uses: actions/setup-node@v3
7487
with:
7588
node-version: '16.x'
76-
89+
- run: |
90+
npm install
91+
npm run test
92+
env:
93+
GITHUB_TOKEN: ${{ github.token }}
7794
- uses: ./
78-
name: validation test by running get-cmake
95+
name: validation test by running get-cmake with specific input
7996
with:
8097
cmakeVersion: ${{ matrix.cmake }}
8198
ninjaVersion: ${{ matrix.ninja }}
@@ -84,10 +101,33 @@ jobs:
84101
which cmake
85102
cmake --version
86103
CMAKE_VER="$(cmake --version)"
87-
EXPECTED_CMAKE_VER="${{ matrix.cmake }}"
88-
[ -z "${EXPECTED_CMAKE_VER}" ] && EXPECTED_CMAKE_VER="${{ env.CMAKE_LATEST}}"
89-
if ! [[ "$CMAKE_VER" =~ .*"${EXPECTED_CMAKE_VER}".* ]]; then
90-
echo "ASSERTION FAILED! Instead of ${EXPECTED_CMAKE_VER}, found: "
104+
CMAKE_REQUESTED_VER="${{ matrix.cmake }}"
105+
case ${CMAKE_REQUESTED_VER} in
106+
'latest')
107+
EXPECTED_CMAKE_VER=`cat .latest_cmake_version`
108+
;;
109+
'latestrc')
110+
EXPECTED_CMAKE_VER=`cat .latestrc_cmake_version`
111+
;;
112+
\~*)
113+
# Drop initial ~
114+
CMAKE_REQUESTED_VER=${CMAKE_REQUESTED_VER:1}
115+
# Drop ".patch"
116+
EXPECTED_CMAKE_VER="${CMAKE_REQUESTED_VER%.*}"
117+
;;
118+
\^*)
119+
# Drop initial ^
120+
CMAKE_REQUESTED_VER=${CMAKE_REQUESTED_VER:1}
121+
# Drop ".minor.patch"
122+
EXPECTED_CMAKE_VER="${CMAKE_REQUESTED_VER%.*.*}"
123+
;;
124+
*)
125+
# Expect the required version as is.
126+
EXPECTED_CMAKE_VER="${CMAKE_REQUESTED_VER}"
127+
;;
128+
esac
129+
if ! [[ "$CMAKE_VER" =~ .*${EXPECTED_CMAKE_VER}.* ]]; then
130+
echo "ASSERTION FAILED! Instead of '${EXPECTED_CMAKE_VER}', found: "
91131
echo "$CMAKE_VER"
92132
exit -1
93133
fi
@@ -97,12 +137,46 @@ jobs:
97137
which ninja
98138
ninja --version
99139
NINJA_VER="$(ninja --version)"
100-
EXPECTED_NINJA_VER="${{ matrix.ninja }}"
101-
[ -z "$EXPECTED_NINJA_VER" ] && EXPECTED_NINJA_VER="${{ env.NINJA_LATEST}}"
102-
if ! [[ "$NINJA_VER" =~ .*"${{ matrix.ninja }}".* ]]; then
103-
echo "ASSERTION FAILED! Instead of $EXPECTED_NINJA_VER, found: "
140+
NINJA_REQUESTED_VER="${{ matrix.ninja }}"
141+
case ${NINJA_REQUESTED_VER} in
142+
'latest')
143+
EXPECTED_NINJA_VER=`cat .latest_ninja_version`
144+
;;
145+
\~*)
146+
# Drop initial ~
147+
NINJA_REQUESTED_VER=${NINJA_REQUESTED_VER:1}
148+
# Drop ".patch"
149+
EXPECTED_NINJA_VER="${NINJA_REQUESTED_VER%.*}"
150+
;;
151+
\^*)
152+
# Drop initial ~
153+
NINJA_REQUESTED_VER=${NINJA_REQUESTED_VER:1}
154+
# Drop ".minor.patch"
155+
EXPECTED_NINJA_VER="${NINJA_REQUESTED_VER%.*.*}"
156+
;;
157+
*)
158+
EXPECTED_NINJA_VER="${NINJA_REQUESTED_VER}"
159+
;;
160+
esac
161+
if ! [[ "$NINJA_VER" =~ .*${EXPECTED_NINJA_VER}.* ]]; then
162+
echo "ASSERTION FAILED! Instead of '${EXPECTED_NINJA_VER}', found: "
104163
echo "$NINJA_VER"
105164
exit -1
106165
fi
107166
shell: bash
108-
167+
- name: Check for Git modified files
168+
if: ${{ false }}
169+
id: git-check
170+
run: echo ::set-output name=modified::$(if [ -n "$(git status --porcelain)" ]; then echo "true"; else echo "false"; fi)
171+
- name: Commit the catalog of CMake and Ninja releases
172+
#steps.git-check.outputs.modified == 'true'
173+
if: ${{ false }}
174+
run: |
175+
git config --global user.name 'Luca'
176+
git config --global user.email '681992+lukka@users.noreply.github.com'
177+
git remote set-url origin https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}
178+
git add -A
179+
git add -f ./src/releases-catalog.ts .latest_cmake_version .latest_ninja_version
180+
git status
181+
git commit -m "Automated commit for updating the releases catalog of CMake and Ninja"
182+
git push

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ __tests__/b
1515
coverage
1616
.DS_Store
1717
.env
18+
!/.latest_cmake_version
19+
!/.latest_ninja_version

.latest_cmake_version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.25.1

.latest_ninja_version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.11.1

.latestrc_cmake_version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.25.0-rc4

README.md

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
- [The **get-cmake** action installs as fast as possible your desired versions of CMake and Ninja](#the-get-cmake-action-installs-as-fast-as-possible-your-desired-versions-of-cmake-and-ninja)
66
- [Quickstart](#quickstart)
7+
- [If you want to use **latest stable** you can use this one-liner:](#if-you-want-to-use--latest-stable-you-can-use-this-one-liner)
8+
- [If you want to **pin** the workflow to **specific range of versions** of CMake and Ninja:](#if-you-want-to-pin-the-workflow-to-specific-range-of-versions-of-cmake-and-ninja)
79
- [Action reference: all input/output parameters](#action-reference-all-inputoutput-parameters)
810
- [Who is using `get-cmake`](#who-is-using-get-cmake)
911
- [Developers information](#developers-information)
@@ -18,7 +20,7 @@
1820
<br>
1921

2022
# [The **get-cmake** action installs as fast as possible your desired versions of CMake and Ninja](https://github.com/marketplace/actions/get-cmake)
21-
The action restores from the GitHub cloud based cache, or downloads and caches, both CMake and Ninja. You can select your desired version of each, or by default CMake **v3.24.3** and Ninja **v1.11.1** are installed.
23+
The action restores from the GitHub cloud based cache, or downloads and caches, both CMake and Ninja. You can select your desired version using [semantic versioning ranges](https://docs.npmjs.com/about-semantic-versioning), and also use `install` or `installrc` special versions to install the latest stable or release candidate.
2224
Works for Linux/macOS/Windows.
2325

2426
Steps of `get-cmake`:
@@ -31,29 +33,43 @@ Steps of `get-cmake`:
3133
<br>
3234

3335
## Quickstart
36+
### If you want to use **latest stable** you can use this one-liner:
3437
```yaml
35-
# - uses: actions/cache@v1 <-----= YOU DO NOT NEED THIS
36-
# key: <key> <-----= YOU DO NOT NEED THIS
37-
# path: <path> <-----= YOU DO NOT NEED THIS
38-
39-
- name: Get latest CMake and Ninja
40-
# Using 'latest' branch, the most recent CMake and ninja are installed.
41-
uses: lukka/get-cmake@latest # <--= THIS IS THE ONE LINER YOU NEED
42-
38+
# Option 1: using 'latest' branch, the most recent CMake and ninja are installed.
39+
- uses: lukka/get-cmake@latest # <--= Just this one-liner suffices.
40+
```
41+
or there is another option:
42+
```yaml
43+
# Option 2: specify 'latest' or 'latestrc' in the input version arguments:
44+
- name: Get latest CMake and Ninja
45+
uses: lukka/get-cmake@latest
46+
with:
47+
cmakeVersion: latestrc # <--= optional, use the latest release candidate (notice the 'rc' suffix).
48+
ninjaVersion: latest # <--= optional, use the latest release (non candidate).
49+
```
4350
44-
# If you need to _pin_ your workflow to specific CMake/Ninja versions you have TWO options:
51+
<br>
4552
46-
# Option 1: specify in a input parameter the desired version (using multiple lines).
47-
- name: Get specific version CMake, v3.24.3, and Ninja v1.11.1
48-
uses: lukka/get-cmake@latest
53+
### If you want to **pin** the workflow to **specific range of versions** of CMake and Ninja:
54+
```yaml
55+
# Option 1: specify in a input parameter the desired version using ranges.
56+
- uses: lukka/get-cmake@latest
4957
with:
50-
cmakeVersion: 3.24.3 # <--= optional, overrides the _latest_ version of CMake
51-
ninjaVersion: 1.11.1 # <--= optional, overrides the _latest_ version of Ninja
52-
58+
cmakeVersion: "~3.25.0" # <--= optional, use most recent 3.25.x version
59+
ninjaVersion: "^1.11.1" # <--= optional, use most recent 1.x version
60+
61+
# or using a specific version (no range)
62+
- uses: lukka/get-cmake@latest
63+
with:
64+
cmakeVersion: 3.25.1 # <--= optional, stick to exactly 3.25.1 version
65+
ninjaVersion: 1.11.1 # <--= optional, stick to exactly 1.11.1 version
66+
```
67+
or there is another option:
68+
```yaml
5369
# Option 2: or you can use the Git 'tag' to select the version, and you can have a one-liner statement,
54-
# but note that you can only use one of the existing tags, create a PR to add more tags!
55-
- name: Get specific version CMake, v3.24.3
56-
uses: lukka/get-cmake@v3.24.3 # <- THIS IS THE ONE LINER YOU NEED
70+
# but note that you can only use one of the existing tags, create a PR to add the tag you need!
71+
- name: Get specific version CMake, v3.25.1
72+
uses: lukka/get-cmake@v3.25.1 # <- this one-liner is all you need.
5773
```
5874
<br>
5975
@@ -88,7 +104,7 @@ Launch `lint` by:
88104
## Generate the catalog of CMake releases
89105
To generate the catalog of CMake releases, run a special test with this command:
90106

91-
> npx jest --config=./jest.config-generate-catalog.js
107+
> npm run generate-catalog
92108

93109
Then embed the new catalog by packaging the action.
94110

__tests__/action_failed.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import * as toolcache from '@actions/tool-cache';
88
import * as core from '@actions/core';
99
import * as getcmake from '../src/get-cmake';
1010

11-
jest.setTimeout(60 * 1000);
11+
// 10 minutes
12+
jest.setTimeout(10 * 60 * 1000)
1213

1314
jest.spyOn(cache, 'saveCache').mockImplementation(() =>
1415
Promise.resolve(0)

__tests__/action_succeeded.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import * as toolcache from '@actions/tool-cache';
99
import * as core from '@actions/core';
1010
import { InputOptions } from '@actions/core';
1111

12-
jest.setTimeout(5 * 60 * 1000)
12+
// 10 minutes
13+
jest.setTimeout(10 * 60 * 1000)
1314

1415
jest.spyOn(cache, 'saveCache').mockImplementation(() =>
1516
Promise.resolve(0)
@@ -39,7 +40,7 @@ test('testing get-cmake action success with default cmake', async () => {
3940
});
4041

4142
test('testing get-cmake action success with specific cmake versions', async () => {
42-
for (var version of ["3.19.8", "3.18.3", "3.16.1", "3.5.2", "3.3.0", "3.1.2", "3.25.0-rc4", "3.25.0-rc3"]) {
43+
for (var version of ["latest", "latestrc", "~3.24", "3.x", "3.20.x", "^3.22", "3.19.8", "3.18.3", "3.16.1", "3.5.2", "3.3.0", "3.1.2", "3.25.0-rc4", "3.25.0-rc3"]) {
4344
process.env.RUNNER_TEMP = os.tmpdir();
4445
process.env["CUSTOM_CMAKE_VERSION"] = version;
4546
await getcmake.main();

__tests__/cachehit.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import * as os from 'os';
77
import { ToolsGetter } from '../src/get-cmake';
88
import * as cache from '@actions/cache';
99

10-
jest.setTimeout(60 * 1000)
10+
// 10 minutes
11+
jest.setTimeout(10 * 60 * 1000)
1112

1213
const cacheSaveCache = jest.spyOn(cache, 'saveCache').mockImplementation(() =>
1314
Promise.resolve(0)

__tests__/cachemiss.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { ToolsGetter } from '../src/get-cmake';
88
import * as cache from '@actions/cache';
99
import * as core from '@actions/core';
1010

11-
jest.setTimeout(60 * 1000)
11+
// 10 minutes
12+
jest.setTimeout(10 * 60 * 1000)
1213

1314
var coreSetFailed = jest.spyOn(core, 'setFailed');
1415

0 commit comments

Comments
 (0)