-
Notifications
You must be signed in to change notification settings - Fork 1
77 lines (72 loc) · 2.27 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Merge group tests
on:
merge_group:
pull_request:
jobs:
changes:
runs-on: ubuntu-latest
outputs:
jobs: ${{ steps.set-jobs.outputs.jobs }}
steps:
- id: set-jobs
run: |
echo 'jobs=["changes","test-ref-merge","test-ref-matrix"]' >> "$GITHUB_OUTPUT"
test-ref-merge:
runs-on: ubuntu-latest
if: github.event_name == 'merge_group'
steps:
- uses: actions/checkout@v4
- name: Print branch names
run: |
echo "Head ref: ${{ github.event.merge_group.head_ref }}"
echo "Base ref: ${{ github.event.merge_group.base_ref }}"
- uses: actions/checkout@v4
with:
ref: ${{ github.event.merge_group.base_ref }}
test-ref-pr:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Print branch name
run: |
echo "Base ref: ${{ github.base_ref }}"
check-job-results:
if: always()
needs: fromJSON(jobs.changes.outputs.jobs)
runs-on: ubuntu-latest
steps:
# - name: Check job results
# id: check-results
# run: |
# # Convert JSON array to Bash array
# mapfile -t job_names < <(echo '${{ fromJson(needs.changes.outputs.jobs) }}')
#
# # Create associative array of job results
# declare -A job_results
# for job in "${job_names[@]}"; do
# job_results["$job"]=$(eval echo "\${{ needs.changes.${job}.result }}")
# done
#
# # Iterate through jobs and get their results
# failed_count=0
# for job in "${!job_results[@]}"; do
# RESULT=${job_results[$job]}
# if [[ "$RESULT" == "failure" ]]; then
# failed_count=$((failed_count + 1))
# fi
# echo "$job result: $RESULT"
# done
#
# if [ "$failed_count" -gt 0 ]; then
# echo "Some jobs failed"
# echo "result=failure" | tee -a $GITHUB_OUTPUT
# else
# echo "All jobs succeeded or were skipped"
# echo "result=success" | tee -a $GITHUB_OUTPUT
# fi
- name: Error on job failure
run: |
if [[ "${{ steps.check-results.outputs.result }}" == "failure" ]]; then
exit 1
fi