Skip to content

Commit 092a85b

Browse files
committed
workflow: Add workflow
1 parent 66ab778 commit 092a85b

1 file changed

Lines changed: 151 additions & 0 deletions

File tree

.github/workflows/build.yml

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

0 commit comments

Comments
 (0)