Skip to content

Commit 6b51e3b

Browse files
Merge pull request #134 from LedgerHQ/fbe/fix_double_pytest_dir_issue
Rework fetch_metadata job to handle multiple pytest dir
2 parents 5ab7ed0 + a23167d commit 6b51e3b

File tree

3 files changed

+62
-25
lines changed

3 files changed

+62
-25
lines changed

.github/workflows/_get_test_metadata.yml

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -53,44 +53,58 @@ jobs:
5353
- name: Gather application metadata, from inputs or 'ledger_app.toml'
5454
id: fetch_metadata
5555
run: |
56-
if [ ! -f "$APP_MANIFEST" ];
57-
then
56+
# Fail if manifest file is missing
57+
if [ ! -f "$APP_MANIFEST" ]; then
5858
>&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"
6161
exit 1
6262
fi
6363
64-
# 'ledger_app.toml' exists
6564
echo "Manifest detected."
66-
# checking the manifest with the repo
6765
ledger-manifest --check . "$APP_MANIFEST"
6866
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
8482
break
8583
fi
8684
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+
8790
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
89101
fi
90-
echo "pytest_directory=${pytest_directory}" >> "$GITHUB_OUTPUT"
91102
103+
# Set output for downstream steps or workflows
104+
echo "pytest_directory=${pytest_directory}" >> "$GITHUB_OUTPUT"
92105
echo "Inferred test metadata:"
93106
cat "$GITHUB_OUTPUT"
94107
108+
95109
outputs:
96110
pytest_directory: ${{ steps.fetch_metadata.outputs.pytest_directory }}

.github/workflows/end_to_end_tests_of_reusable_workflows.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,17 @@ jobs:
159159
app_repository: LedgerHQ/app-boilerplate
160160
app_branch_name: master
161161
download_app_binaries_artifact: "boilerplate_binaries"
162+
test_dir: "tests/standalone"
163+
164+
ragger_swap_tests_boilerplate:
165+
name: Run boilerplate swap tests
166+
needs: build_boilerplate_application
167+
uses: ./.github/workflows/reusable_swap_tests.yml
168+
with:
169+
app_repository: LedgerHQ/app-boilerplate
170+
app_branch_name: master
171+
download_app_binaries_artifact: "boilerplate_binaries"
172+
swap_test_dir: "tests/swap"
162173

163174
build_nanos_boilerplate_application:
164175
name: Build boilerplate for Nano S

.github/workflows/reusable_swap_tests.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@ name: Run Swap Functional tests
33
on:
44
workflow_call:
55
inputs:
6-
app_build_artifact:
6+
app_repository:
7+
description: 'The GIT repository to test (defaults to `github.repository`)'
8+
required: false
9+
default: ${{ github.repository }}
10+
type: string
11+
app_branch_name:
12+
description: 'The GIT branch to test (defaults to `github.ref`)'
13+
required: false
14+
default: ${{ github.ref }}
15+
type: string
16+
download_app_binaries_artifact:
717
required: true
818
type: string
919
exchange_build_artifact:
@@ -110,7 +120,9 @@ jobs:
110120
needs: [get_artifacts_names, get_dir_names]
111121
uses: ./.github/workflows/reusable_ragger_tests.yml
112122
with:
113-
download_app_binaries_artifact: ${{ inputs.app_build_artifact }}
123+
app_repository: ${{ inputs.app_repository }}
124+
app_branch_name: ${{ inputs.app_branch_name }}
125+
download_app_binaries_artifact: ${{ inputs.download_app_binaries_artifact }}
114126
additional_app_binaries_artifact: ${{ needs.get_artifacts_names.outputs.exchange_build_artifact }}
115127
additional_app_binaries_artifact_dir: ${{ needs.get_dir_names.outputs.main_app_dir }}
116128
lib_binaries_artifact: ${{ needs.get_artifacts_names.outputs.ethereum_build_artifact }}

0 commit comments

Comments
 (0)