Skip to content

Commit

Permalink
Make them all a single job and aggregated results at the end to incre…
Browse files Browse the repository at this point in the history
…ase speed and efficiency but also keeping it clear what steps are failing and what is passing

Signed-off-by: Alfredo Gutierrez <[email protected]>
  • Loading branch information
AlfredoG87 committed Jul 23, 2024
1 parent 70d2d26 commit 4ea866d
Showing 1 changed file with 37 additions and 27 deletions.
64 changes: 37 additions & 27 deletions .github/workflows/pr-formatting.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##
# Copyright (C) 2024 Hedera Hashgraph, LLC
# Copyright (C) 2023-2024 Hedera Hashgraph, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
##

name: "PR Formatting"
on:
pull_request:
Expand All @@ -31,8 +32,6 @@ on:
- locked
- unlocked
- synchronize
branches:
- "*"

defaults:
run:
Expand All @@ -42,42 +41,53 @@ permissions:
statuses: write

jobs:
title-check:
name: Title Check
pr-formatting-checks:
name: PR Formatting Checks
runs-on: [self-hosted, Linux, medium, ephemeral]
steps:
- name: Check PR Title
id: title-check
uses: step-security/conventional-pr-title-action@0eae74515f5a79f8773fa04142dd746df76666ac # v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true

milestone-check:
name: Milestone Check
runs-on: [self-hosted, Linux, medium, ephemeral]
steps:
- name: Check Milestone
if: ${{ github.event.pull_request.milestone == null }}
id: milestone-check
run: |
echo "Milestone is not set. Failing the workflow."
exit 1
if [[ "${{ github.event.pull_request.milestone }}" == "null" ]]; then
echo "Milestone is not set. Failing the workflow."
exit 1
fi
continue-on-error: true

assignee-check:
name: Assignee Check
runs-on: [ self-hosted, Linux, medium, ephemeral ]

steps:
- name: Check Assignee
if: ${{ github.event.pull_request.assignees == null || github.event.pull_request.assignees[0] == null }}
id: assignee-check
run: |
echo "Assignee is not set. Failing the workflow."
exit 1
if [[ "${{ github.event.pull_request.assignees }}" == "null" || "${{ github.event.pull_request.assignees[0] }}" == "null" ]]; then
echo "Assignee is not set. Failing the workflow."
exit 1
fi
continue-on-error: true

label-check:
name: Label Check
runs-on: [self-hosted, Linux, medium, ephemeral]
steps:
- name: Check Labels
if: ${{ github.event.pull_request.labels == null || github.event.pull_request.labels.size == 0 }}
id: label-check
run: |
if [[ "${{ github.event.pull_request.labels }}" == "null" || "${{ github.event.pull_request.labels.size }}" == 0 ]]; then
echo "No labels are set. Failing the workflow."
exit 1
fi
continue-on-error: true

- name: Aggregate Results
run: |
echo "No labels are set. Failing the workflow."
exit 1
failed=false
for step in title-check milestone-check assignee-check label-check; do
if [ "${{ steps.$step.outcome }}" == "failure" ]; then
echo "Step $step failed"
failed=true
fi
done
if [ "$failed" == "true" ]; then
exit 1
fi

0 comments on commit 4ea866d

Please sign in to comment.