mirror of https://github.com/rust-lang/rust.git
Output `run_type` from the matrix calculation job
This commit is contained in:
parent
adbc84cfac
commit
b194d5ce44
|
@ -47,6 +47,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
jobs: ${{ steps.jobs.outputs.jobs }}
|
||||
run_type: ${{ steps.jobs.outputs.run_type }}
|
||||
steps:
|
||||
- name: Checkout the source code
|
||||
uses: actions/checkout@v4
|
||||
|
@ -116,7 +117,7 @@ jobs:
|
|||
run: echo "[CI_PR_NUMBER=$num]"
|
||||
env:
|
||||
num: ${{ github.event.number }}
|
||||
if: github.event_name == 'pull_request'
|
||||
if: needs.calculate_matrix.outputs.run_type == 'pr'
|
||||
|
||||
- name: add extra environment variables
|
||||
run: src/ci/scripts/setup-environment.sh
|
||||
|
@ -226,9 +227,9 @@ jobs:
|
|||
outcome:
|
||||
name: bors build finished
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ job ]
|
||||
needs: [ calculate_matrix, job ]
|
||||
# !cancelled() executes the job regardless of whether the previous jobs passed or failed
|
||||
if: "!cancelled() && github.event_name == 'push'"
|
||||
if: ${{ !cancelled() && contains(fromJSON('["auto", "try"]'), needs.calculate_matrix.outputs.run_type) }}
|
||||
steps:
|
||||
- name: checkout the source code
|
||||
uses: actions/checkout@v4
|
||||
|
@ -243,6 +244,6 @@ jobs:
|
|||
- name: publish toolstate
|
||||
run: src/ci/publish_toolstate.sh
|
||||
shell: bash
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'
|
||||
if: needs.calculate_matrix.outputs.run_type == 'auto'
|
||||
env:
|
||||
TOOLSTATE_REPO_ACCESS_TOKEN: ${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}
|
||||
|
|
|
@ -106,6 +106,17 @@ def get_github_ctx() -> GitHubCtx:
|
|||
)
|
||||
|
||||
|
||||
def format_run_type(run_type: WorkflowRunType) -> str:
|
||||
if run_type == WorkflowRunType.PR:
|
||||
return "pr"
|
||||
elif run_type == WorkflowRunType.Auto:
|
||||
return "auto"
|
||||
elif run_type == WorkflowRunType.Try:
|
||||
return "try"
|
||||
else:
|
||||
raise AssertionError()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
@ -124,6 +135,8 @@ if __name__ == "__main__":
|
|||
if run_type is not None:
|
||||
jobs = calculate_jobs(run_type, data)
|
||||
jobs = skip_jobs(jobs, channel)
|
||||
run_type = format_run_type(run_type)
|
||||
|
||||
logging.info(f"Output:\n{yaml.dump(jobs, indent=4)}")
|
||||
logging.info(f"Output:\n{yaml.dump(dict(jobs=jobs, run_type=run_type), indent=4)}")
|
||||
print(f"jobs={json.dumps(jobs)}")
|
||||
print(f"run_type={run_type}")
|
||||
|
|
Loading…
Reference in New Issue