Skip to content

Commit f2d98b8

Browse files
committed
Move android.yml to pull.yml
1 parent fe20be9 commit f2d98b8

File tree

5 files changed

+97
-17
lines changed

5 files changed

+97
-17
lines changed

.github/hi.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cat >> hi.txt<< EOF
2+
hi
3+
4+
asjdi
5+
EOF

.github/hi.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
hi
2+
hi
3+
4+
asjdi
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
8+
"""
9+
Helper to determine whether a CI should run on a list of modified files.
10+
Takes a list of modified files and a list of matchers.
11+
If any modified file matches to the matcher, print '1' to indicate CI should
12+
run.
13+
"""
14+
15+
16+
import re
17+
18+
19+
def filename_matches(filename: str, matchers: list[str]):
20+
combined = "(" + ")|(".join(matchers) + ")"
21+
return re.match(combined, filename)
22+
23+
24+
def any_match(modified_files: list[str], matchers: list[str]):
25+
return any(filename_matches(f, matchers) for f in modified_files)
26+
27+
28+
def main(modified_file_list_path: str, matchers_path: str):
29+
with open(modified_file_list_path, "r") as f:
30+
modified_files = f.read().splitlines()
31+
with open(matchers_path, "r") as f:
32+
matchers = f.read().splitlines()
33+
if any_match(modified_files, matchers):
34+
print("1")
35+
else:
36+
print("0")
37+
38+
39+
if __name__ == "__main__":
40+
main()

.github/workflows/android.yml renamed to .github/workflows/_android.yml

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,60 @@
11
name: Android
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
- release/*
8-
tags:
9-
- ciflow/android/*
10-
pull_request:
11-
paths:
12-
- .ci/docker/**
13-
- .github/workflows/android.yml
14-
- build/*android*.sh
15-
- install_requirements.sh
16-
- examples/demo-apps/android/**
17-
- extension/android/**
18-
- extension/benchmark/android/**
19-
- extension/module/**
4+
workflow_call:
205
workflow_dispatch:
216

227
concurrency:
23-
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
8+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
249
cancel-in-progress: true
2510

2611
jobs:
12+
check_path:
13+
name: Check whether the affected path needs to be validated by this CI
14+
runs-on: ubuntu-22.04
15+
outputs:
16+
should_run: ${{ steps.check-path.outputs.should_run }}
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
fetch-depth: '0'
21+
- uses: actions/setup-python@v4
22+
with:
23+
python-version: '3.10'
24+
- name: Check path
25+
id: check-path
26+
env:
27+
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
28+
GITHUB_PR_BASE: ${{ github.base_ref }}
29+
GITHUB_PR_HEAD: ${{ github.head_ref }}
30+
run: |
31+
if [ -z "$GITHUB_PR_NUMBER" ]; then
32+
# It's not for a PR, but pushed to a branch in pull.yml, or dispatch. Always run.
33+
echo "::set-output should_run=1"
34+
return 0
35+
fi
36+
if [ -z "$GITHUB_PR_BASE" ] || [ -z "$GITHUB_PR_HEAD" ] ; then
37+
# Seems like not a well-formed PR
38+
echo "::set-output should_run=1"
39+
return 0
40+
fi
41+
git diff --name-only "$GITHUB_PR_BASE" "$GITHUB_PR_HEAD" > modified_files
42+
cat >> matcher<< EOF
43+
.ci/docker/
44+
.github/workflows/android.yml
45+
build/.*android.*.sh
46+
install_requirements.sh
47+
examples/demo-apps/android
48+
extension/android
49+
extension/benchmark/android
50+
extension/module
51+
EOF
52+
echo "::set-output should_run=$(python .github/scripts/check_path_match.py modified_files matcher)"
53+
2754
build-llm-demo:
2855
name: build-llm-demo
2956
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
57+
if: ${{ steps.check_path.outputs.should_run }} == '1'
3058
with:
3159
runner: linux.2xlarge
3260
docker-image: executorch-ubuntu-22.04-clang12-android

.github/workflows/pull.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ jobs:
347347
exit 1
348348
fi
349349
350+
android:
351+
uses: ./.github/workflows/_android.yml
352+
350353
unittest:
351354
uses: ./.github/workflows/_unittest.yml
352355
with:

0 commit comments

Comments
 (0)