Skip to content

Commit d680b9f

Browse files
committed
workflow: Add workflow
1 parent 66ab778 commit d680b9f

1 file changed

Lines changed: 148 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
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+
# 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+
- name: Fetch, verify, and setup build environment
116+
run: |
117+
export PATH="$PWD/depot_tools:$PATH"
118+
echo "$PWD/depot_tools" >> $GITHUB_PATH
119+
gclient config --spec 'solutions = [
120+
{
121+
"name": ".",
122+
"url": "https://chromium.googlesource.com/angle/angle.git",
123+
"deps_file": "DEPS",
124+
"managed": False,
125+
"custom_vars": {},
126+
},
127+
]
128+
target_os = ["${{ matrix.os }}"]'
129+
gclient sync -Rf --no-history --with_branch_heads
130+
- name: Build ANGLE
131+
run: |
132+
gn gen out/${{ matrix.os }}-${{ matrix.arch }}
133+
autoninja -C out/${{ matrix.os }}-${{ matrix.arch }}
134+
- name: Setup tmate session if failed
135+
if: ${{ failure() }}
136+
uses: mxschmitt/action-tmate@v3
137+
- name: Upload builds
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: ANGLE-${{ matrix.os }}-${{ matrix.arch }}
141+
path: out/${{ matrix.os }}-${{ matrix.arch }}
142+
- name: Upload shared library
143+
uses: actions/upload-artifact@v4
144+
with:
145+
name: ANGLE-${{ matrix.os }}-${{ matrix.arch }}.so
146+
path: |
147+
out/${{ matrix.os }}-${{ matrix.arch }}/lib*.so
148+
!out/${{ matrix.os }}-${{ matrix.arch }}/*.so.TOC

0 commit comments

Comments
 (0)