Skip to content

Commit 452e6ab

Browse files
committed
workflow: Add workflow
1 parent c5fcbc3 commit 452e6ab

1 file changed

Lines changed: 153 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: Build ANGLE
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
check-cache-date:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
reverify-cache: ${{ steps.check.outputs.reverify-cache }}
11+
steps:
12+
- name: Update cache once a week
13+
id: check
14+
env:
15+
GH_TOKEN: ${{ github.token }}
16+
run: |
17+
if gh cache list -R AngelAuraMC/angle --json createdAt -q '.[0].createdAt' | grep -q .; then
18+
echo "Cache exists"
19+
else
20+
echo "No cache found"
21+
echo "reverify-cache=true" >> "$GITHUB_OUTPUT"
22+
exit 0
23+
fi
24+
if (( $(date +%s) < $(( $(date -d "$(gh cache list -R AngelAuraMC/angle --json createdAt -q '.[0].createdAt')" +%s) + 604800 )) )); then
25+
echo "Cache is new enough"
26+
echo "reverify-cache=false" >> "$GITHUB_OUTPUT"
27+
else
28+
echo "Cache needs updating"
29+
echo "reverify-cache=true" >> "$GITHUB_OUTPUT"
30+
fi
31+
32+
update-build-environment-cache:
33+
needs: check-cache-date
34+
permissions:
35+
actions: write
36+
runs-on: ubuntu-24.04
37+
steps:
38+
# Do not remove this checkout else gclient sync gets confused on what rev of ANGLE to checkout
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
# if: needs.check-cache-date.outputs.reverify-cache == 'true' is spammed throughout this job because the job itself can't be skipped if we are to use needs for the build job
42+
- name: Restore environment from cache
43+
if: needs.check-cache-date.outputs.reverify-cache == 'true'
44+
id: cached-environment-restore
45+
uses: actions/cache/restore@v4
46+
with:
47+
path: ./
48+
key: ios_and_android-build-environment
49+
- name: Verify cached environment is valid
50+
if: needs.check-cache-date.outputs.reverify-cache == 'true'
51+
run: |
52+
if [ ! -d "depot_tools" ] ; then
53+
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
54+
fi
55+
export PATH="$PWD/depot_tools:$PATH"
56+
gclient config --spec 'solutions = [
57+
{
58+
"name": ".",
59+
"url": "https://chromium.googlesource.com/angle/angle.git",
60+
"deps_file": "DEPS",
61+
"managed": False,
62+
"custom_vars": {},
63+
},
64+
]
65+
target_os = ["ios", "android"]'
66+
gclient sync -Rf --no-history --with_branch_heads
67+
- name: Remove non-crossplatform files that cause build issues
68+
if: needs.check-cache-date.outputs.reverify-cache == 'true'
69+
run: |
70+
rm -rf third_party/llvm-build # This only contains linux files if ran on a linux machine, it has to be deleted so gclient can fetch the files for macOS/iOS instead
71+
# Stupid workaround, see https://github.com/azu/github-actions-overwrite-cache-example and https://github.com/actions/cache/issues/342
72+
- name: Delete Previous Cache
73+
if: needs.check-cache-date.outputs.reverify-cache == 'true'
74+
run: |
75+
gh cache delete "${{ steps.cached-environment-restore.outputs.cache-primary-key }}" --repo $GITHUB_REPOSITORY || echo "Cache not found. Skipping delete."
76+
env:
77+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
- name: Save environment to cache
79+
if: needs.check-cache-date.outputs.reverify-cache == 'true'
80+
uses: actions/cache/save@v4
81+
with:
82+
path: ./
83+
key: ios_and_android-build-environment
84+
85+
build:
86+
needs: update-build-environment-cache
87+
strategy:
88+
matrix:
89+
include:
90+
- os: android
91+
arch: arm64
92+
runs-on: ubuntu-24.04
93+
- os: android
94+
arch: arm
95+
runs-on: ubuntu-24.04
96+
- os: android
97+
arch: x86
98+
runs-on: ubuntu-24.04
99+
- os: android
100+
arch: x64
101+
runs-on: ubuntu-24.04
102+
- os: ios
103+
arch: arm64
104+
runs-on: macos-15
105+
runs-on: ${{ matrix.runs-on }}
106+
steps:
107+
- name: Checkout
108+
uses: actions/checkout@v4
109+
- name: Restore environment from cache
110+
id: cached-environment-restore
111+
uses: actions/cache/restore@v4
112+
with:
113+
path: ./
114+
key: ios_and_android-build-environment
115+
restore-keys: ios_and_android-build-environment
116+
fail-on-cache-miss: true
117+
- name: Fetch, verify, and setup build environment
118+
run: |
119+
if [ ! -d "depot_tools" ] ; then
120+
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
121+
fi
122+
export PATH="$PWD/depot_tools:$PATH"
123+
echo "$PWD/depot_tools" >> $GITHUB_PATH
124+
gclient config --spec 'solutions = [
125+
{
126+
"name": ".",
127+
"url": "https://chromium.googlesource.com/angle/angle.git",
128+
"deps_file": "DEPS",
129+
"managed": False,
130+
"custom_vars": {},
131+
},
132+
]
133+
target_os = ["${{ matrix.os }}"]'
134+
gclient sync -Rf --no-history --with_branch_heads
135+
- name: Build ANGLE
136+
run: |
137+
gn gen out/${{ matrix.os }}-${{ matrix.arch }}
138+
autoninja -C out/${{ matrix.os }}-${{ matrix.arch }}
139+
- name: Setup tmate session if failed
140+
if: ${{ failure() }}
141+
uses: mxschmitt/action-tmate@v3
142+
- name: Upload builds
143+
uses: actions/upload-artifact@v4
144+
with:
145+
name: ANGLE-${{ matrix.os }}-${{ matrix.arch }}
146+
path: out/${{ matrix.os }}-${{ matrix.arch }}
147+
- name: Upload shared library
148+
uses: actions/upload-artifact@v4
149+
with:
150+
name: ANGLE-${{ matrix.os }}-${{ matrix.arch }}.so
151+
path: |
152+
out/${{ matrix.os }}-${{ matrix.arch }}/lib*.so
153+
!out/${{ matrix.os }}-${{ matrix.arch }}/*.so.TOC

0 commit comments

Comments
 (0)