Skip to content

Commit dde1473

Browse files
committed
fix: resolve critical CI/CD pipeline failures - Black formatting and Windows Unicode encoding
**Black Code Formatting Fixes:** - Run Black formatter on all Python files to ensure consistent formatting - Fix any formatting inconsistencies that may have caused CI failures - Ensure all Python code complies with 88-character line length standard **Windows Unicode Encoding Fixes:** - Remove all remaining Unicode emoji characters from CI workflow files - Replace Unicode emojis with ASCII alternatives in code-quality.yml: * [SETUP], [INSTALL], [SCAN], [OK] - Replace Unicode emojis in auto-release.yml changelog generation: * Breaking Changes, New Features, Bug Fixes, Maintenance - Fix publish.yml workflow name: remove and emojis **Comprehensive Unicode Character Removal:** - Systematically searched and replaced all Unicode characters in workflow files - Maintained clear, professional status reporting with ASCII alternatives - Preserved all functionality while ensuring Windows console compatibility **Expected Resolution:** - Code Quality workflow should pass Black formatting checks - Integration Test workflow should complete on Windows without UnicodeEncodeError - All CI/CD pipelines should work consistently across Ubuntu, Windows, macOS - Professional, readable status messages without encoding dependencies **Root Causes Fixed:** 1. Black formatting: Inconsistent code formatting in test files 2. Unicode encoding: Remaining emoji characters in CI workflows causing Windows cp1252 encoding errors **Solution:** Complete Unicode character elimination + Black formatting compliance + UTF-8 encoding for Python scripts that need Unicode support.
1 parent ae867d1 commit dde1473

14 files changed

+675
-551
lines changed

.github/workflows/auto-release.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ jobs:
126126
# Push with retry logic
127127
for i in {1..3}; do
128128
if git push origin main; then
129-
echo " Successfully pushed version bump commit"
129+
echo "[OK] Successfully pushed version bump commit"
130130
break
131131
else
132-
echo " Push attempt $i failed, retrying in 5 seconds..."
132+
echo "[ERROR] Push attempt $i failed, retrying in 5 seconds..."
133133
sleep 5
134134
fi
135135
136136
if [ $i -eq 3 ]; then
137-
echo " Failed to push after 3 attempts"
137+
echo "[ERROR] Failed to push after 3 attempts"
138138
exit 1
139139
fi
140140
done
@@ -148,23 +148,23 @@ jobs:
148148
149149
# Check if tag already exists
150150
if git tag -l | grep -q "^$TAG_NAME$"; then
151-
echo "⚠️ Tag $TAG_NAME already exists, skipping tag creation"
151+
echo "[WARN] Tag $TAG_NAME already exists, skipping tag creation"
152152
else
153153
git tag "$TAG_NAME"
154-
echo " Created tag: $TAG_NAME"
154+
echo "[OK] Created tag: $TAG_NAME"
155155
156156
# Push tag with retry logic
157157
for i in {1..3}; do
158158
if git push origin "$TAG_NAME"; then
159-
echo " Successfully pushed tag: $TAG_NAME"
159+
echo "[OK] Successfully pushed tag: $TAG_NAME"
160160
break
161161
else
162-
echo " Tag push attempt $i failed, retrying in 5 seconds..."
162+
echo "[ERROR] Tag push attempt $i failed, retrying in 5 seconds..."
163163
sleep 5
164164
fi
165165
166166
if [ $i -eq 3 ]; then
167-
echo " Failed to push tag after 3 attempts"
167+
echo "[ERROR] Failed to push tag after 3 attempts"
168168
exit 1
169169
fi
170170
done
@@ -265,10 +265,10 @@ jobs:
265265
266266
if pip index versions demopy_gb_jj 2>/dev/null | grep -q "$VERSION"; then
267267
echo "exists=true" >> $GITHUB_OUTPUT
268-
echo "⚠️ Version $VERSION already exists on PyPI"
268+
echo "[WARN] Version $VERSION already exists on PyPI"
269269
else
270270
echo "exists=false" >> $GITHUB_OUTPUT
271-
echo " Version $VERSION is new, proceeding with upload"
271+
echo "[OK] Version $VERSION is new, proceeding with upload"
272272
fi
273273
274274
- name: Publish to PyPI
@@ -315,29 +315,29 @@ jobs:
315315
BREAKING=$(echo "$COMMITS" | grep -iE "(BREAKING CHANGE|breaking:|major:)" || true)
316316
317317
if [ ! -z "$BREAKING" ]; then
318-
CHANGELOG="${CHANGELOG}### 🚨 Breaking Changes\n${BREAKING}\n\n"
318+
CHANGELOG="${CHANGELOG}### Breaking Changes\n${BREAKING}\n\n"
319319
fi
320-
320+
321321
if [ ! -z "$FEATURES" ]; then
322-
CHANGELOG="${CHANGELOG}### New Features\n${FEATURES}\n\n"
322+
CHANGELOG="${CHANGELOG}### New Features\n${FEATURES}\n\n"
323323
fi
324-
324+
325325
if [ ! -z "$FIXES" ]; then
326-
CHANGELOG="${CHANGELOG}### 🐛 Bug Fixes\n${FIXES}\n\n"
326+
CHANGELOG="${CHANGELOG}### Bug Fixes\n${FIXES}\n\n"
327327
fi
328-
328+
329329
if [ ! -z "$CHORES" ]; then
330-
CHANGELOG="${CHANGELOG}### 🔧 Maintenance\n${CHORES}\n\n"
330+
CHANGELOG="${CHANGELOG}### Maintenance\n${CHORES}\n\n"
331331
fi
332-
332+
333333
# Add installation instructions
334-
CHANGELOG="${CHANGELOG}### 📦 Installation\n\n"
334+
CHANGELOG="${CHANGELOG}### Installation\n\n"
335335
CHANGELOG="${CHANGELOG}\`\`\`bash\n"
336336
CHANGELOG="${CHANGELOG}pip install demopy_gb_jj==${{ needs.analyze-and-version.outputs.new_version }}\n"
337337
CHANGELOG="${CHANGELOG}\`\`\`\n\n"
338-
338+
339339
# Add usage example
340-
CHANGELOG="${CHANGELOG}### 🚀 Usage\n\n"
340+
CHANGELOG="${CHANGELOG}### Usage\n\n"
341341
CHANGELOG="${CHANGELOG}\`\`\`python\n"
342342
CHANGELOG="${CHANGELOG}import demopy\n"
343343
CHANGELOG="${CHANGELOG}print(demopy.hello()) # Hello from demopy_gb_jj!\n"

.github/workflows/code-quality.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ jobs:
5353

5454
- name: Install Rust tools
5555
run: |
56-
echo "🛠️ Installing Rust tools for CI..."
56+
echo "[SETUP] Installing Rust tools for CI..."
5757
python scripts/install_rust_tools.py --mode ci
5858
5959
- name: Check for unused dependencies
6060
run: |
61-
echo "🔍 Checking for unused dependencies..."
62-
cargo machete || echo "⚠️ cargo-machete check completed with warnings"
61+
echo "Checking for unused dependencies..."
62+
cargo machete || echo "[WARN] cargo-machete check completed with warnings"
6363
6464
python-quality:
6565
name: Python Code Quality
@@ -93,7 +93,7 @@ jobs:
9393
echo "PYTHONPATH=${PYTHONPATH}:$(pwd)/python" >> $GITHUB_ENV
9494
9595
# Validate that the package can be imported
96-
python -c "import sys; sys.path.insert(0, 'python'); import demopy; print(' demopy module imported successfully')"
96+
python -c "import sys; sys.path.insert(0, 'python'); import demopy; print('[OK] demopy module imported successfully')"
9797
python -c "import sys; sys.path.insert(0, 'python'); import demopy; print('Package version:', demopy.__version__)"
9898
9999
- name: Check Python formatting (Black)
@@ -116,7 +116,7 @@ jobs:
116116
echo "PYTHONPATH: $PYTHONPATH"
117117
118118
# Test that the module can be imported
119-
python -c "import sys; sys.path.insert(0, 'python'); import demopy; print(' demopy module imported successfully')"
119+
python -c "import sys; sys.path.insert(0, 'python'); import demopy; print('[OK] demopy module imported successfully')"
120120
121121
# Run the actual tests
122122
pytest tests/ -v
@@ -152,9 +152,9 @@ jobs:
152152
try:
153153
with open('$workflow', 'r') as f:
154154
yaml.safe_load(f)
155-
print(' $workflow is valid')
155+
print('[OK] $workflow is valid')
156156
except Exception as e:
157-
print(' $workflow is invalid: {e}')
157+
print('[ERROR] $workflow is invalid: {e}')
158158
sys.exit(1)
159159
"
160160
done
@@ -170,13 +170,13 @@ jobs:
170170
run: |
171171
# Install cargo-audit if not already present
172172
if ! command -v cargo-audit &> /dev/null; then
173-
echo "📦 Installing cargo-audit..."
173+
echo "[INSTALL] Installing cargo-audit..."
174174
cargo install cargo-audit --locked || cargo install cargo-audit --locked --force
175175
else
176-
echo " cargo-audit already installed"
176+
echo "[OK] cargo-audit already installed"
177177
fi
178178
179-
echo "🔒 Running security audit..."
179+
echo "[SCAN] Running security audit..."
180180
cargo audit
181181
continue-on-error: true # Don't fail the build on security advisories initially
182182

@@ -245,17 +245,17 @@ jobs:
245245
pip install target/wheels/*.whl
246246
python -c "
247247
import demopy
248-
print(' Package imports successfully')
248+
print('[OK] Package imports successfully')
249249
print('Version:', demopy.__version__)
250250
print('Functions:', demopy.__all__)
251-
251+
252252
# Test all functions
253253
print('hello():', demopy.hello())
254254
print('add(5, 7):', demopy.add(5, 7))
255255
print('multiply(2.5, 4.0):', demopy.multiply(2.5, 4.0))
256256
print('sum_list([1,2,3]):', demopy.sum_list([1,2,3]))
257257
print('reverse_string(\"test\"):', demopy.reverse_string('test'))
258258
print('power(2, 3):', demopy.power(2, 3))
259-
print(' All functions work correctly')
259+
print('[OK] All functions work correctly')
260260
"
261261
shell: bash

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish Python 🐍 distribution 📦 to PyPI atomatically
1+
name: Publish Python distribution to PyPI automatically
22

33
on:
44
release:

scripts/bump_version.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
This script updates version numbers across all relevant files:
66
- Cargo.toml
7-
- pyproject.toml
7+
- pyproject.toml
88
- python/demopy/__init__.py
99
1010
Usage:
@@ -22,7 +22,7 @@
2222

2323
def parse_version(version_str):
2424
"""Parse a semantic version string into major, minor, patch components."""
25-
match = re.match(r'^(\d+)\.(\d+)\.(\d+)$', version_str)
25+
match = re.match(r"^(\d+)\.(\d+)\.(\d+)$", version_str)
2626
if not match:
2727
raise ValueError(f"Invalid version format: {version_str}")
2828
return tuple(map(int, match.groups()))
@@ -31,7 +31,7 @@ def parse_version(version_str):
3131
def bump_version(current_version, bump_type):
3232
"""Bump version according to the specified type."""
3333
major, minor, patch = parse_version(current_version)
34-
34+
3535
if bump_type == "major":
3636
return f"{major + 1}.0.0"
3737
elif bump_type == "minor":
@@ -49,12 +49,12 @@ def get_current_version():
4949
pyproject_path = Path("pyproject.toml")
5050
if not pyproject_path.exists():
5151
raise FileNotFoundError("pyproject.toml not found")
52-
52+
5353
content = pyproject_path.read_text()
5454
match = re.search(r'^version = "([^"]+)"', content, re.MULTILINE)
5555
if not match:
5656
raise ValueError("Version not found in pyproject.toml")
57-
57+
5858
return match.group(1)
5959

6060

@@ -64,10 +64,10 @@ def update_file(file_path, pattern, replacement):
6464
if not path.exists():
6565
print(f"Warning: {file_path} not found, skipping...")
6666
return False
67-
67+
6868
content = path.read_text()
6969
new_content = re.sub(pattern, replacement, content)
70-
70+
7171
if content != new_content:
7272
path.write_text(new_content)
7373
print(f"Updated {file_path}")
@@ -80,62 +80,62 @@ def update_file(file_path, pattern, replacement):
8080
def update_all_versions(new_version):
8181
"""Update version in all relevant files."""
8282
files_updated = []
83-
83+
8484
# Update pyproject.toml
8585
if update_file(
86-
"pyproject.toml",
87-
r'version = "[^"]+"',
88-
f'version = "{new_version}"'
86+
"pyproject.toml", r'version = "[^"]+"', f'version = "{new_version}"'
8987
):
9088
files_updated.append("pyproject.toml")
91-
89+
9290
# Update Cargo.toml (only the package version, not dependencies)
9391
if update_file(
9492
"Cargo.toml",
9593
r'(\[package\][\s\S]*?)version = "[^"]+"',
96-
rf'\1version = "{new_version}"'
94+
rf'\1version = "{new_version}"',
9795
):
9896
files_updated.append("Cargo.toml")
99-
97+
10098
# Update python/demopy/__init__.py
10199
if update_file(
102100
"python/demopy/__init__.py",
103101
r'__version__ = "[^"]+"',
104-
f'__version__ = "{new_version}"'
102+
f'__version__ = "{new_version}"',
105103
):
106104
files_updated.append("python/demopy/__init__.py")
107-
105+
108106
return files_updated
109107

110108

111109
def main():
112-
parser = argparse.ArgumentParser(description="Bump version across all project files")
110+
parser = argparse.ArgumentParser(
111+
description="Bump version across all project files"
112+
)
113113
parser.add_argument(
114114
"bump_type",
115-
help="Version bump type (major, minor, patch) or specific version (e.g., 1.2.3)"
115+
help="Version bump type (major, minor, patch) or specific version (e.g., 1.2.3)",
116116
)
117117

118118
args = parser.parse_args()
119119

120120
# Handle argument parsing
121121
bump_type = args.bump_type
122-
122+
123123
try:
124124
current_version = get_current_version()
125125
print(f"Current version: {current_version}")
126-
126+
127127
new_version = bump_version(current_version, bump_type)
128128
print(f"New version: {new_version}")
129-
129+
130130
files_updated = update_all_versions(new_version)
131-
131+
132132
if files_updated:
133133
print(f"\nSuccessfully updated version to {new_version} in:")
134134
for file in files_updated:
135135
print(f" - {file}")
136136
else:
137137
print("No files were updated.")
138-
138+
139139
except Exception as e:
140140
print(f"Error: {e}", file=sys.stderr)
141141
sys.exit(1)

0 commit comments

Comments
 (0)