-
-
Notifications
You must be signed in to change notification settings - Fork 18
112 lines (107 loc) · 3.42 KB
/
build-test-tmpl.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Build, test, validate
on:
workflow_call:
inputs:
runs-on:
required: true
type: string
generate-catalog:
required: true
type: boolean
secrets:
token:
required: true
jobs:
build_and_test:
name: '${{ matrix.os }}: build and test'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ${{ fromJson(inputs.runs-on) }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
ssh-key: ${{ secrets.token }}
- uses: actions/download-artifact@v4
with:
name: catalog
if: inputs.generate-catalog != true
- uses: actions/setup-node@v4
with:
node-version: '20.x'
- run: npm install
- run: npm run generate-catalog
env:
GITHUB_TOKEN: ${{ github.token }}
if: inputs.generate-catalog == true
- run: npm run test
- uses: ./
name: validation test by running get-cmake
- name: CMake version check
run: |
which cmake
cmake --version
CMAKE_LATEST=`cat .latest_cmake_version`
CMAKE_VER="$(cmake --version)"
if ! [[ "$CMAKE_VER" =~ .*"${CMAKE_LATEST}".* ]]; then
echo "ASSERTION FAILED! Instead of '${CMAKE_LATEST}', found: "
echo "$CMAKE_VER"
exit -1
fi
shell: bash
- name: ninja version check
run: |
which ninja
ninja --version
NINJA_LATEST=`cat .latest_ninja_version`
NINJA_VER="$(ninja --version)"
if ! [[ "$NINJA_VER" =~ .*"${NINJA_LATEST}".* ]]; then
echo "ASSERTION FAILED! Instead of '${NINJA_LATEST}', found: "
echo "$NINJA_VER"
exit -1
fi
shell: bash
- uses: actions/upload-artifact@v4
with:
name: catalog
path: |
.latest_ninja_version
.latest_cmake_version
src/releases-catalog.ts
if: inputs.generate-catalog == true
- name: If there is a new CMake version, create a Git commit for the PR
id: git-check
run: |
if ! git diff --exit-code .latest_cmake_version ; then
export CMAKE_NEW_VERSIONS=cmake-v$(cat .latest_cmake_version)
fi
if ! git diff --exit-code .latestrc_cmake_version ; then
export CMAKE_NEW_VERSIONS="${CMAKE_NEW_VERSIONS} cmake-rc-v$(cat .latestrc_cmake_version)"
fi
if [[ -n "${CMAKE_NEW_VERSIONS}" ]]; then
# Get rid of blank space if any
CMAKE_NEW_VERSIONS="${CMAKE_NEW_VERSIONS// /}"
CMAKE_NEW_VERSIONS="${CMAKE_NEW_VERSIONS## }"
echo "CMAKE_NEW_VERSIONS=${CMAKE_NEW_VERSIONS}" >> "$GITHUB_ENV"
git add -u
git commit -m "New CMake version(s): $CMAKE_NEW_VERSIONS"
echo "createpr=true" >> $GITHUB_OUTPUT
else
echo "There is no new version of CMake."
fi
if: ${{ inputs.generate-catalog == true }}
- name: Create the PR for new CMake version(s)
uses: peter-evans/create-pull-request@v7
with:
title: '[Automated] Adding ${{ env.CMAKE_NEW_VERSIONS }}'
body: "Add to catalog new CMake version(s): ${{ env.CMAKE_NEW_VERSIONS }}"
draft: true
branch: automated-pr-cmake-${{ env.CMAKE_NEW_VERSIONS}}
base: main
add-paths: |
dist/*.js
.latest_cmake_version
.latestrc_cmake_version
if: ${{ (steps.git-check.outputs.createpr == 'true') }}