Skip to content

Commit 57ed861

Browse files
authored
ci: make ci work with larger matrixes (#1204)
* ci: make ci work with larger matrixes * no anchor support :( * whopps * hmm * more * compact
1 parent 7acd331 commit 57ed861

File tree

2 files changed

+59
-21
lines changed

2 files changed

+59
-21
lines changed

.github/scripts/changed_apps.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,35 @@ def find_test_files(changed_files):
6262
print("Skipped apps based on the EXCLUDE_TESTS list:", file=sys.stderr)
6363
print("\n".join(skipped), file=sys.stderr)
6464

65-
if len(matrix) > 256:
66-
print(f"Github Actions has a limit of 256 matrix jobs. Cannot run [{len(matrix)}] tests.", file=sys.stderr)
67-
sys.exit(1)
65+
result = {
66+
"matrix1": {"include": matrix[:256]},
67+
"matrix2": {"include": matrix[256:]},
68+
}
6869

69-
return matrix
70+
return json.dumps(result)
7071

7172

7273
def main():
7374
changed_files = get_changed_files()
74-
matrix = find_test_files(changed_files)
75+
print(find_test_files(changed_files))
7576
# This should look like:
7677
# {
77-
# "include": [
78-
# { "train": "enterprise", "app": "minio", "test_file": "basic-values.yaml" },
79-
# { "train": "enterprise", "app": "minio", "test_file": "https-values.yaml" },
80-
# ...
81-
# ]
78+
# "matrix1": {
79+
# "include": [
80+
# { "train": "enterprise", "app": "minio", "test_file": "basic-values.yaml" },
81+
# { "train": "enterprise", "app": "minio", "test_file": "https-values.yaml" },
82+
# ...
83+
# ]
84+
# },
85+
# "matrix2": {
86+
# "include": [
87+
# { "train": "enterprise", "app": "minio", "test_file": "basic-values.yaml" },
88+
# { "train": "enterprise", "app": "minio", "test_file": "https-values.yaml" },
89+
# ...
90+
# ]
91+
# }
8292
# }
8393

84-
print(json.dumps({"include": matrix}))
85-
8694

8795
if __name__ == "__main__":
8896
main()

.github/workflows/app-test-suite.yaml

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ jobs:
88
name: Generate matrix
99
runs-on: ubuntu-latest
1010
outputs:
11-
changed-apps: ${{ steps.changed-apps.outputs.changed-apps }}
12-
change-count: ${{ steps.changed-apps.outputs.change-count }}
11+
changed-apps-1: ${{ steps.changed-apps.outputs.changed-apps-1 }}
12+
change-count-1: ${{ steps.changed-apps.outputs.change-count-1 }}
13+
changed-apps-2: ${{ steps.changed-apps.outputs.changed-apps-2 }}
14+
change-count-2: ${{ steps.changed-apps.outputs.change-count-2 }}
1315
steps:
1416
- name: Checkout
1517
uses: actions/checkout@v4
@@ -30,8 +32,11 @@ jobs:
3032
id: changed-apps
3133
run: |
3234
out=$(python3 .github/scripts/changed_apps.py)
33-
echo "changed-apps=${out}" >> $GITHUB_OUTPUT
34-
echo "change-count=$(echo "${out}" | jq -r '.include | length')" >> $GITHUB_OUTPUT
35+
echo "changed-apps-1=$(echo "${out}" | jq -cr '.matrix1')" >> $GITHUB_OUTPUT
36+
echo "changed-apps-2=$(echo "${out}" | jq -cr '.matrix2')" >> $GITHUB_OUTPUT
37+
38+
echo "change-count-1=$(echo "${out}" | jq -cr '.matrix1.include | length')" >> $GITHUB_OUTPUT
39+
echo "change-count-2=$(echo "${out}" | jq -cr '.matrix2.include | length')" >> $GITHUB_OUTPUT
3540
3641
- name: Message Generation
3742
id: message
@@ -50,15 +55,40 @@ jobs:
5055
comment-tag: notify-teams
5156
file-path: pr-comment.txt
5257

53-
run-apps:
54-
name: Run Docker Compose Render/Install
58+
run-apps-matrix-1:
59+
name: Run Docker Compose Render/Install (Matrix 1)
60+
needs: changed-files
61+
runs-on: ubuntu-latest
62+
if: needs.changed-files.outputs.change-count-1 > 0
63+
strategy:
64+
matrix: ${{ fromJson(needs.changed-files.outputs.changed-apps-1) }}
65+
fail-fast: false
66+
max-parallel: 20
67+
steps:
68+
- name: Environment Information
69+
run: |
70+
echo "====== Docker Info ======"
71+
docker info
72+
echo "========================="
73+
74+
- name: Checkout
75+
uses: actions/checkout@v4
76+
77+
- name: Test
78+
shell: bash
79+
run: |
80+
echo "Testing [${{matrix.train}}/${{matrix.app}}/templates/test_values/${{matrix.test_file}}]"
81+
python3 ./.github/scripts/ci.py --train ${{matrix.train}} --app ${{matrix.app}} --test-file ${{matrix.test_file}}
82+
83+
run-apps-matrix-2:
84+
name: Run Docker Compose Render/Install (Matrix 2)
5585
needs: changed-files
5686
runs-on: ubuntu-latest
57-
if: needs.changed-files.outputs.change-count > 0
87+
if: needs.changed-files.outputs.change-count-2 > 0
5888
strategy:
59-
matrix: ${{ fromJson(needs.changed-files.outputs.changed-apps) }}
89+
matrix: ${{ fromJson(needs.changed-files.outputs.changed-apps-2) }}
6090
fail-fast: false
61-
max-parallel: 10
91+
max-parallel: 20
6292
steps:
6393
- name: Environment Information
6494
run: |

0 commit comments

Comments
 (0)