Skip to content

Commit

Permalink
upgrade ci
Browse files Browse the repository at this point in the history
see unrealsdk 6c73287e for more details
  • Loading branch information
apple1417 committed Oct 2, 2024
1 parent 6d592d1 commit 7b9a72f
Showing 1 changed file with 28 additions and 95 deletions.
123 changes: 28 additions & 95 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,12 @@ on:
required: false

env:
# Important to pin the clang version, cause we also use it for linting
CLANG_VERSION: 17
CLANG_TIDY_JOBS: 4
# LLVM MinGW download
LLVM_MINGW_VERSION: llvm-mingw-20231128-msvcrt-ubuntu-20.04-x86_64
LLVM_MINGW_DOWNLOAD: https://github.com/mstorsjo/llvm-mingw/releases/download/20231128/llvm-mingw-20231128-msvcrt-ubuntu-20.04-x86_64.tar.xz
# xwin settings
XWIN_VERSION: xwin-0.5.0-x86_64-unknown-linux-musl
XWIN_DOWNLOAD: https://github.com/Jake-Shadle/xwin/releases/download/0.5.0/xwin-0.5.0-x86_64-unknown-linux-musl.tar.gz
LLVM_MINGW_VERSION: llvm-mingw-20240619-msvcrt-ubuntu-20.04-x86_64
LLVM_MINGW_DOWNLOAD: https://github.com/mstorsjo/llvm-mingw/releases/download/20240619/llvm-mingw-20240619-msvcrt-ubuntu-20.04-x86_64.tar.xz

jobs:
cache-clang:
runs-on: windows-latest

steps:
- name: Cache Clang
uses: actions/cache@v4
id: cache-clang
with:
path: C:\Program Files\LLVM
key: ${{ runner.os }}-clang-${{ env.CLANG_VERSION }}
lookup-only: true

- name: Setup Clang
if: steps.cache-clang.outputs.cache-hit != 'true'
uses: egor-tensin/setup-clang@v1
with:
version: ${{ env.CLANG_VERSION }}

# ==============================================================================

build-windows:
runs-on: windows-latest
needs: cache-clang

strategy:
fail-fast: false
Expand All @@ -58,13 +30,9 @@ jobs:
]

steps:
- name: Restore Clang Cache
- name: Setup Clang
if: startswith(matrix.preset, 'clang')
uses: actions/cache/restore@v4
with:
path: C:\Program Files\LLVM
key: ${{ runner.os }}-clang-${{ env.CLANG_VERSION }}
fail-on-cache-miss: true
uses: egor-tensin/setup-clang@v1

- name: Add MSVC to PATH
if: startswith(matrix.preset, 'msvc')
Expand Down Expand Up @@ -113,31 +81,6 @@ jobs:
- name: Setup CMake and Ninja
uses: lukka/get-cmake@latest

# Both Clang and MinGW install quick enough that it's not worth caching
# Caching would also lose the +x - so we'd have to tar before caching/untar after, making it
# even slower
- name: Setup Clang
if: startswith(matrix.preset, 'clang')
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ env.CLANG_VERSION }}
sudo update-alternatives --install \
/usr/bin/clang \
clang \
/usr/bin/clang-${{ env.CLANG_VERSION }} \
200
sudo update-alternatives --install \
/usr/bin/clang++ \
clang++ \
/usr/bin/clang++-${{ env.CLANG_VERSION }} \
200
sudo update-alternatives --install \
/usr/bin/llvm-rc \
llvm-rc \
/usr/bin/llvm-rc-${{ env.CLANG_VERSION }} \
200

- name: Setup LLVM MinGW
if: startswith(matrix.preset, 'llvm-mingw')
Expand All @@ -146,32 +89,31 @@ jobs:
tar -xf ${{ env.LLVM_MINGW_VERSION }}.tar.xz -C ~/
echo $(readlink -f ~/${{ env.LLVM_MINGW_VERSION }}/bin) >> $GITHUB_PATH
- name: Set up MinGW
- name: Setup MinGW
if: startswith(matrix.preset, 'mingw')
uses: egor-tensin/setup-mingw@v2
with:
platform: ${{ fromJSON('["x86", "x64"]')[contains(matrix.preset, 'x64')] }}

# xwin does take long enough that caching's worth it
- name: Restore xwin cache
if: contains(matrix.preset, 'cross')
- name: Setup Clang
if: startswith(matrix.preset, 'clang-cross')
uses: egor-tensin/setup-clang@v1

- name: Restore win sdk cache
if: startswith(matrix.preset, 'clang-cross')
uses: actions/cache@v4
id: cache-xwin
id: cache-win-sdk
with:
path: ~/xwin
key: ${{ runner.os }}-xwin
path: ~/win-sdk
key: ${{ runner.os }}-win-sdk

- name: Setup xwin
if: contains(matrix.preset, 'cross') && steps.cache-xwin.outputs.cache-hit != 'true'
- name: Setup win sdk
if: startswith(matrix.preset, 'clang-cross') && steps.cache-win-sdk.outputs.cache-hit != 'true'
run: |
wget -nv ${{ env.XWIN_DOWNLOAD }}
tar -xf ${{ env.XWIN_VERSION }}.tar.gz
${{ env.XWIN_VERSION }}/xwin \
--accept-license \
--arch x86,x86_64 \
splat \
--include-debug-libs \
--output ~/xwin
git clone https://github.com/mstorsjo/msvc-wine.git
msvc-wine/vsdownload.py --accept-license --dest ~/win-sdk Microsoft.VisualStudio.Workload.VCTools
msvc-wine/install.sh ~/win-sdk
rm -r msvc-wine
- name: Checkout repository and submodules
uses: actions/checkout@v4
Expand All @@ -180,12 +122,12 @@ jobs:

- name: Configure CMake
working-directory: ${{ env.GITHUB_WORKSPACE }}
# The extra xwin dir arg won't do anything if we're not cross compiling
# The extra msvc wine arg won't do anything if we're not cross compiling
run: >
cmake .
--preset ${{ matrix.preset }}
-G Ninja
-DXWIN_DIR=$(readlink -f ~)/xwin
-DMSVC_WINE_ENV_SCRIPT=$(readlink -f ~)/win-sdk/bin/${{ fromJSON('["x86", "x64"]')[contains(matrix.preset, 'x64')] }}/msvcenv.sh
- name: Build
working-directory: ${{ env.GITHUB_WORKSPACE }}
Expand All @@ -201,7 +143,6 @@ jobs:

clang-tidy:
runs-on: windows-latest
needs: cache-clang

strategy:
fail-fast: false
Expand All @@ -212,12 +153,9 @@ jobs:
]

steps:
- name: Restore Clang Cache
uses: actions/cache/restore@v4
with:
path: C:\Program Files\LLVM
key: ${{ runner.os }}-clang-${{ env.CLANG_VERSION }}
fail-on-cache-miss: true
- name: Setup Clang
if: startswith(matrix.preset, 'clang')
uses: egor-tensin/setup-clang@v1

- name: Setup CMake and Ninja
uses: lukka/get-cmake@latest
Expand Down Expand Up @@ -246,7 +184,6 @@ jobs:
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: |
python (Get-Command run-clang-tidy).Source `
-j ${{ env.CLANG_TIDY_JOBS }} `
-p "out\build\${{ matrix.preset }}" `
-export-fixes clang-tidy-fixes.yml `
$([Regex]::Escape("$pwd\src") + ".+\.(c|cpp|h|hpp)$")
Expand All @@ -258,15 +195,11 @@ jobs:

clang-format:
runs-on: windows-latest
needs: cache-clang

steps:
- name: Restore Clang Cache
uses: actions/cache/restore@v4
with:
path: C:\Program Files\LLVM
key: ${{ runner.os }}-clang-${{ env.CLANG_VERSION }}
fail-on-cache-miss: true
- name: Setup Clang
if: startswith(matrix.preset, 'clang')
uses: egor-tensin/setup-clang@v1

- name: Checkout repository
uses: actions/checkout@v4
Expand Down

0 comments on commit 7b9a72f

Please sign in to comment.