Skip to content

Commit 9ab6ebc

Browse files
committed
WIP
1 parent 7988c2a commit 9ab6ebc

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed

.github/workflows/fetch_and_log.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,21 @@ jobs:
2424
- name: Fetch Unprocessed Workflow Runs
2525
id: fetch-unprocessed-run-ids
2626
run: |
27-
# TODO: We need to address an important issue where workflow runs that are currently in progress may be included.
28-
# These should be excluded from processing, and we should revisit them in the next run once they have finished.
29-
WORKFLOW_IDS=$(gh run list --repo $GITHUB_REPOSITORY --limit 100 --json databaseId,createdAt,displayTitle --jq "[.[] | select(.databaseId > $LAST_PROCESSED_RUN_ID and .displayTitle != \"Fetch and Log Workflow Runs\")] | sort_by(.databaseId) | [.[].databaseId] | @json")
27+
# This script ensures that only completed GitHub workflow runs are processed while avoiding workflows that are still in progress.
28+
# Steps:
29+
# 1. Fetch the latest workflow runs from GitHub, sorted by databaseId.
30+
# 2. Identify the oldest incomplete workflow (first one still running).
31+
# 3. Return an array of workflow IDs up to (but not including) the oldest incomplete workflow ID.
32+
WORKFLOW_DATA=$(gh run list --repo $GITHUB_REPOSITORY --limit 100 --json databaseId,createdAt,displayTitle,status --jq "[.[] | select(.databaseId > $LAST_PROCESSED_RUN_ID and .displayTitle != \"Fetch and Log Workflow Runs\")] | sort_by(.databaseId)")
33+
34+
OLDEST_INCOMPLETE_ID=$(echo "$WORKFLOW_DATA" | jq '[.[] | select(.status != "completed") | .databaseId] | min // empty')
35+
36+
if [[ -n "$OLDEST_INCOMPLETE_ID" ]]; then
37+
WORKFLOW_IDS=$(echo "$WORKFLOW_DATA" | jq "[.[] | select(.status == \"completed\" and .databaseId < $OLDEST_INCOMPLETE_ID)] | [.[].databaseId] | @json")
38+
else
39+
WORKFLOW_IDS=$(echo "$WORKFLOW_DATA" | jq "[.[] | select(.status == \"completed\")] | [.[].databaseId] | @json")
40+
fi
41+
3042
echo "Workflow runs to process: $WORKFLOW_IDS"
3143
echo "workflow_ids=$WORKFLOW_IDS" >> $GITHUB_OUTPUT
3244
env:

.github/workflows/validate.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
on:
3+
pull_request:
4+
types: [synchronize, opened, reopened, labeled]
5+
6+
permissions:
7+
pull-requests: write
8+
9+
jobs:
10+
multiple-labels:
11+
name: 'Check that only one validation label is applied'
12+
if: >
13+
(contains(github.event.pull_request.labels.*.name, 'run-full-validation') && contains(github.event.pull_request.labels.*.name, 'run-full-validation-long')) ||
14+
(contains(github.event.pull_request.labels.*.name, 'run-full-validation') && contains(github.event.pull_request.labels.*.name, 'run-quick-validation')) ||
15+
(contains(github.event.pull_request.labels.*.name, 'run-full-validation-long') && contains(github.event.pull_request.labels.*.name, 'run-quick-validation'))
16+
runs-on: ubuntu-latest
17+
steps:
18+
- run: |
19+
echo "Multiple validation labels detected. Exiting."
20+
exit 1
21+
22+
validate:
23+
name: 'Validate Changed Packages - Github Hosted'
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
28+
- name: Run Validation Script
29+
run: |
30+
echo "Running validation because 'full validation' label was added"
31+
# Add your validation logic here (e.g., linting, testing)
32+
33+
sleep 30
34+
exit 0
35+
36+
- name: 'Remove label'
37+
run: |
38+
curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
39+
-H "Accept: application/vnd.github.v3+json" \
40+
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/run-full-validation"
41+
42+

0 commit comments

Comments
 (0)