Skip to content

Commit 4bf3c70

Browse files
committed
workflow needs to build
1 parent cee22c4 commit 4bf3c70

1 file changed

Lines changed: 155 additions & 0 deletions

File tree

.github/workflows/build.yml

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

0 commit comments

Comments
 (0)