@@ -53,44 +53,58 @@ jobs:
53
53
- name : Gather application metadata, from inputs or 'ledger_app.toml'
54
54
id : fetch_metadata
55
55
run : |
56
- if [ ! -f "$APP_MANIFEST" ];
57
- then
56
+ # Fail if manifest file is missing
57
+ if [ ! -f "$APP_MANIFEST" ]; then
58
58
>&2 echo "/!\ No $APP_MANIFEST manifest detected!"
59
- >&2 echo "This file is mandatory, please add it on your repository"
60
- >&2 echo "Documentation here : https://github.com/LedgerHQ/ledgered/blob/master/doc/utils/manifest.md"
59
+ >&2 echo "This file is mandatory, please add it to your repository"
60
+ >&2 echo "Documentation: https://github.com/LedgerHQ/ledgered/blob/master/doc/utils/manifest.md"
61
61
exit 1
62
62
fi
63
63
64
- # 'ledger_app.toml' exists
65
64
echo "Manifest detected."
66
- # checking the manifest with the repo
67
65
ledger-manifest --check . "$APP_MANIFEST"
68
66
69
- set +e
70
- temp ="$(ledger-manifest --output-tests-pytest-directory "$APP_MANIFEST") "
71
- status=$?
72
- set -e
73
- # catch the error if the manifest does not contain the pytest_directory
74
- if [ $status -ne 0 ]; then
75
- >&2 echo "This is a v2 manifest"
76
- pytest_directory=""
77
- temp ="$(ledger-manifest --output-pytest-directories -j -- "$APP_MANIFEST")"
78
- for dir in $ (echo "$temp " | jq -r '.pytest_directories[]'); do
79
- echo "Found in Manifest pytest directory: $dir"
80
- echo "Searching for '${{ inputs.pytest_directory }}'"
81
- # if the dir is the same as input.pytest_directory, we keep it
82
- if [ "$dir" = "${{ inputs.pytest_directory }} " ]; then
83
- pytest_directory="$dir"
67
+ # Read the input directory from caller
68
+ input_pytest_dir ="${{ inputs.pytest_directory }} "
69
+
70
+ if [ "$input_pytest_dir" != "None" ]; then
71
+ # Use the provided input as-is
72
+ pytest_directory="$input_pytest_dir"
73
+
74
+ # Check if it's listed in the manifest
75
+ manifest_json ="$(ledger-manifest --output-pytest-directories -j -- "$APP_MANIFEST")"
76
+ mapfile -t manifest_dirs < < (echo "$manifest_json " | jq -r '.pytest_directories[]')
77
+
78
+ found=0
79
+ for dir in "${manifest_dirs[@]}"; do
80
+ if [ "$dir" = "$input_pytest_dir " ]; then
81
+ found=1
84
82
break
85
83
fi
86
84
done
85
+
86
+ if [ "$found" -ne 1 ]; then
87
+ >&2 echo "::warning::Provided pytest_directory '$input_pytest_dir' not found in manifest. Proceeding anyway."
88
+ fi
89
+
87
90
else
88
- pytest_directory="${temp}"
91
+ # No input: try to infer the directory using legacy logic
92
+ set +e
93
+ pytest_directory="$(ledger-manifest --output-tests-pytest-directory "$APP_MANIFEST")"
94
+ status=$?
95
+ set -e
96
+
97
+ if [ "$status" -ne 0 ]; then
98
+ >&2 echo "Error: Could not infer pytest_directory automatically. Multiple or missing entries in manifest."
99
+ exit 1
100
+ fi
89
101
fi
90
- echo "pytest_directory=${pytest_directory}" >> "$GITHUB_OUTPUT"
91
102
103
+ # Set output for downstream steps or workflows
104
+ echo "pytest_directory=${pytest_directory}" >> "$GITHUB_OUTPUT"
92
105
echo "Inferred test metadata:"
93
106
cat "$GITHUB_OUTPUT"
94
107
108
+
95
109
outputs :
96
110
pytest_directory : ${{ steps.fetch_metadata.outputs.pytest_directory }}
0 commit comments