Skip to content

Commit bd54dc7

Browse files
committed
ci: unify llvm parameters
1 parent 3500877 commit bd54dc7

File tree

2 files changed

+106
-112
lines changed

2 files changed

+106
-112
lines changed

.github/llvm-matrix.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
const fs = require('fs');
2+
const core = require('@actions/core');
3+
const { exec } = require('child_process');
4+
5+
// Function to check if a file exists on the server
6+
const fileExists = (url) => {
7+
return new Promise((resolve) => {
8+
exec(`curl -s -o /dev/null -w "%{http_code}" -I "${url}"`, (error, stdout) => {
9+
if (error) {
10+
resolve(false);
11+
} else {
12+
resolve(stdout.trim() === '200');
13+
}
14+
});
15+
});
16+
};
17+
18+
// Read the JSON string from the file
19+
const matrixJson = fs.readFileSync('matrix.json', 'utf8');
20+
21+
// Parse the JSON string into an array of objects
22+
const matrixEntries = JSON.parse(matrixJson);
23+
24+
// Create a new array to store unique entries based on llvm-archive-filename
25+
const seenFilenames = new Set();
26+
const uniqueEntries = [];
27+
28+
(async () => {
29+
for (const entry of matrixEntries) {
30+
const filename = entry['llvm-archive-filename'];
31+
if (!seenFilenames.has(filename)) {
32+
seenFilenames.add(filename);
33+
const url = `https://www.mrdocs.com/llvm+clang/${filename}`;
34+
const exists = await fileExists(url);
35+
if (!exists) {
36+
uniqueEntries.push(entry);
37+
}
38+
}
39+
}
40+
41+
// Convert the new array back to a JSON string
42+
const uniqueMatrixJson = JSON.stringify(uniqueEntries);
43+
44+
// Output the filtered JSON string using core.setOutput
45+
core.setOutput('llvm-matrix', uniqueMatrixJson);
46+
47+
// Print matrix to console
48+
console.log(`LLVM Matrix (${uniqueEntries.length} entries):`)
49+
uniqueEntries.forEach(obj => {
50+
console.log(`- ${obj.name}`)
51+
for (const key in obj) {
52+
if (key !== 'name') {
53+
console.log(` ${key}: ${JSON.stringify(obj[key])}`)
54+
}
55+
}
56+
})
57+
})();

.github/workflows/ci.yml

Lines changed: 49 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ jobs:
2323
name: Generate Test Matrix
2424
outputs:
2525
matrix: ${{ steps.cpp-matrix.outputs.matrix }}
26+
llvm-matrix: ${{ steps.llvm-matrix.outputs.llvm-matrix }}
2627
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
2731
- name: Generate Test Matrix
28-
uses: alandefreitas/cpp-actions/[email protected].4
32+
uses: alandefreitas/cpp-actions/[email protected].5
2933
id: cpp-matrix
3034
with:
3135
compilers: |
@@ -45,6 +49,26 @@ jobs:
4549
msvc Optimized-Debug: /Ob1 /O2 /Zi
4650
cxxflags: |
4751
msvc Optimized-Debug: /Ob1 /O2 /Zi
52+
extra-values: |
53+
llvm-hash: e1065370aaacb1b1cb48e77d37d376bf024f4a39
54+
llvm-id: {{ substr llvm-hash 0 7 }}
55+
llvm-build-preset-prefix: {{#if optimized-debug}}debwithopt{{else}}{{lowercase build-type}}{{/if}}
56+
llvm-build-preset-suffix: {{#if (ieq os 'windows') }}win{{else}}unix{{/if}}
57+
llvm-build-preset: {{ llvm-build-preset-prefix }}-{{ llvm-build-preset-suffix }}
58+
llvm-compiler-key: {{ compiler }}-{{ version }}
59+
llvm-cache-key: llvm-libcxx-{{ lowercase os }}-{{ llvm-compiler-key }}-{{ llvm-build-preset-prefix }}-{{ llvm-hash }}
60+
llvm-root: ../third-party/llvm-project/install
61+
llvm-archive-basename: llvm-{{ os }}-{{ llvm-build-preset-prefix }}-{{ llvm-id }}
62+
llvm-archive-extension: {{#if (ieq os 'windows') }}7z{{else}}tar.bz2{{/if}}
63+
llvm-archive-filename: {{ llvm-archive-basename }}.{{ llvm-archive-extension }}
64+
output-file: matrix.json
65+
66+
- name: Generate LLVM Test Matrix
67+
id: llvm-matrix
68+
run: |
69+
set -x
70+
npm install @actions/core
71+
node .github/llvm-matrix.js
4872
4973
build:
5074
needs: cpp-matrix
@@ -70,7 +94,7 @@ jobs:
7094
uses: actions/checkout@v4
7195

7296
- name: Setup CMake
73-
uses: alandefreitas/cpp-actions/[email protected].4
97+
uses: alandefreitas/cpp-actions/[email protected].5
7498
id: setup-cmake
7599
with:
76100
version: ${{ matrix.compiler == 'clang' && '3.26' || '>=3.26' }}
@@ -82,15 +106,15 @@ jobs:
82106
if: ${{ runner.os == 'Windows' }}
83107

84108
- name: Setup C++
85-
uses: alandefreitas/cpp-actions/[email protected].4
109+
uses: alandefreitas/cpp-actions/[email protected].5
86110
id: setup-cpp
87111
with:
88112
compiler: ${{ matrix.compiler }}
89113
version: ${{ matrix.version }}
90114
check-latest: ${{ matrix.compiler == 'clang' }}
91115

92116
- name: Install System Packages
93-
uses: alandefreitas/cpp-actions/[email protected].4
117+
uses: alandefreitas/cpp-actions/[email protected].5
94118
id: package-install
95119
env:
96120
DEBIAN_FRONTEND: 'noninteractive'
@@ -225,50 +249,12 @@ jobs:
225249
fi
226250
echo -E "libxml2-root=$libxml2_root" >> $GITHUB_OUTPUT
227251
228-
- name: LLVM Parameters
229-
id: llvm-parameters
230-
run: |
231-
llvm_hash=e1065370aaacb1b1cb48e77d37d376bf024f4a39
232-
echo -E "llvm-hash=$llvm_hash" >> $GITHUB_OUTPUT
233-
llvm_id=$(echo $llvm_hash | cut -c1-7)
234-
echo -E "llvm-id=$llvm_id" >> $GITHUB_OUTPUT
235-
llvm_build_preset=${{ runner.os == 'Windows' && 'relwithdebinfo-win' || 'release-unix' }}
236-
if [[ ${{ matrix.optimized-debug }} == 'true' ]]; then
237-
llvm_build_preset=debwithopt-
238-
else
239-
if [[ ${{ runner.os }} == 'Windows' ]]; then
240-
llvm_build_preset=relwithdebinfo-
241-
else
242-
llvm_build_preset=release-
243-
fi
244-
fi
245-
if [[ ${{ runner.os }} == 'Windows' ]]; then
246-
llvm_build_preset+=win
247-
else
248-
llvm_build_preset+=unix
249-
fi
250-
echo -E "llvm-build-preset=$llvm_build_preset" >> $GITHUB_OUTPUT
251-
compiler_and_version=${{ matrix.compiler }}-${{ matrix.version }}
252-
workflow_factor=
253-
if [[ ${{ matrix.build-type }} == 'Debug' ]]; then
254-
workflow_factor=-debug
255-
fi
256-
echo -E "llvm-cache-key=llvm-libcxx-${{ runner.os }}-$compiler_and_version$workflow_factor-$llvm_build_preset-$llvm_hash" >> $GITHUB_OUTPUT
257-
cd ..
258-
llvm_root=$(pwd)/third-party/llvm-project/install
259-
if [[ ${{ runner.os }} == 'Windows' ]]; then
260-
llvm_root=$(echo "$llvm_root" | sed 's/\\/\//g')
261-
llvm_root=$(echo $llvm_root | sed 's|^/d/|D:/|')
262-
echo "$llvm_root"
263-
fi
264-
echo -E "llvm-root=$llvm_root" >> $GITHUB_OUTPUT
265-
266252
- name: LLVM Binaries
267253
id: llvm-cache
268254
uses: actions/cache@v4
269255
with:
270-
path: ${{ steps.llvm-parameters.outputs.llvm-root }}
271-
key: ${{ steps.llvm-parameters.outputs.llvm-cache-key }}
256+
path: ${{ matrix.llvm-root }}
257+
key: ${{ matrix.llvm-cache-key }}
272258

273259
- name: Install LLVM
274260
id: llvm-install
@@ -287,7 +273,7 @@ jobs:
287273
git config --global advice.detachedHead false
288274
git init
289275
git remote add origin https://github.com/llvm/llvm-project.git
290-
git fetch --depth 1 origin ${{ steps.llvm-parameters.outputs.llvm-hash }}
276+
git fetch --depth 1 origin ${{ matrix.llvm-hash }}
291277
git checkout FETCH_HEAD
292278
293279
# Copy presets
@@ -298,7 +284,7 @@ jobs:
298284
cd llvm
299285
llvm_root=$(pwd)
300286
cmake --version
301-
cmake -S . -B ./build --preset=${{ steps.llvm-parameters.outputs.llvm-build-preset }} -DCMAKE_CXX_COMPILER=${{ steps.setup-cpp.outputs.cxx }} -DCMAKE_C_COMPILER=${{ steps.setup-cpp.outputs.cc }}
287+
cmake -S . -B ./build --preset=${{ matrix.llvm-build-preset }} -DCMAKE_CXX_COMPILER=${{ steps.setup-cpp.outputs.cxx }} -DCMAKE_C_COMPILER=${{ steps.setup-cpp.outputs.cc }}
302288
if [[ ${{ runner.os }} == 'Linux' ]]; then
303289
cmake --build ./build --target help
304290
fi
@@ -349,7 +335,7 @@ jobs:
349335
node-version: '18'
350336

351337
- name: CMake Workflow
352-
uses: alandefreitas/cpp-actions/[email protected].4
338+
uses: alandefreitas/cpp-actions/[email protected].5
353339
with:
354340
cmake-version: ${{ matrix.compiler == 'clang' && '3.26' || '>=3.26' }}
355341
cxxstd: ${{ matrix.cxxstd }}
@@ -363,8 +349,8 @@ jobs:
363349
install-prefix: .local
364350
extra-args: |
365351
-D MRDOCS_BUILD_DOCS=OFF
366-
-D LLVM_ROOT=${{ steps.llvm-parameters.outputs.llvm-root }}
367-
-D Clang_ROOT=${{ steps.llvm-parameters.outputs.llvm-root }}
352+
-D LLVM_ROOT=${{ matrix.llvm-root }}
353+
-D Clang_ROOT=${{ matrix.llvm-root }}
368354
-D duktape_ROOT=${{ steps.duktape-install.outputs.duktape-root }}
369355
-D Duktape_ROOT=${{ steps.duktape-install.outputs.duktape-root }}
370356
-D fmt_ROOT=${{ steps.fmt-install.outputs.fmt-root }}
@@ -387,7 +373,7 @@ jobs:
387373
retention-days: 1
388374

389375
- name: FlameGraph
390-
uses: alandefreitas/cpp-actions/[email protected].4
376+
uses: alandefreitas/cpp-actions/[email protected].5
391377
if: matrix.time-trace
392378
with:
393379
build-dir: build
@@ -415,7 +401,7 @@ jobs:
415401
contents: write
416402
steps:
417403
- name: Install packages
418-
uses: alandefreitas/cpp-actions/[email protected].4
404+
uses: alandefreitas/cpp-actions/[email protected].5
419405
id: package-install
420406
with:
421407
apt-get: build-essential asciidoctor cmake bzip2 git
@@ -448,7 +434,7 @@ jobs:
448434
echo -e "MRDOCS_ROOT=$MRDOCS_ROOT" >> $GITHUB_ENV
449435
450436
- name: Clone Boost.URL
451-
uses: alandefreitas/cpp-actions/[email protected].4
437+
uses: alandefreitas/cpp-actions/[email protected].5
452438
id: boost-url-clone
453439
with:
454440
branch: develop
@@ -638,7 +624,7 @@ jobs:
638624
git config --global --add safe.directory "$(pwd)"
639625
640626
- name: Create changelog
641-
uses: alandefreitas/cpp-actions/[email protected].4
627+
uses: alandefreitas/cpp-actions/[email protected].5
642628
with:
643629
output-path: CHANGELOG.md
644630
thank-non-regular: ${{ startsWith(github.ref, 'refs/tags/') }}
@@ -678,7 +664,7 @@ jobs:
678664
strategy:
679665
fail-fast: false
680666
matrix:
681-
include: ${{ fromJSON(needs.cpp-matrix.outputs.matrix) }}
667+
include: ${{ fromJSON(needs.cpp-matrix.outputs.llvm-matrix) }}
682668

683669
defaults:
684670
run:
@@ -693,66 +679,17 @@ jobs:
693679

694680
steps:
695681
- name: Install packages
696-
uses: alandefreitas/cpp-actions/[email protected].4
682+
uses: alandefreitas/cpp-actions/[email protected].5
697683
id: package-install
698684
with:
699685
apt-get: build-essential asciidoctor cmake bzip2 git curl
700686

701-
- name: LLVM Parameters
702-
id: llvm-parameters
703-
run: |
704-
llvm_hash=e1065370aaacb1b1cb48e77d37d376bf024f4a39
705-
echo -E "llvm-hash=$llvm_hash" >> $GITHUB_OUTPUT
706-
llvm_id=$(echo $llvm_hash | cut -c1-7)
707-
echo -E "llvm-id=$llvm_id" >> $GITHUB_OUTPUT
708-
llvm_build_preset=${{ runner.os == 'Windows' && 'relwithdebinfo-win' || 'release-unix' }}
709-
if [[ ${{ matrix.optimized-debug }} == 'true' ]]; then
710-
llvm_build_preset=debwithopt-
711-
else
712-
if [[ ${{ runner.os }} == 'Windows' ]]; then
713-
llvm_build_preset=relwithdebinfo-
714-
else
715-
llvm_build_preset=release-
716-
fi
717-
fi
718-
if [[ ${{ runner.os }} == 'Windows' ]]; then
719-
llvm_build_preset+=win
720-
else
721-
llvm_build_preset+=unix
722-
fi
723-
echo -E "llvm-build-preset=$llvm_build_preset" >> $GITHUB_OUTPUT
724-
compiler_and_version=${{ matrix.compiler }}-${{ matrix.version }}
725-
workflow_factor=
726-
if [[ ${{ matrix.build-type }} == 'Debug' ]]; then
727-
workflow_factor=-debug
728-
fi
729-
echo -E "llvm-cache-key=llvm-libcxx-${{ runner.os }}-$compiler_and_version$workflow_factor-$llvm_build_preset-$llvm_hash" >> $GITHUB_OUTPUT
730-
llvm_archive_basename=llvm-${{ runner.os }}-$llvm_id
731-
echo -E "llvm-archive-basename=$llvm_archive_basename" >> $GITHUB_OUTPUT
732-
if [[ ${{ runner.os }} == 'Windows' ]]; then
733-
llvm_archive_extension=7z
734-
else
735-
llvm_archive_extension=tar.bz2
736-
fi
737-
echo -E "llvm-archive-extension=$llvm_archive_extension" >> $GITHUB_OUTPUT
738-
llvm_archive_filename=$llvm_archive_basename.$llvm_archive_extension
739-
echo -E "llvm-archive-filename=$llvm_archive_filename" >> $GITHUB_OUTPUT
740-
741-
cd ..
742-
llvm_root=$(pwd)/third-party/llvm-project/install
743-
if [[ ${{ runner.os }} == 'Windows' ]]; then
744-
llvm_root=$(echo "$llvm_root" | sed 's/\\/\//g')
745-
llvm_root=$(echo $llvm_root | sed 's|^/d/|D:/|')
746-
echo "$llvm_root"
747-
fi
748-
echo -E "llvm-root=$llvm_root" >> $GITHUB_OUTPUT
749-
750687
- name: Check website releases
751688
id: website-releases
752689
run: |
753690
set -x
754-
archive_url="https://mrdocs.com/llvm+clang/${{ steps.llvm-parameters.outputs.llvm-archive-filename }}"
755-
http_status=$(curl -s -o /dev/null -w "%{http_code}" "$archive_url")
691+
archive_url="https://mrdocs.com/llvm+clang/${{ matrix.llvm-archive-filename }}"
692+
http_status=$(curl -s -o /dev/null -w "%{http_code}" -I "$archive_url")
756693
if [ "$http_status" -eq 200 ]; then
757694
exists="true"
758695
else
@@ -765,8 +702,8 @@ jobs:
765702
if: steps.website-releases.outputs.exists != 'true'
766703
uses: actions/cache@v4
767704
with:
768-
path: ${{ steps.llvm-parameters.outputs.llvm-root }}
769-
key: ${{ steps.llvm-parameters.outputs.llvm-cache-key }}
705+
path: ${{ matrix.llvm-root }}
706+
key: ${{ matrix.llvm-cache-key }}
770707

771708
- name: Compress LLVM
772709
id: llvm-upload
@@ -781,9 +718,9 @@ jobs:
781718
782719
# Use 7z on windows
783720
if [[ ${{ runner.os }} == 'Windows' ]]; then
784-
7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on ${{ steps.llvm-parameters.outputs.llvm-archive-filename }} install
721+
7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on ${{ matrix.llvm-archive-filename }} install
785722
else
786-
tar -cjf ${{ steps.llvm-parameters.outputs.llvm-archive-filename }} -C install .
723+
tar -cjf ${{ matrix.llvm-archive-filename }} -C install .
787724
fi
788725
789726
- name: Publish LLVM on website
@@ -803,6 +740,6 @@ jobs:
803740
804741
# Remove previous demos associated with this tag
805742
llvm_dir="/var/www/mrdox.com/llvm+clang"
806-
chmod 755 -R ${{ steps.llvm-parameters.outputs.llvm-archive-filename }}
807-
scp -o StrictHostKeyChecking=no $(pwd)/${{ steps.llvm-parameters.outputs.llvm-archive-filename }} [email protected]:$llvm_dir/
743+
chmod 755 -R ${{ matrix.llvm-archive-filename }}
744+
scp -o StrictHostKeyChecking=no $(pwd)/${{ matrix.llvm-archive-filename }} [email protected]:$llvm_dir/
808745

0 commit comments

Comments
 (0)