-
Notifications
You must be signed in to change notification settings - Fork 13
167 lines (144 loc) · 5.41 KB
/
Copy pathplanner.yml
File metadata and controls
167 lines (144 loc) · 5.41 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Planner
on:
pull_request:
types: [opened, labeled, unlabeled, reopened, synchronize, ready_for_review]
workflow_dispatch:
concurrency:
group: planner-${{ github.ref }}
cancel-in-progress: true
jobs:
generate-matrix:
runs-on: ubuntu-latest
# Skip this job (and subsequently all other planner jobs) if the PR has the `skip-ci` label
if: |
! contains(github.event.pull_request.labels.*.name, 'skip-ci')
permissions:
contents: read
id-token: write
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
repositories: ${{ steps.repo-matrix.outputs.repositories }}
artifacts: ${{ steps.generate.outputs.artifacts }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
- name: Compute diff refs
id: compute-refs
run: |
set -e
BASE_SHA=${{ github.event.pull_request.base.sha }}
HEAD_SHA=${{ github.event.after || github.event.pull_request.head.sha }}
# Ensure we have both the base and head commits
git fetch --depth=1 origin $BASE_SHA
git fetch --depth=1 origin $HEAD_SHA
echo "BASE_SHA=$BASE_SHA" >> $GITHUB_ENV
echo "HEAD_SHA=$HEAD_SHA" >> $GITHUB_ENV
echo "Diff will compare main ($BASE_SHA) with $HEAD_SHA"
- name: Generate repository matrix
id: repo-matrix
uses: ./.github/actions/generate-repo-matrix
with:
repoRoot: "."
- name: Build changed project matrix
id: generate
run: |
set -e
# Get repository names and check for changes
repositories_json='${{ steps.repo-matrix.outputs.repositories }}'
changed_repos=()
# Check each repository for changes
while IFS= read -r repo; do
if git diff --name-only $BASE_SHA $HEAD_SHA | grep "^$repo/" > /dev/null 2>&1; then
changed_repos+=("$repo")
fi
done < <(echo "$repositories_json" | jq -r 'keys[]')
if [ ${#changed_repos[@]} -eq 0 ]; then
echo "No changes detected for any project"
echo "matrix=" >> $GITHUB_OUTPUT
echo "artifacts={}" >> $GITHUB_OUTPUT
else
# Convert changed repos array to JSON
changed_repos_json=$(printf '%s\n' "${changed_repos[@]}" | jq -R . | jq -s .)
matrixJson=$(echo "$changed_repos_json" | jq -c '{"repo": .}')
# Generate artifacts JSON with workspace prefix
artifacts_json=$(echo "$repositories_json" | jq -c \
--argjson changed_repos "$changed_repos_json" \
--arg workspace "${{ github.workspace }}" \
'to_entries |
map(select(.key as $repo | $changed_repos | index($repo) != null)) |
from_entries |
with_entries(.key as $repo | .value = (.value["e2e-artifacts"] | map($workspace + "/" + $repo + "/" + .) | join("\n")))')
echo "matrix=$matrixJson" >> $GITHUB_OUTPUT
echo "artifacts=$artifacts_json" >> $GITHUB_OUTPUT
fi
echo "Matrix: $matrixJson"
echo "Artifacts: $artifacts_json"
extract-label-filter:
name: extract-label-filter
needs: generate-matrix
runs-on: ubuntu-latest
outputs:
ginkgoLabelFilter: ${{ steps.extract-label-filter.outputs.ginkgoLabelFilter }}
steps:
- name: Extract label filter
id: extract-label-filter
run: |
set -e
# Find labels that start with 'ginkgo-filter:'
LABELS="${{ join(github.event.pull_request.labels.*.name, ',') }}"
# Array to collect all filters
FILTERS=()
# Extract all ginkgo filters
for label in $(echo $LABELS | tr ',' '\n'); do
if [[ $label == ginkgo-filter:* ]]; then
# Extract the filter part after the prefix
FILTER="${label#ginkgo-filter:}"
echo "Found Ginkgo filter in label: $FILTER"
FILTERS+=("$FILTER")
fi
done
# If we have filters, combine them with OR operator
if [ ${#FILTERS[@]} -gt 0 ]; then
COMBINED_FILTER=""
# OR each filter
for i in "${!FILTERS[@]}"; do
if [ $i -eq 0 ]; then
COMBINED_FILTER="(${FILTERS[$i]})"
else
COMBINED_FILTER="$COMBINED_FILTER||(${FILTERS[$i]})"
fi
done
echo "Final ginkgo label filter: $COMBINED_FILTER"
echo "ginkgoLabelFilter=$COMBINED_FILTER" >> $GITHUB_OUTPUT
fi
call-test:
name: test
needs: generate-matrix
if: |
needs.generate-matrix.outputs.matrix != ''
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
uses: ./.github/workflows/test.yml
with:
repo: ${{ matrix.repo }}
secrets: inherit
call-e2e:
name: e2e
needs:
- generate-matrix
- extract-label-filter
if: |
needs.generate-matrix.outputs.matrix != ''
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
uses: ./.github/workflows/e2e.yml
with:
repo: ${{ matrix.repo }}
artifacts: ${{ fromJson(needs.generate-matrix.outputs.artifacts)[matrix.repo] }}
ginkgoLabelFilter: ${{ needs.extract-label-filter.outputs.ginkgoLabelFilter }}
secrets: inherit