HyukjinKwon commented on a change in pull request #29086:
URL: https://github.com/apache/spark/pull/29086#discussion_r454144037
##########
File path: dev/run-tests.py
##########
@@ -589,43 +627,74 @@ def main():
# /home/jenkins/anaconda2/envs/py36/bin
os.environ["PATH"] = "/home/anaconda/envs/py36/bin:" +
os.environ.get("PATH")
else:
- # else we're running locally and can use local settings
+ # else we're running locally or Github Actions.
build_tool = "sbt"
hadoop_version = os.environ.get("HADOOP_PROFILE", "hadoop2.7")
hive_version = os.environ.get("HIVE_PROFILE", "hive2.3")
- test_env = "local"
+ if "GITHUB_ACTIONS" in os.environ:
+ test_env = "github_actions"
+ else:
+ test_env = "local"
print("[info] Using build tool", build_tool, "with Hadoop profile",
hadoop_version,
"and Hive profile", hive_version, "under environment", test_env)
extra_profiles = get_hadoop_profiles(hadoop_version) +
get_hive_profiles(hive_version)
changed_modules = None
+ test_modules = None
changed_files = None
- should_only_test_modules = "TEST_ONLY_MODULES" in os.environ
+ should_only_test_modules = opts.modules is not None
included_tags = []
+ excluded_tags = []
if should_only_test_modules:
- str_test_modules = [m.strip() for m in
os.environ.get("TEST_ONLY_MODULES").split(",")]
+ str_test_modules = [m.strip() for m in opts.modules.split(",")]
test_modules = [m for m in modules.all_modules if m.name in
str_test_modules]
- # Directly uses test_modules as changed modules to apply tags and
environments
- # as if all specified test modules are changed.
+
+ # If we're running the tests in Github Actions, attempt to detect and
test
+ # only the affected modules.
+ if test_env == "github_actions":
+ if os.environ["GITHUB_BASE_REF"] != "":
+ # Pull requests
+ changed_files = identify_changed_files_from_git_commits(
+ os.environ["GITHUB_SHA"],
target_branch=os.environ["GITHUB_BASE_REF"])
Review comment:
From my testing, it combines all commits and `changed_files` is based on
all commits always.
Seems like `GITHUB_SHA` became a merge commit internally in Github Actions,
and `GITHUB_BASE_REF` becomes the branch which PR opens against.
For example, if a PR has commits 1, 2 and 3, GitHub Actions looks creates a
merge commit 4 for commits 1, 2 and 3. And, it calculates the diff from the
branch, for example, `master` in the original repo, Apache Spark.
```bash
git diff 4 master
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]