Add test for GitHub Actions
@@ -195,6 +195,28 @@ class CIManagerTest(unittest.TestCase):
self.assertEquals(manager.is_pull_request(), True)
self.assertEquals(manager.is_tag(), True)
+ def test_github_actions_instance(self):
+ gha_env = {"GITHUB_ACTIONS": "true",
+ "GITHUB_SHA": "98e984eacf4e3dfea431c8850c8c181a08e8cf3d",
+ "GITHUB_REF": "testing/5.6.5",
+ "GITHUB_BASE_REF" : "testing/5.6.5",
+ "GITHUB_EVENT_NAME": "push"}
+ with tools.environment_append(gha_env):
+ manager = CIManager(self.printer)
+ self.assertEquals(manager.get_branch(), shippable_env["GITHUB_REF"])
+ self.assertEquals(manager.get_commit_id(), shippable_env["GITHUB_SHA"])
+ self.assertEquals(manager.is_pull_request(), False)
+
+ gha_env = {"GITHUB_ACTIONS": "true",
+ "GITHUB_SHA": "98e984eacf4e3dfea431c8850c8c181a08e8cf3d",
+ "GITHUB_REF": "quick_fix",
+ "GITHUB_BASE_REF" : "testing/5.6.5",
+ "GITHUB_EVENT_NAME": "pull_request"}
+ with tools.environment_append(gha_env):
+ manager = CIManager(self.printer)
+ self.assertEquals(manager.get_branch(), shippable_env["GITHUB_BASE_REF"])
+ self.assertEquals(manager.get_commit_id(), shippable_env["GITHUB_SHA"])
+ self.assertEquals(manager.is_pull_request(), True)
def test_build_policy(self):
# Travis
