Skip to content

Orchestrator

Orchestrator #113

name: Orchestrator
on:
pull_request:
types: [opened, reopened, ready_for_review]
workflow_dispatch:
jobs:
check-lockfile-job:
name: Check lockfile job
uses: ./.github/workflows/CI-check-lockfile.yml
build-job:
name: Cargo build job
needs: [check-lockfile-job]
uses: ./.github/workflows/CI-build.yml
test-job:
name: Cargo test job
needs: [check-lockfile-job]
uses: ./.github/workflows/CI-test.yml
test-bench-job:
name: Cargo test bench job
needs: [check-lockfile-job]
uses: ./.github/workflows/CI-test-bench.yml
try-runtime-job:
name: Try runtime job
needs: [check-lockfile-job]
uses: ./.github/workflows/CI-try-runtime.yml
lint-format-job:
name: Lint and format job
needs: [check-lockfile-job]
uses: ./.github/workflows/CI-lint-format.yml
audit-job:
name: Cargo audit job
needs: [check-lockfile-job]
uses: ./.github/workflows/CI-audit.yml
feature-propagation-job:
name: Feature propagation job
needs: [check-lockfile-job]
uses: ./.github/workflows/CI-feature-propagation.yml
machete-job:
name: Machete job
uses: ./.github/workflows/CI-machete.yml
# Only for pull requests and if not canceled
set-overall-result:
runs-on: warp-ubuntu-latest-x64-2x
name: Set overall status
needs:
[
check-lockfile-job,
build-job,
test-job,
test-bench-job,
try-runtime-job,
lint-format-job,
audit-job,
feature-propagation-job,
machete-job,
]
if: ${{ !cancelled() }}
outputs:
branch-name: ${{ steps.get-info.outputs.BRANCH_NAME }}
last-commit-sha: ${{ steps.get-info.outputs.LAST_COMMIT_SHA }}
pr-url: ${{ steps.get-info.outputs.PR_URL }}
overall-status: ${{ steps.set-status.outputs.OVERALL_STATUS }}
steps:
- name: Get target PR info
id: get-info
env:
BRANCH_NAME: "${{ github.head_ref || github.ref_name }}"
run: |
echo "BRANCH_NAME is ${{ env.BRANCH_NAME }}"
echo "BRANCH_NAME=${BRANCH_NAME}" >> "${GITHUB_OUTPUT}"
ALL_PRS="$(curl -s --fail \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls?state=open")"
LAST_COMMIT_SHA="$(echo "${ALL_PRS}" | jq ".[] | select(.head.label == \"${GITHUB_REPOSITORY_OWNER}:${BRANCH_NAME}\")" | jq -r ".head.sha")"
echo "LAST_COMMIT_SHA is ${LAST_COMMIT_SHA}"
echo "LAST_COMMIT_SHA=${LAST_COMMIT_SHA}" >> "${GITHUB_OUTPUT}"
echo "LAST_COMMIT_SHA=${LAST_COMMIT_SHA}" >> "${GITHUB_ENV}"
PR_URL="$(echo "${ALL_PRS}" | jq ".[] | select(.head.label == \"${GITHUB_REPOSITORY_OWNER}:${BRANCH_NAME}\")" | jq -r ".html_url")"
echo "PR_URL is ${PR_URL}"
echo "PR_URL=${PR_URL}" >> "${GITHUB_OUTPUT}"
- name: Set overall result
id: set-status
shell: bash
run: |
if [ "${{ github.event.workflow_run.conclusion }}" == "cancelled" ]; then
OVERALL_STATUS="cancelled"
else
OVERALL_STATUS="success"
if [ "${{ needs.check-lockfile-job.result }}" != "success" ] ||
[ "${{ needs.build-job.result }}" != "success" ] ||
[ "${{ needs.test-job.result }}" != "success" ] ||
[ "${{ needs.test-bench-job.result }}" != "success" ] ||
[ "${{ needs.try-runtime-job.result }}" != "success" ] ||
[ "${{ needs.lint-format-job.result }}" != "success" ] ||
[ "${{ needs.feature-propagation-job.result }}" != "success" ] ||
[ "${{ needs.audit-job.result }}" != "success" ] ||
[ "${{ needs.machete-job.result }}" != "success" ]; then
OVERALL_STATUS="failure"
fi
if [ "${LAST_COMMIT_SHA:-}" != "" ]; then
echo "Setting overall result"
curl -s -L --fail \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/statuses/${LAST_COMMIT_SHA}" \
-d '{"state":"'${OVERALL_STATUS}'","context":"Orchestrator"}'
else
echo "ERROR: 'LAST_COMMIT_SHA' variable is empty. Unable to set overall result"
fi
fi