Skip to content

Commit 11dfa47

Browse files
authored
update build pipeline (#56)
1 parent 2200605 commit 11dfa47

File tree

1 file changed

+96
-32
lines changed

1 file changed

+96
-32
lines changed

.github/workflows/build.yml

Lines changed: 96 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ jobs:
5656
extra-cmake-args: '-DCLANG_ANALYZER_ENABLE_Z3_SOLVER=OFF'
5757
- os: linux
5858
runner: ubuntu-22.04
59-
os-cmake-args: '-DLLVM_BUILD_STATIC=ON -DCMAKE_CXX_FLAGS="-s -flto" ${LINUX_CMAKE_ARGS}'
59+
os-cmake-args: '-DLLVM_BUILD_STATIC=ON -DCMAKE_CXX_FLAGS="-s -flto" ${POSIX_CMAKE_ARGS} ${LINUX_CMAKE_ARGS}'
6060
build-args: '-j$(nproc)'
6161
bindir: '/build/bin'
6262
dotexe: ''
6363
shacmd: 'sha512sum'
6464
- os: macosx
65-
runner: macos-13 # macos intel
66-
os-cmake-args: '-DCMAKE_CXX_FLAGS="-static-libgcc -static-libstdc++ -flto -ffunction-sections -fdata-sections" -DCMAKE_OSX_DEPLOYMENT_TARGET=11 ${MACOS_CMAKE_ARGS}'
65+
runner: macos-13
66+
os-cmake-args: '-DCMAKE_CXX_FLAGS="-static-libgcc -static-libstdc++ -flto" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 ${POSIX_CMAKE_ARGS} ${MACOS_CMAKE_ARGS}'
6767
build-args: '-j$(sysctl -n hw.ncpu)'
6868
bindir: '/build/bin'
6969
dotexe: ''
@@ -78,18 +78,11 @@ jobs:
7878
extra-tar-args: '--exclude=${RELEASE}/clang/test/Driver/Inputs/* --exclude=${RELEASE}/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/* --exclude=${RELEASE}/libclc/amdgcn-mesa3d'
7979
extra-tar-args-cfe: '--exclude=cfe-${version}.src/test/Driver/Inputs/*'
8080
runs-on: ${{ matrix.runner }}
81-
if: ${{ github.actor != 'dependabot[bot]' }}
8281
env:
8382
COMMON_CMAKE_ARGS: '-DBUILD_SHARED_LIBS=OFF -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra"'
84-
MACOS_CMAKE_ARGS: >
85-
-DCMAKE_BUILD_TYPE=MinSizeRel
86-
-DCMAKE_CXX_COMPILER=g++-14
87-
-DCMAKE_C_COMPILER=gcc-14
88-
-DZSTD_STATIC_LINKING_ONLY=1
89-
-DLLVM_ENABLE_ASSERTIONS=OFF
90-
-DZLIB_USE_STATIC_LIBS=ON
91-
-DLLVM_TARGETS_TO_BUILD=X86
92-
LINUX_CMAKE_ARGS: '-DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_C_COMPILER=gcc-10'
83+
LINUX_CMAKE_ARGS: '-DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_C_COMPILER=gcc-10'
84+
MACOS_CMAKE_ARGS: '-DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_C_COMPILER=gcc-14'
85+
POSIX_CMAKE_ARGS: '-DCMAKE_BUILD_TYPE=MinSizeRel'
9386
RELEASE: '${{ matrix.release }}'
9487
suffix: '${{ matrix.clang-version }}_${{ matrix.os }}-amd64'
9588
steps:
@@ -141,34 +134,37 @@ jobs:
141134
- name: Patch cmake implicit link libraries on macOS
142135
if: ${{ matrix.os == 'macosx' }}
143136
shell: bash
144-
run: |
145-
BREW_PREFIX=$(brew --prefix)
146-
FILES=$(find "$BREW_PREFIX" -name CMakeParseImplicitLinkInfo.cmake)
147-
for file in $FILES; do
148-
echo "Patching $file"
149-
sed -i.backup 's/gcc_eh.*|/gcc_eh.*|gcc_ext.*|/g' "$file"
150-
done
151-
- name: CMake
137+
run: sed -i.backup 's/gcc_eh.\*|/gcc_eh.*|gcc_ext.*|/g' $(find /usr/local/Cellar -name CMakeParseImplicitLinkInfo.cmake)
138+
- name: Cmake
152139
run: cmake -S ${{ matrix.release }}/llvm -B ${{ matrix.release }}/build ${{ env.COMMON_CMAKE_ARGS }} ${{ matrix.os-cmake-args }} ${{ matrix.extra-cmake-args }}
153140
- name: Build
154141
run: cmake --build ${{ matrix.release }}/build ${{ matrix.build-args }} --target clang-format clang-query clang-tidy clang-apply-replacements
155142
- name: Print dependencies
156143
if: ${{ matrix.os == 'macosx' }}
157144
run: otool -L ${{ matrix.release }}/build/bin/clang-format
158-
- name: Rename output binary and test
145+
- name: Smoke test clang-tools (macos, linux)
146+
if: ${{ matrix.os == 'macosx' || matrix.os == 'linux' }}
147+
run: |
148+
cd ${{ matrix.release }}/build/bin
149+
./clang-format --version
150+
./clang-query --version
151+
./clang-tidy --version
152+
./clang-apply-replacements --version
153+
- name: Smoke test clang-tools (windows)
154+
if: ${{ matrix.os == 'windows' }}
155+
run: |
156+
cd ${{ matrix.release }}${{ matrix.bindir }}
157+
clang-format${{ matrix.dotexe }} --version
158+
clang-query${{ matrix.dotexe }} --version
159+
clang-tidy${{ matrix.dotexe }} --version
160+
clang-apply-replacements${{ matrix.dotexe }} --version
161+
- name: Rename output binary
159162
run: |
160163
cd ${{ matrix.release }}${{ matrix.bindir }}
161164
mv clang-format${{ matrix.dotexe }} clang-format-${{ env.suffix }}${{ matrix.dotexe }}
162165
mv clang-query${{ matrix.dotexe }} clang-query-${{ env.suffix }}${{ matrix.dotexe }}
163166
mv clang-tidy${{ matrix.dotexe }} clang-tidy-${{ env.suffix }}${{ matrix.dotexe }}
164167
mv clang-apply-replacements${{ matrix.dotexe }} clang-apply-replacements-${{ env.suffix }}${{ matrix.dotexe }}
165-
166-
./clang-format-${{ env.suffix }}${{ matrix.dotexe }} --version
167-
./clang-query-${{ env.suffix }}${{ matrix.dotexe }} --version
168-
file ./clang-tidy-${{ env.suffix }}${{ matrix.dotexe }}
169-
./clang-tidy-${{ env.suffix }}${{ matrix.dotexe }} --version
170-
./clang-apply-replacements-${{ env.suffix }}${{ matrix.dotexe }} --version
171-
continue-on-error: true # continue to publish when clang-tidy 18+ failed on MacOS
172168
- name: Create and print sha512sum
173169
shell: bash
174170
run: |
@@ -188,6 +184,76 @@ jobs:
188184
name: clang-tools-${{ matrix.release }}-${{ env.suffix }}
189185
path: "${{ matrix.release }}${{ matrix.bindir }}/clang-*-${{ env.suffix }}*"
190186
retention-days: 1
187+
test-release:
188+
strategy:
189+
matrix:
190+
os: [ linux, macosx, windows ]
191+
include:
192+
- os: linux
193+
runner: ubuntu-22.04
194+
- os: macosx
195+
runner: macos-13
196+
- os: windows
197+
runner: windows-latest
198+
runs-on: ${{ matrix.runner }}
199+
needs: build
200+
env:
201+
suffix: '_${{ matrix.os }}-amd64'
202+
steps:
203+
- name: download artifacts
204+
uses: actions/download-artifact@v4
205+
with:
206+
path: artifacts
207+
pattern: '**/*${{ env.suffix }}'
208+
- name: List files (macos, linux)
209+
if: ${{ matrix.os == 'macosx' || matrix.os == 'linux' }}
210+
run: ls -laR artifacts/
211+
- name: Smoke test each clang tool (macos, linux)
212+
if: ${{ matrix.os == 'macosx' || matrix.os == 'linux' }}
213+
run: |
214+
cd artifacts
215+
# From the artifacts directory, loop over each executable
216+
# (not .sha512sum files) and
217+
# invoke the --version command to verify
218+
219+
for tool in $(find . -type f); do
220+
# Skip the sha512sum files
221+
if [[ $tool == *.sha512sum ]]; then
222+
continue
223+
fi
224+
chmod +x $tool
225+
# Run the tool with --version and print the output
226+
echo "Running $tool --version"
227+
$tool --version
228+
done
229+
- name: List files (Windows)
230+
if: ${{ matrix.os == 'windows' }}
231+
run: |
232+
Get-ChildItem -Recurse artifacts | Format-List
233+
234+
- name: Smoke test each clang tool (Windows)
235+
if: ${{ matrix.os == 'windows' }}
236+
shell: pwsh
237+
run: |
238+
Set-Location artifacts
239+
240+
# Find all files excluding *.sha512sum
241+
$tools = Get-ChildItem -Recurse -File | Where-Object { $_.Name -notlike '*.sha512sum' }
242+
243+
foreach ($tool in $tools) {
244+
# Ensure the file is executable
245+
$toolPath = $tool.FullName
246+
247+
# Print which tool is being run
248+
Write-Host "Running $toolPath --version"
249+
250+
try {
251+
# Attempt to run the tool with --version
252+
& $toolPath --version
253+
} catch {
254+
Write-Host "Failed to run $toolPath --version. Error: $_"
255+
}
256+
}
191257
draft-release:
192258
runs-on: ubuntu-22.04
193259
needs: build
@@ -209,8 +275,6 @@ jobs:
209275
uses: svenstaro/upload-release-action@v2
210276
with:
211277
repo_token: ${{ secrets.GITHUB_TOKEN }}
212-
release_name: master-${{ steps.get-sha.outputs.short_sha }}
213-
tag: master-${{ steps.get-sha.outputs.short_sha }}
214278
draft: true
215279
file_glob: true
216-
file: clang-*/**/*
280+
file: clang-*/**/*

0 commit comments

Comments
 (0)