@@ -59,31 +59,72 @@ jobs:
59
59
with :
60
60
sarif_file : ' trivy-results.sarif'
61
61
62
+ e2e-tests-discovery :
63
+ runs-on : ubuntu-latest
64
+ outputs :
65
+ matrix : ${{ steps.set-matrix.outputs.matrix }}
66
+ steps :
67
+ - name : Checkout code
68
+ uses : actions/checkout@v3
69
+ - id : set-matrix
70
+ name : Discover E2E tests
71
+ run : |
72
+ log_content() {
73
+ local content="$1"
74
+ local label="${2:-}"
75
+
76
+ if [[ -n "$label" ]]; then
77
+ # Replace the beginning of each line with two spaces
78
+ local indented_content="${content//$'\n'/$'\n' }"
79
+ printf "%s:\n %s\n" "$label" "$indented_content"
80
+ else
81
+ echo "$content"
82
+ fi
83
+ }
84
+
85
+ log_output() {
86
+ echo ::group::Set outputs
87
+ log_content "$(cat "$GITHUB_OUTPUT")" "GITHUB_OUTPUT"
88
+ log_content "$(cat "$GITHUB_ENV")" "GITHUB_ENV"
89
+ echo ::endgroup::
90
+ }
91
+
92
+ set_output() {
93
+ local value="$1"
94
+ local output_key="$2"
95
+ local env_key="${3:-}"
96
+
97
+ if [ -z "$value" ] || [ -z "$output_key" ]; then
98
+ echo "Missing essential arguments to set_output_and_env"
99
+ return 1
100
+ fi
101
+
102
+ # If env_key is empty, convert output_key to upper snake case
103
+ if [ -z "$env_key" ]; then
104
+ env_key=$(echo "$output_key" | awk '{print toupper($0)}' | sed 's/-/_/g')
105
+ fi
106
+
107
+ echo "$output_key=$value" >> "$GITHUB_OUTPUT"
108
+ echo "$env_key=$value" >> "$GITHUB_ENV"
109
+ }
110
+ set_output "{\"include\":$(jq -c '[.[]]' test/e2e_tests.json)}" "matrix"
111
+ log_output
112
+
62
113
e2e-tests :
63
- needs : [ build ]
114
+ needs : [ build, e2e-tests-discovery ]
64
115
strategy :
65
116
fail-fast : false
66
- matrix :
67
- data :
68
- - name : " return"
69
- script : |
70
- "return"
71
- expected : " return"
72
-
73
- - name : " context"
74
- script : |
75
- Map.keys(context)
76
- expected : " [__struct__,action,actor,api_url,event_name,graphql_url,job,payload,ref,run_id,run_number,server_url,sha,workflow]"
117
+ matrix : ${{fromJson(needs.e2e-tests-discovery.outputs.matrix)}}
77
118
runs-on : ubuntu-latest
78
- name : " e2e tests (${{ matrix.data. name }})"
119
+ name : " e2e tests (${{ matrix.name }})"
79
120
steps :
80
121
- uses : actions/checkout@v3
81
122
- uses : ./.github/actions/load-tar-image
82
123
- uses : ./.github/actions/run-e2e
83
124
with :
84
125
image-name : ${{ env.IMAGE_NAME }}
85
- script : ${{ matrix.data. script }}
86
- expected : ${{ matrix.data. expected }}
126
+ script : ${{ matrix.script }}
127
+ expected : ${{ matrix.expected }}
87
128
88
129
push :
89
130
needs : [ version, build, e2e-tests, vulnerability-scanner ]
0 commit comments