Skip to content

Commit 8f0370e

Browse files
committed
Test: add result check.
1 parent 9e67795 commit 8f0370e

3 files changed

Lines changed: 28 additions & 11 deletions

File tree

.github/workflows/evaluate-artifacts-backend.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,16 @@ jobs:
6767

6868
- name: Run tests and save results
6969
id: run-tests
70+
# continue-on-error ensures the job doesn’t stop here even if tests fail
71+
continue-on-error: true
7072
run: |
71-
cat filtered_files.txt | main/build/test/ghaction -b -d ${{ env.TESTDATA_DIR }} \
72-
--sha "${{ github.sha }}" \
73-
--report "test_report.md"
73+
set -o pipefail
74+
cat filtered_files.txt \
75+
| main/build/test/ghaction -b -d ${{ env.TESTDATA_DIR }} \
76+
--sha "${{ github.sha }}" \
77+
--report "test_report.md"
78+
EXIT_CODE=$?
79+
echo "exit_code=${EXIT_CODE}" >> $GITHUB_OUTPUT
7480
7581
- name: Checkout test-result branch
7682
uses: actions/checkout@v4
@@ -104,6 +110,11 @@ jobs:
104110
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
105111
106112
git add README.md
107-
git commit -m "Add test results for artifacts commit ${{ github.sha }}"
108-
109-
git push origin ${{ env.TEST_RESULT_BRANCH }}
113+
git commit -m "Add test results for artifacts commit ${{ github.sha }}" || echo "Nothing to commit"
114+
git push origin ${{ env.TEST_RESULT_BRANCH }}
115+
116+
- name: Fail if tests failed
117+
if: steps.run-tests.outputs.exit_code != '0'
118+
run: |
119+
echo "🛑 ghaction exited with code ${{ steps.run-tests.outputs.exit_code }}. Failing job."
120+
exit ${{ steps.run-tests.outputs.exit_code }}

test/ghaction.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,14 @@ int main(int argc, char *argv[]) {
279279
};
280280
report << "- **Artifacts Commit:** " << (commit_sha.empty() ? "N/A" : build_md_url(commit_sha)) << "\n";
281281
report << "- **Total Tests:** " << entries.size() << "\n";
282-
report << "- **Mode:** " << (only_frontend ? "Frontend only" : "With backend") << "\n\n";
282+
report << "- **Mode:** " << (only_frontend ? "Frontend only" : "With backend") << "\n";
283+
284+
size_t passed = std::count_if(results.begin(), results.end(), [](const auto& tres) {
285+
return tres.passed;
286+
});
287+
288+
report << "- **Result: ** " << (passed == entries.size() ? "✅ PASSED" : "❌ FAILED") << "\n\n";
283289

284-
size_t passed = 0;
285290
std::vector<std::string> failed_tests;
286291
for (const auto& tres : results) {
287292
report << "#### Test: " << tres.id << "\n";
@@ -290,7 +295,6 @@ int main(int argc, char *argv[]) {
290295
report << "- **Status:** ";
291296

292297
if (tres.passed) {
293-
++passed;
294298
report << "✅ PASSED\n";
295299
} else {
296300
failed_tests.push_back(tres.id);
@@ -318,5 +322,9 @@ int main(int argc, char *argv[]) {
318322
report << "| **Total** | **" << entries.size() << "** |\n";
319323

320324
report.close();
325+
326+
if (!failed_tests.empty())
327+
return -1;
328+
321329
return 0;
322330
}

test/include/runner.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ static CheckResult check_ir_or_bin(const CheckIRBinData &data, bool only_run_fro
137137
// Not the one in sh or bash.
138138
exec_command += R"(;/bin/echo -e "\n"$? >> )" + output;
139139

140-
println("| Running execute command: '{}'", exec_command);
141-
142140
if (std::system(exec_command.c_str()) != 0)
143141
return {"exec error", "", 0};
144142

0 commit comments

Comments
 (0)