Skip to content

Commit 45459a6

Browse files
committed
workflow: Add workflow
1 parent cf30f49 commit 45459a6

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+
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+
env:
20+
GH_TOKEN: ${{ github.token }}
21+
run: |
22+
if gh cache list -R AngelAuraMC/angle --json createdAt -q '.[0].createdAt' | grep -q .; then
23+
echo "Cache exists"
24+
else
25+
echo "No cache found"
26+
echo "reverify-cache=true" >> "$GITHUB_OUTPUT"
27+
exit 0
28+
fi
29+
if (( $(date +%s) < $(( $(date -d "$(gh cache list -R AngelAuraMC/angle --json createdAt -q '.[0].createdAt')" +%s) + 604800 )) )); then
30+
echo "Cache is new enough"
31+
echo "reverify-cache=false" >> "$GITHUB_OUTPUT"
32+
else
33+
echo "Cache needs updating"
34+
echo "reverify-cache=true" >> "$GITHUB_OUTPUT"
35+
fi
36+
37+
update-build-environment-cache:
38+
needs: check-cache-date
39+
permissions:
40+
actions: write
41+
runs-on: ubuntu-24.04
42+
steps:
43+
# Do not remove this checkout else gclient sync gets confused on what rev of ANGLE to checkout
44+
- name: Checkout
45+
uses: actions/checkout@v4
46+
# 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
47+
- name: Restore environment from cache
48+
if: needs.check-cache-date.outputs.reverify-cache == 'true'
49+
id: cached-environment-restore
50+
uses: actions/cache/restore@v4
51+
with:
52+
path: ./
53+
key: ios_and_android-build-environment
54+
- name: Verify cached environment is valid
55+
if: needs.check-cache-date.outputs.reverify-cache == 'true'
56+
run: |
57+
if [ ! -d "depot_tools" ] ; then
58+
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
59+
fi
60+
export PATH="$PWD/depot_tools:$PATH"
61+
gclient config --spec 'solutions = [
62+
{
63+
"name": ".",
64+
"url": "https://chromium.googlesource.com/angle/angle.git",
65+
"deps_file": "DEPS",
66+
"managed": False,
67+
"custom_vars": {},
68+
},
69+
]
70+
target_os = ["ios", "android"]'
71+
gclient sync -Rf --no-history --with_branch_heads
72+
- name: Remove non-crossplatform files that cause build issues
73+
if: needs.check-cache-date.outputs.reverify-cache == 'true'
74+
run: |
75+
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
76+
# Stupid workaround, see https://github.com/azu/github-actions-overwrite-cache-example and https://github.com/actions/cache/issues/342
77+
- name: Delete Previous Cache
78+
if: needs.check-cache-date.outputs.reverify-cache == 'true'
79+
run: |
80+
gh cache delete "${{ steps.cached-environment-restore.outputs.cache-primary-key }}" --repo $GITHUB_REPOSITORY || echo "Cache not found. Skipping delete."
81+
env:
82+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
- name: Save environment to cache
84+
if: needs.check-cache-date.outputs.reverify-cache == 'true'
85+
uses: actions/cache/save@v4
86+
with:
87+
path: ./
88+
key: ios_and_android-build-environment
89+
90+
build:
91+
needs: update-build-environment-cache
92+
strategy:
93+
matrix:
94+
include:
95+
- os: android
96+
arch: arm64
97+
runs-on: ubuntu-24.04
98+
- os: android
99+
arch: arm
100+
runs-on: ubuntu-24.04
101+
- os: android
102+
arch: x86
103+
runs-on: ubuntu-24.04
104+
- os: android
105+
arch: x64
106+
runs-on: ubuntu-24.04
107+
- os: ios
108+
arch: arm64
109+
runs-on: macos-15
110+
runs-on: ${{ matrix.runs-on }}
111+
steps:
112+
- name: Checkout
113+
uses: actions/checkout@v4
114+
- name: Restore environment from cache
115+
id: cached-environment-restore
116+
uses: actions/cache/restore@v4
117+
with:
118+
path: ./
119+
key: ios_and_android-build-environment
120+
- name: Fetch, verify, and setup build environment
121+
run: |
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)