This repository was archived by the owner on Jan 19, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
146 lines (121 loc) · 5.01 KB
/
Copy pathtest-and-publish.yml
File metadata and controls
146 lines (121 loc) · 5.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Test and Publish
on: [push, pull_request, workflow_dispatch]
# Add permissions for GitHub Pages deployment
permissions:
contents: write
pages: write
id-token: write
jobs:
test-build-publish:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.13']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Install dependencies
run: |
poetry install --with dev
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg
- name: Install spaCy language models
run: |
poetry run python -m spacy download en_core_web_sm
- name: Download NLTK data
run: |
poetry run python -c "import nltk; nltk.download('cmudict')"
# Add Node.js and Yarn setup for frontend build
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Enable Yarn
run: corepack enable
# Frontend needs to be built before tests can run
- name: Build Frontend with version sync
run: |
chmod +x scripts/build_frontend.sh
./scripts/build_frontend.sh
echo "🔍 Verifying web_assets was created:"
ls -la lyrics_transcriber/frontend/ | grep -E "(web_assets|dist)" || echo "No web_assets or dist found after build"
- name: Run unit tests
run: |
poetry run pytest tests/unit/ -v --cov=lyrics_transcriber --cov-report=xml --cov-report=term-missing --cov-fail-under=60
- name: Upload coverage reports
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
- name: Run integration tests
run: |
poetry run pytest tests/integration/ -v
- if: github.ref == 'refs/heads/main' && github.event_name == 'push'
name: Setup Pages for Frontend
uses: actions/configure-pages@v4
- if: github.ref == 'refs/heads/main' && github.event_name == 'push'
name: Upload Frontend artifact
uses: actions/upload-pages-artifact@v3
with:
path: lyrics_transcriber/frontend/dist/
- if: github.ref == 'refs/heads/main' && github.event_name == 'push'
name: Deploy Frontend to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Build package
run: |
echo "🔍 Checking for web_assets before building package..."
ls -la lyrics_transcriber/frontend/ | grep -E "(web_assets|dist)" || echo "No web_assets or dist found"
if [ ! -d "lyrics_transcriber/frontend/web_assets" ]; then
echo "❌ web_assets directory missing - rebuilding frontend"
./scripts/build_frontend.sh
fi
echo "🔍 Frontend directory contents after ensuring web_assets exists:"
ls -la lyrics_transcriber/frontend/ | grep -E "(web_assets|dist)"
poetry build
- name: Verify frontend assets in package
run: |
# Extract and inspect the wheel to verify frontend assets are included
unzip -l dist/*.whl | grep "frontend/web_assets" || (echo "❌ Frontend assets not found in wheel!" && exit 1)
echo "✅ Frontend assets found in wheel"
- name: Test package installation
run: |
pip install dist/*.whl
python -m lyrics_transcriber.cli.cli_main --help
python -c "from lyrics_transcriber import __version__; print(f'Package version: {__version__}')"
- name: Verify frontend assets are accessible after installation
run: |
python -c "
from lyrics_transcriber.frontend import get_frontend_assets_dir
import os
try:
frontend_dir = get_frontend_assets_dir()
print(f'✅ Frontend assets found at: {frontend_dir}')
files = os.listdir(frontend_dir)
print(f'✅ Frontend files: {files}')
except Exception as e:
print(f'❌ Error: {e}')
exit(1)
"
- if: github.ref == 'refs/heads/main' && github.event_name == 'push'
name: Publish to PyPI
run: |
echo "📦 Publishing the following files to PyPI:"
ls -la dist/
echo "🔍 Verifying web_assets are in the wheel:"
unzip -l dist/*.whl | grep "web_assets" || echo "❌ No web_assets found!"
echo "🚀 Publishing to PyPI..."
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
poetry publish