Skip to content

Commit 41c1140

Browse files
Daniel KampertDaniel Kampert
authored andcommitted
Fixes from CodeRabbit
1 parent 5e68ff6 commit 41c1140

File tree

9 files changed

+50
-44
lines changed

9 files changed

+50
-44
lines changed

.github/workflows/firmware.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ jobs:
5656
# It's output to GITHUB_ENV so it can be used in the next steps
5757
# and only needs to be calculated once.
5858
BUILD_DIR=${{ matrix.board }}_${{ matrix.built_type }}
59-
echo "BUILD_DIR=${BUILD_DIR}" | sed 's/\//_/g' >> "$GITHUB_ENV"
59+
echo "BUILD_DIR=${BUILD_DIR}" | sed 's/\//_/g' >> ""${GITHUB_ENV}""
6060
6161
- name: Build firmware
62+
env:
63+
BUILD_DIR: ${{ env.BUILD_DIR }}
6264
working-directory: BeeLight/firmware/app
6365
run: |
6466
set -e
@@ -68,7 +70,9 @@ jobs:
6870
if [ -z "$src_hex" ] && [ -f "${{ env.BUILD_DIR }}/zephyr/merged.hex" ]; then src_hex="${{ env.BUILD_DIR }}/zephyr/merged.hex"; fi
6971
if [ -n "$src_hex" ]; then cp "$src_hex" "fw_images/${{ matrix.built_type }}.hex"; else echo "merged.hex not found, skipping"; fi
7072
71-
- name : Upload Firmware
73+
- name: Upload Firmware
74+
env:
75+
BUILD_DIR: ${{ env.BUILD_DIR }}
7276
uses: actions/[email protected]
7377
with:
7478
name: ${{ env.BUILD_DIR }}

.github/workflows/pcb.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ jobs:
6262
last_tag="$(git describe --tags --abbrev=0 || echo "")"
6363
if [[ "${{ github.ref_type }}" == "tag" ]]; then
6464
echo "Overriding kibot_variant to 'RELEASED' for tag"
65-
echo "kibot_variant=RELEASED" >> $GITHUB_ENV
65+
echo "kibot_variant=RELEASED" >> "${GITHUB_ENV}"
6666
else
67-
echo "kibot_variant=${{ env.kibot_variant }}" >> $GITHUB_ENV
67+
echo "kibot_variant=${{ env.kibot_variant }}" >> "${GITHUB_ENV}"
6868
fi
6969
7070
- name: Download updated CHANGELOG
@@ -109,7 +109,7 @@ jobs:
109109
- name: Initialize
110110
run: |
111111
mkdir -p log
112-
echo "DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
112+
echo "DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> "${GITHUB_ENV}"
113113
114114
# Run these changelog update steps only on tag pushes
115115
- name: Pull latest changes for changelog update
@@ -125,7 +125,7 @@ jobs:
125125
shell: bash
126126
run: |
127127
git clone https://github.com/Kampi/KiCad.git kicad-library
128-
echo "KICAD_LIBRARY=$(pwd)/kicad-library" >> "$GITHUB_ENV"
128+
echo "KICAD_LIBRARY=$(pwd)/kicad-library" >> "${GITHUB_ENV}"
129129
pip install defusedxml --break-system-packages
130130
131131
- name: Extract release notes
@@ -163,10 +163,10 @@ jobs:
163163
if [[ "${{ github.ref_type }}" == "tag" ]]; then
164164
version_arg="-E REVISION='${last_tag}'"
165165
echo "Overriding kibot_variant to 'RELEASED' for tag"
166-
echo "kibot_variant=RELEASED" >> $GITHUB_ENV
166+
echo "kibot_variant=RELEASED" >> "${GITHUB_ENV}"
167167
else
168168
version_arg="-E REVISION='${last_tag} + (Unreleased)'"
169-
echo "kibot_variant=${{ env.kibot_variant }}" >> $GITHUB_ENV
169+
echo "kibot_variant=${{ env.kibot_variant }}" >> "${GITHUB_ENV}"
170170
fi
171171
172172
# Determine additional_args based on the variant
@@ -186,8 +186,8 @@ jobs:
186186
;;
187187
esac
188188
189-
echo "version_arg=${version_arg}" >> "$GITHUB_ENV"
190-
echo "additional_args=${additional_args}" >> "$GITHUB_ENV"
189+
echo "version_arg=${version_arg}" >> "${GITHUB_ENV}"
190+
echo "additional_args=${additional_args}" >> "${GITHUB_ENV}"
191191
192192
# Generate notes (skipped for DRAFT variant)
193193
- name: Generate notes
@@ -285,4 +285,4 @@ jobs:
285285
uses: stefanzweifel/git-auto-commit-action@v5
286286
with:
287287
branch: ${{ github.ref_name }}
288-
commit_message: Push outputs from CI/CD (${{ env.DATE }})
288+
commit_message: Push outputs from CI/CD (${{ github.event.head_commit.timestamp }})

.github/workflows/zigbee.yaml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: Zigbee-Config
33
on:
44
workflow_dispatch:
55

6+
env:
7+
root_dir: BeeLight
8+
69
jobs:
710
build:
811
runs-on: ubuntu-24.04
@@ -12,23 +15,19 @@ jobs:
1215
- name: Checkout
1316
uses: actions/checkout@v4
1417
with:
15-
path: BeeLight
18+
path: ${{ env.root_dir }}
1619

1720
- name: Dependencies
18-
working-directory: BeeLight/firmware/app
21+
working-directory: ${{ env.root_dir }}/firmware/app
1922
run: |
2023
apt-get update && apt-get install -y curl
2124
curl https://files.nordicsemi.com/artifactory/swtools/external/nrfutil/executables/x86_64-unknown-linux-gnu/nrfutil -o nrfutil
22-
23-
- name: Setup
24-
working-directory: BeeLight/firmware/app
25-
run: |
2625
mkdir -p zigbee
2726
chmod +x nrfutil
28-
./nrfutil install nrf5sdk-tools==8.1.0
27+
./nrfutil install nrf5sdk-tools=8.1.0
2928
3029
- name: Generate
31-
working-directory: BeeLight/firmware/app
30+
working-directory: ${{ env.root_dir }}/firmware/app
3231
run: |
3332
./nrfutil nrf5sdk-tools zigbee production_config zigbee_config.yml zigbee/zigbee_config.hex --offset 0x17a000
3433
@@ -37,5 +36,5 @@ jobs:
3736
with:
3837
name: zigbee-config
3938
path: |
40-
BeeLight/firmware/app/zigbee
39+
${{ env.root_dir }}/firmware/app/zigbee
4140
if-no-files-found: ignore

firmware/app/scripts/astyle_format_west_command.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import os
77
import sys
8+
import shutil
89
import subprocess
910

1011
from west.commands import WestCommand
@@ -32,6 +33,9 @@ def do_add_parser(self, parser_adder):
3233

3334
def do_run(self, args, _unknown_args):
3435
astyle_args = ["astyle"]
36+
if(shutil.which("astyle") is None):
37+
print("ERROR: 'astyle' not found in PATH", file = sys.stderr)
38+
return 127
3539

3640
if(args.dry_run):
3741
astyle_args.append("--dry-run")

hardware/BeeLight.kicad_pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@
466466
"single_global_label": "ignore",
467467
"unannotated": "error",
468468
"unconnected_wire_endpoint": "warning",
469+
"undefined_netclass": "error",
469470
"unit_value_mismatch": "error",
470471
"unresolved_variable": "error",
471472
"wire_dangling": "error"

hardware/kibot_resources/scripts/docker_kibot_linux.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ docker run --rm -it \
1717
--volume="/home/$USER_NAME:/home/$USER_NAME:rw" \
1818
--entrypoint /bin/bash \
1919
"$IMAGE" -c "
20-
if ! id $USER_NAME &>/dev/null; then
21-
echo \"Creating user $USER_NAME ($USER_ID:$GROUP_ID)...\"
22-
useradd -u $USER_ID -g $GROUP_ID -d /home/$USER_NAME -m $USER_NAME
23-
chown -R $USER_ID:$GROUP_ID /home/$USER_NAME
20+
if ! id '$USER_NAME' >/dev/null 2>&1; then
21+
echo \"Creating user '$USER_NAME' ('$USER_ID':'$GROUP_ID')...\"
22+
useradd -u '$USER_ID' -g '$GROUP_ID' -d '/home/$USER_NAME' -m '$USER_NAME'
23+
chown -R '$USER_ID':'$GROUP_ID' '/home/$USER_NAME'
2424
fi
25-
exec su - $USER_NAME"
25+
exec su - '$USER_NAME'"

hardware/kibot_resources/scripts/get_changelog.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import argparse
21
import re
32
import sys
3+
import argparse
44

55
def parse_changelog(file_path, version, title_only, extra_spaces, separators):
66
try:
7-
with open(file_path, 'r') as f:
7+
with open(file_path, "r") as f:
88
changelog = f.read()
99
except FileNotFoundError:
1010
print(f"Error: File '{file_path}' not found.")
@@ -14,22 +14,21 @@ def parse_changelog(file_path, version, title_only, extra_spaces, separators):
1414
version_pattern = re.compile(rf"## \[{version}\] - (\d{{4}}-\d{{2}}-\d{{2}})\n(.*?)(?=## \[|\[Unreleased\]:|\[\d+\.\d+\.\d+\]:|$)", re.DOTALL)
1515
match = version_pattern.search(changelog)
1616

17-
if not match:
17+
if(not match):
1818
print(f"Version {version} not found.")
19-
sys.exit(1)
19+
return
2020

2121
date, content = match.groups()
2222

23-
if title_only:
23+
if(title_only):
2424
print(f"Version {version} - {date}")
2525
else:
26-
27-
if separators is not None:
26+
if(separators is not None):
2827
content = re.sub(r'^(###.*?)$', '_' * separators + r'\n\1', content, flags=re.MULTILINE)
2928

3029
cleaned_content = re.sub(r'### ', '', content) # Remove ###
3130

32-
if extra_spaces:
31+
if(extra_spaces):
3332
cleaned_content = re.sub(r'(?<!\n)\n(?!\n)', '\n\n', cleaned_content)
3433

3534
print(cleaned_content)

hardware/kibot_resources/scripts/get_changelog_version.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

55
def get_last_version(file_path):
66
try:
7-
with open(file_path, 'r') as file:
7+
with open(file_path, "r") as file:
88
content = file.read()
99

1010
# Regex to match version entries
1111
version_pattern = r"## \[(.*?)\]"
1212
versions = re.findall(version_pattern, content)
1313

14-
if not versions:
14+
if(not versions):
1515
return "N/A"
1616

1717
# Check the last entry
1818
last_version = versions[0] # First match is the most recent
1919

20-
if last_version.lower() == "unreleased":
21-
if len(versions) > 1:
20+
if(last_version.lower() == "unreleased"):
21+
if(len(versions) > 1):
2222
second_last_version = versions[1]
2323
return f"{second_last_version}+ (Unreleased)"
2424
else:
@@ -27,10 +27,10 @@ def get_last_version(file_path):
2727
return last_version
2828

2929
except FileNotFoundError:
30-
print(f"Error: File '{file_path}' not found.", file=sys.stderr)
30+
print(f"Error: File '{file_path}' not found.", file = sys.stderr)
3131
sys.exit(1)
3232
except (IOError, OSError) as e:
33-
print(f"Error: An error occurred: {e}", file=sys.stderr)
33+
print(f"Error: An error occurred: {e}", file = sys.stderr)
3434
sys.exit(1)
3535

3636
if(__name__ == "__main__"):

hardware/kibot_resources/scripts/get_sheet_title.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ def get_sheet_title(file_path, page_number, dots_number):
1111

1212
for sheet in root.findall(".//sheet"):
1313
number = sheet.get("number")
14-
if number == page_number:
14+
if(number == page_number):
1515
# Get the last part of the 'name' attribute after '/'
1616
name = sheet.get("name")
17-
if name:
17+
if(name):
1818
titles.append(name.split("/")[-2 if name.endswith("/") else -1])
1919

20-
if not titles:
20+
if(not titles):
2121
print('.'*dots_number)
2222

23-
elif len(set(titles)) > 1:
23+
elif(len(set(titles)) > 1):
2424
print("Conflicting page numbers")
2525
else:
2626
print(titles[0])
@@ -31,7 +31,6 @@ def get_sheet_title(file_path, page_number, dots_number):
3131
except Exception as e:
3232
print(f"Error: {e}")
3333

34-
3534
def main():
3635
parser = argparse.ArgumentParser(description = "Get the sheet title based on page number from a KiCad XML file")
3736
parser.add_argument("-p", "--page-number", type = int, required = True, help = "Page number to search")

0 commit comments

Comments
 (0)