Skip to content

Commit

Permalink
Fixes LLVM caching
Browse files Browse the repository at this point in the history
  • Loading branch information
ultimaweapon committed Sep 14, 2023
1 parent 5e1a0a2 commit 36cb1cc
Showing 1 changed file with 80 additions and 22 deletions.
102 changes: 80 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,105 @@ on:
branches:
- main
jobs:
build:
name: Build
deps:
name: Build dependencies
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
parallel: 2
build-deps: ./build-deps.sh
artifact: nitro-linux-x86_64
artifact: deps-linux-x86_64
llvm: |
curl -o llvm.tar.xz "$LLVM_URL"
hash=$(md5sum llvm.tar.xz | head -c 32)
mkdir llvm
tar -xJ --strip-components=1 -C llvm -f llvm.tar.xz
rm llvm.tar.xz
echo "key=${{ runner.os }}-llvm-$hash" >> $GITHUB_OUTPUT
- os: macos-latest
parallel: 3
build-deps: ./build-deps.sh
artifact: nitro-mac-x86_64
artifact: deps-mac-x86_64
llvm: |
curl -o llvm.tar.xz "$LLVM_URL"
hash=$(md5sum llvm.tar.xz | head -c 32)
mkdir llvm
tar -xJ --strip-components=1 -C llvm -f llvm.tar.xz
rm llvm.tar.xz
echo "key=${{ runner.os }}-llvm-$hash" >> $GITHUB_OUTPUT
- os: windows-latest
parallel: 2
build-deps: .\build-deps.ps1
artifact: nitro-win-x86_64
artifact: deps-win-x86_64
llvm: |
Invoke-WebRequest -Uri "$env:LLVM_URL" -OutFile llvm.tar.xz
$hash = (Get-FileHash llvm.tar.xz).Hash
unxz llvm.tar.xz
New-Item .\llvm -ItemType Directory
tar -x --strip-components=1 -C llvm -f llvm.tar
Remove-Item llvm.tar.xz, llvm.tar
echo "key=${{ runner.os }}-llvm-$hash" >> $env:GITHUB_OUTPUT
runs-on: ${{ matrix.os }}
env:
LLVM_URL: https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.6/llvm-project-16.0.6.src.tar.xz
CMAKE_BUILD_PARALLEL_LEVEL: ${{ matrix.parallel }}
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
submodules: recursive
- name: Restore LLVM
- name: Download LLVM
run: ${{ matrix.llvm }}
id: llvm
- name: Restore build files
uses: actions/cache/restore@v3
with:
path: deps/llvm/build
key: ${{ runner.os }}-llvm
- name: Build dependencies
run: ${{ matrix.build-deps }}
- name: Build CLI
run: cargo install --path stage0 --root dist
- name: Cache LLVM
path: llvm/build
key: ${{ steps.llvm.outputs.key }}
- name: Run CMake
run: cmake --install-prefix "${{ github.workspace }}/dist/llvm" -B "${{ github.workspace }}/llvm/build" -Wno-dev -DCMAKE_BUILD_TYPE:STRING=Release -DLLVM_ENABLE_ZSTD:BOOL=OFF -DLLVM_APPEND_VC_REV:BOOL=OFF llvm/llvm
- name: Build
run: cmake --build "${{ github.workspace }}/llvm/build" --config Release
- name: Cache build files
uses: actions/cache/save@v3
with:
path: deps/llvm/build
key: ${{ runner.os }}-llvm-${{ github.run_id }}
path: llvm/build
key: ${{ steps.llvm.outputs.key }}-${{ github.run_id }}
if: startsWith(github.ref, 'refs/heads/')
- name: Export artifacts
run: cmake --install "${{ github.workspace }}/llvm/build" --config Release
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact }}
path: dist
build:
name: Build Nitro
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
deps: deps-linux-x86_64
perms: chmod +x lib/llvm/bin/llvm-config
artifact: nitro-linux-x86_64
- os: macos-latest
deps: deps-mac-x86_64
perms: chmod +x lib/llvm/bin/llvm-config
artifact: nitro-mac-x86_64
- os: windows-latest
deps: deps-win-x86_64
perms: ''
artifact: nitro-win-x86_64
runs-on: ${{ matrix.os }}
needs: deps
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Download dependencies
uses: actions/download-artifact@v3
with:
name: ${{ matrix.deps }}
path: lib
- name: Fix file permissions
run: ${{ matrix.perms }}
- name: Build CLI
run: cargo install --path stage0 --root dist
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
Expand Down

0 comments on commit 36cb1cc

Please sign in to comment.