Skip to content

Commit 9743ff1

Browse files
committed
ci: stabilize branch cache workflow
1 parent f824042 commit 9743ff1

1 file changed

Lines changed: 47 additions & 29 deletions

File tree

.github/workflows/build-android-arm64.yml

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
push:
66
branches:
77
- main
8+
- codex/fix-android-arm64-build
89

910
jobs:
1011
build:
@@ -36,39 +37,32 @@ jobs:
3637
"build-tools;${ANDROID_BUILD_TOOLS_VERSION}" \
3738
"ndk;${ANDROID_NDK_VERSION}"
3839
39-
- name: Set Up Java 11
40-
uses: actions/setup-java@v4
41-
with:
42-
distribution: temurin
43-
java-version: "11"
44-
45-
- name: Restore Bazel caches
40+
- name: Restore Bazel Repository Cache
4641
uses: actions/cache@v4
4742
with:
48-
path: |
49-
${{ github.workspace }}/.bazel-cache/repository
50-
${{ github.workspace }}/.bazel-cache/disk
43+
path: ${{ github.workspace }}/.bazel-cache/repository
5144
key: ${{ runner.os }}-bazel-${{ env.ANDROID_PLATFORM }}-${{ env.TFJAVA_COMMIT }}-${{ hashFiles('scripts/patch_tfjava.py', '.github/workflows/build-android-arm64.yml') }}
5245
restore-keys: |
5346
${{ runner.os }}-bazel-${{ env.ANDROID_PLATFORM }}-${{ env.TFJAVA_COMMIT }}-
5447
${{ runner.os }}-bazel-${{ env.ANDROID_PLATFORM }}-
5548
56-
- name: Restore Maven repository cache
57-
uses: actions/cache@v4
58-
with:
59-
path: /home/runner/.m2/repository
60-
key: ${{ runner.os }}-m2-${{ env.TFJAVA_COMMIT }}-${{ hashFiles('scripts/patch_tfjava.py', '.github/workflows/build-android-arm64.yml') }}
61-
restore-keys: |
62-
${{ runner.os }}-m2-${{ env.TFJAVA_COMMIT }}-
63-
${{ runner.os }}-m2-
64-
6549
- name: Clone TensorFlow Java
6650
shell: bash
6751
run: |
6852
git clone https://github.com/tensorflow/java.git tfjava
6953
cd tfjava
7054
git checkout "${TFJAVA_COMMIT}"
7155
56+
- name: Set Up Java 11
57+
uses: actions/setup-java@v4
58+
with:
59+
distribution: temurin
60+
java-version: "11"
61+
cache: maven
62+
cache-dependency-path: |
63+
tfjava/pom.xml
64+
tfjava/**/pom.xml
65+
7266
- name: Patch TensorFlow Java For Android ARM64
7367
shell: bash
7468
run: |
@@ -123,8 +117,7 @@ jobs:
123117
export LC_ALL="C.UTF-8"
124118
export PATH="${JAVA_HOME}/bin:${PATH}"
125119
export BAZEL_REPOSITORY_CACHE="${GITHUB_WORKSPACE}/.bazel-cache/repository"
126-
export BAZEL_DISK_CACHE="${GITHUB_WORKSPACE}/.bazel-cache/disk"
127-
mkdir -p "${BAZEL_REPOSITORY_CACHE}" "${BAZEL_DISK_CACHE}"
120+
mkdir -p "${BAZEL_REPOSITORY_CACHE}"
128121
mkdir -p "${GITHUB_WORKSPACE}/artifacts"
129122
cd tfjava
130123
mvn -B -e \
@@ -152,12 +145,15 @@ jobs:
152145
raise SystemExit(0)
153146
154147
lines = log_path.read_text(encoding="utf-8", errors="ignore").splitlines()
155-
patterns = [
156-
re.compile(r"^(.+?:\d+(?::\d+)?: (?:fatal )?error: .+)$"),
157-
re.compile(r"^(.+?UnsatisfiedLinkError.+)$"),
158-
re.compile(r"^(.+?NoSuch.+)$"),
159-
re.compile(r"^(ERROR: .+)$"),
160-
re.compile(r"^(FAILED: .+)$"),
148+
primary_patterns = [
149+
re.compile(r"^\s*.+?:\d+(?::\d+)?: (?:fatal )?error: .+$"),
150+
re.compile(r"^\s*.+?: error: .+$"),
151+
re.compile(r"^\s*(?:ld(?:\.lld)?|clang(?:\+\+)?): error: .+$"),
152+
re.compile(r"^\s*undefined reference to .+$"),
153+
re.compile(r"^\s*cannot find -l.+$"),
154+
re.compile(r"^\s*collect2: error: .+$"),
155+
re.compile(r"^\s*.+?UnsatisfiedLinkError.+$"),
156+
re.compile(r"^\s*.+?NoSuch.+$"),
161157
]
162158
163159
skip = (
@@ -167,16 +163,38 @@ jobs:
167163
"BUILD FAILURE",
168164
"compilation of rule",
169165
"Linking of rule",
166+
"Failed to restore: Cache service responded with 400",
170167
)
171168
169+
def is_skippable(line: str) -> bool:
170+
return any(token in line for token in skip)
171+
172172
hit = None
173173
for i, line in enumerate(lines):
174-
if any(token in line for token in skip):
174+
if is_skippable(line):
175175
continue
176-
if any(p.search(line) for p in patterns):
176+
if any(p.search(line) for p in primary_patterns):
177177
hit = i
178178
break
179179
180+
if hit is None:
181+
for i in range(len(lines) - 1, -1, -1):
182+
line = lines[i]
183+
normalized = line.strip()
184+
if not normalized or is_skippable(line):
185+
continue
186+
if "error:" in normalized or "undefined reference" in normalized:
187+
hit = i
188+
break
189+
190+
if hit is None:
191+
for i, line in enumerate(lines):
192+
if is_skippable(line):
193+
continue
194+
if line.startswith("ERROR: ") or line.startswith("FAILED: "):
195+
hit = i
196+
break
197+
180198
if hit is None:
181199
hit = max(0, len(lines) - 80)
182200

0 commit comments

Comments
 (0)