Skip to content

Commit 182d4a8

Browse files
committed
workflow: Add workflow
1 parent 66ab778 commit 182d4a8

1 file changed

Lines changed: 139 additions & 0 deletions

File tree

.github/workflows/build.yml

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

0 commit comments

Comments
 (0)