-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check to keep releases.json in sync with the firmware binaries
- Loading branch information
1 parent
7be70f9
commit c551820
Showing
7 changed files
with
118 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: "[Check]: Shell validation" | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- "**.sh" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
shellcheck: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: shellcheck | ||
run: ./scripts/shellcheck.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env bash | ||
|
||
PARENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit ; pwd -P ) | ||
|
||
GREEN='\033[0;32m' | ||
RED='\033[0;31m' | ||
NC='\033[0m' # No Color | ||
|
||
if [[ $# -ne 1 ]] | ||
then | ||
echo "must provide 1 argument. $# provided" | ||
exit 1 | ||
fi | ||
|
||
DEVICE=$1 | ||
|
||
extract_filenames_from_json() { | ||
local json_file="$1" | ||
jq -r '.[] | select(.url) | .url, .url_bitcoinonly' "$json_file" | xargs -n 1 basename | sort | uniq \ | ||
| grep -v "null" # filter out null from missing .url_bitcoinonly for older firmwares | ||
} | ||
|
||
list_files_in_directory() { | ||
local dir="$1" | ||
find "$dir" -type f -name "*.bin" -exec basename {} \; | sort \ | ||
| grep -v "trezor-inter-" | grep -v "trezor-t1tb-inter-" # filer out Intermediary firmwares | ||
} | ||
|
||
compare_files() { | ||
local json_file="$1" | ||
local directory="$2" | ||
|
||
expected_files=$(extract_filenames_from_json "$json_file") | ||
actual_files=$(list_files_in_directory "$directory") | ||
|
||
missing_files=$(comm -23 <(echo "$expected_files") <(echo "$actual_files")) | ||
extra_files=$(comm -13 <(echo "$expected_files") <(echo "$actual_files")) | ||
|
||
if [[ -z "$missing_files" && -z "$extra_files" ]]; then | ||
echo -e "${GREEN}All files are present and accounted for.${NC}" | ||
else | ||
if [[ -n "$missing_files" ]]; then | ||
echo -e "${RED}Missing files:" | ||
echo "$missing_files" | awk '{print " " $0}' | ||
echo -e "${NC}" | ||
fi | ||
if [[ -n "$extra_files" ]]; then | ||
echo -e "${RED}Extra files in directory:" | ||
echo "$extra_files" | awk '{print " " $0}' | ||
echo -e "${NC}" | ||
fi | ||
|
||
exit 1 | ||
fi | ||
} | ||
|
||
json_file=$PARENT_PATH"/../firmware/"$DEVICE/"releases.json" | ||
directory=$PARENT_PATH"/../firmware/"$DEVICE | ||
|
||
echo "Checking directory: $directory" | ||
|
||
compare_files "$json_file" "$directory" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
DEVICE_PATHS=$(find firmware -maxdepth 1 -type d ! -name 'translations' ! -name 'README.md' ! -name 'firmware') | ||
|
||
for FILE in $DEVICE_PATHS; | ||
do | ||
DEVICE_MODEL=$(basename "$FILE") | ||
if ! ./scripts/check-firmware-presence-in-releases-json.sh "$DEVICE_MODEL" ; then | ||
exit 1 | ||
fi; | ||
|
||
echo | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -u | ||
set -x | ||
set -o pipefail | ||
|
||
shellcheck --version | ||
|
||
find . -type f -name '*.sh' -exec shellcheck {} + |