Skip to content

Commit 0619229

Browse files
authored
Merge branch 'develop' into feature/test-flags-big-fix
2 parents 5c5d33a + 0913560 commit 0619229

File tree

5 files changed

+51
-48
lines changed

5 files changed

+51
-48
lines changed

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ jobs:
6969
aws-region: us-east-2
7070
7171
- name: Run JEDI CI
72-
uses: JCSDA-internal/jedi-ci@feature/ci-v3
72+
uses: JCSDA-internal/jedi-ci@develop
7373
with:
7474
container_version: 'latest'
75-
env:
76-
TARGET_REPO_DIR: target_repository
77-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78-
JEDI_CI_TOKEN: ${{ steps.generate-token.outputs.token }}
79-
```
75+
jedi_ci_token: ${{ steps.generate-token.outputs.token }}

action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ inputs:
2020
required: false
2121
default: 'run_tests.sh'
2222
target_repo_dir:
23-
description: 'Target repository directory'
23+
description: 'Deprecated option, we no longer pre-clone the target repository.'
2424
required: false
2525
default: 'target_repository'
2626
bundle_repository:
@@ -68,7 +68,6 @@ runs:
6868
TARGET_PROJECT_NAME: ${{ inputs.target_project_name }}
6969
BUNDLE_BRANCH: ${{ inputs.bundle_branch }}
7070
TEST_SCRIPT: ${{ inputs.test_script }}
71-
TARGET_REPO_DIR: ${{ inputs.target_repo_dir }}
7271
BUNDLE_REPOSITORY: ${{ inputs.bundle_repository }}
7372
CI_SELF_TEST: ${{ inputs.self_test }}
7473
JEDI_CI_TOKEN: ${{ inputs.jedi_ci_token }}

ci_action/implementation.py

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,48 @@ def upload_to_aws(bucket_name, s3_client, tarball_path, s3_file):
5151
return s3_path
5252

5353

54+
def cancel_prior_jobs_and_check_runs(
55+
non_blocking_errors,
56+
infra_config,
57+
config,
58+
):
59+
"""Cancel prior unfinished jobs and check runs for the PR."""
60+
# Use a thread pool to cancel prior unfinished jobs and their associated check runs.
61+
# This process is done in parallel to save time on slow network-bound operations.
62+
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
63+
64+
# Submit operation: cancel prior unfinished AWS Batch jobs for the PR.
65+
cxl_batch_future = executor.submit(
66+
aws_client.cancel_prior_batch_jobs,
67+
job_queue=infra_config['batch_queue'],
68+
repo_name=config['repo_name'],
69+
pr=config["pull_request_number"],
70+
)
71+
72+
# Submit operation: cancel unfinished check runs for the PR.
73+
cxl_checkrun_future = executor.submit(
74+
github_client.cancel_prior_unfinished_check_runs,
75+
repo=config['repo_name'],
76+
owner=config['owner'],
77+
pr_number=config["pull_request_number"],
78+
)
79+
80+
# Wait for the cancel operations to complete.
81+
for future in concurrent.futures.as_completed([cxl_batch_future, cxl_checkrun_future]):
82+
try:
83+
future.result()
84+
except Exception as e:
85+
if future is cxl_batch_future:
86+
non_blocking_errors.append(f"Error cancelling prior batch jobs: {e}")
87+
else:
88+
non_blocking_errors.append(f"Error cancelling prior check runs: {e}")
89+
return non_blocking_errors
90+
91+
5492
def prepare_and_launch_ci_test(
5593
infra_config,
5694
config,
5795
bundle_repo_path,
58-
target_repo_path,
5996
):
6097
"""The main function that will be called to prepare and launch the CI test.
6198
@@ -68,7 +105,6 @@ def prepare_and_launch_ci_test(
68105
config: The GitHub action environment configuration including
69106
PR metadata and passed config variables.
70107
bundle_repo_path: The path to the bundle repository.
71-
target_repo_path: The path to the target repository.
72108
73109
Returns:
74110
A 2-tuple of lists of strings representing errors:
@@ -205,35 +241,11 @@ def prepare_and_launch_ci_test(
205241
else:
206242
chosen_build_environments = [test_select]
207243

208-
# Use a thread pool to cancel prior unfinished jobs and their associated check runs.
209-
# This process is done in parallel to save time on slow network-bound operations.
210-
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
211-
212-
# Submit operation: cancel prior unfinished AWS Batch jobs for the PR.
213-
cxl_batch_future = executor.submit(
214-
aws_client.cancel_prior_batch_jobs,
215-
job_queue=infra_config['batch_queue'],
216-
repo_name=config['repo_name'],
217-
pr=config["pull_request_number"],
218-
)
219-
220-
# Submit operation: cancel unfinished check runs for the PR.
221-
cxl_checkrun_future = executor.submit(
222-
github_client.cancel_prior_unfinished_check_runs,
223-
repo=config['repo_name'],
224-
owner=config['owner'],
225-
pr_number=config["pull_request_number"],
226-
)
227-
228-
# Wait for the cancel operations to complete.
229-
for future in concurrent.futures.as_completed([cxl_batch_future, cxl_checkrun_future]):
230-
try:
231-
future.result()
232-
except Exception as e:
233-
if future is cxl_batch_future:
234-
non_blocking_errors.append(f"Error cancelling prior batch jobs: {e}")
235-
else:
236-
non_blocking_errors.append(f"Error cancelling prior check runs: {e}")
244+
non_blocking_errors = cancel_prior_jobs_and_check_runs(
245+
non_blocking_errors,
246+
infra_config,
247+
config,
248+
)
237249

238250
# This is a constructor for the configuration needed to submit AWS Batch jobs.
239251
# This constructor reads configuration from the environment and must be

ci_action/library/pr_resolve.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ class TestAnnotations(NamedTuple):
5353
# not read from the cache and will build all code.
5454
skip_cache: str
5555

56-
# Should draft pull request run all tests. Defaults to False.
57-
run_on_draft: bool
58-
5956
# If True, a 2-hour sleep will be added to the conclusion of a test.
6057
debug_mode: bool
6158

@@ -73,6 +70,9 @@ class TestAnnotations(NamedTuple):
7370
# default branch. This branch must exist in `JCSDA-internal/jedi-bundle`.
7471
jedi_bundle_branch: str
7572

73+
# Should draft pull request run all tests. Defaults to False.
74+
run_on_draft: bool = False
75+
7676

7777
def read_test_annotations(
7878
repo_uri: str,
@@ -168,11 +168,11 @@ def read_test_annotations(
168168
return TestAnnotations(
169169
build_group_map=build_group_pr_map,
170170
skip_cache=skip_cache,
171-
run_on_draft=run_on_draft,
172171
debug_mode=debug_mode,
173172
next_ci_suffix=next_ci_suffix,
174173
test_select=test_select,
175174
jedi_bundle_branch=bundle_branch,
175+
run_on_draft=run_on_draft,
176176
)
177177

178178

ci_action/main.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ def main():
171171
return 0
172172

173173
workspace_dir = os.environ.get('GITHUB_WORKSPACE', os.getcwd())
174-
target_repo_full_path = os.path.join(
175-
workspace_dir, os.environ['TARGET_REPO_DIR'])
176-
177174
# Get environment attributes set by GitHub.
178175
env_config = get_environment_config()
179176

@@ -184,8 +181,7 @@ def main():
184181
errors, non_blocking_errors = ci_implementation.prepare_and_launch_ci_test(
185182
infra_config=JEDI_CI_INFRA_CONFIG,
186183
config=env_config,
187-
bundle_repo_path=os.path.join(workspace_dir, 'bundle'),
188-
target_repo_path=target_repo_full_path)
184+
bundle_repo_path=os.path.join(workspace_dir, 'bundle'))
189185

190186
# The following block is used to format a list of errors that will be logged to the GitHub
191187
# action log. The output should look something like this.

0 commit comments

Comments
 (0)