Further refactor by extracting heredoc content to separate templates #659
This file contains hidden or 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
| name: Build image, lint, and run tests | |
| on: [push] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: [3.9] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install uv | |
| python -m uv venv | |
| python -m uv pip install .[test] | |
| - name: Lint with ruff | |
| run: | | |
| source .venv/bin/activate | |
| ruff check . | |
| - name: Test with pytest | |
| run: | | |
| source .venv/bin/activate | |
| pytest | |
| - name: Build web app | |
| run: | | |
| cd gonotego/settings-server | |
| npm install | |
| npm run build | |
| cd ../.. | |
| - name: Archive web app build | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: web-app-dist | |
| path: gonotego/settings-server/dist | |
| build_image: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download web app build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: web-app-dist | |
| path: web-app-dist | |
| # /home/runner/work/GoNoteGo/GoNoteGo/web-app-dist | |
| - name: Verify web app download | |
| run: | | |
| echo "Checking contents of web-app-dist:" | |
| ls -la web-app-dist | |
| if [ ! -f "web-app-dist/index.html" ]; then | |
| echo "ERROR: web-app-dist directory does not contain expected files!" | |
| exit 1 | |
| fi | |
| - uses: dbieber/arm-runner-action@v1.0.9 | |
| id: build_image | |
| with: | |
| base_image: https://downloads.raspberrypi.com/raspios_armhf/images/raspios_armhf-2024-03-15/2024-03-15-raspios-bookworm-armhf.img.xz | |
| bootpartition: 1 | |
| rootpartition: 2 | |
| image_additional_mb: 6000 | |
| extra_files_path: /home/runner/work/GoNoteGo/GoNoteGo/web-app-dist | |
| extra_files_mnt_path: web-app-dist | |
| commands: | | |
| echo "Updating package lists..." | |
| sudo apt-get update | |
| # Clean up apt cache to free up space | |
| sudo apt-get clean | |
| echo "Installing dependencies!" | |
| sudo apt install -y git firefox-esr xvfb portaudio19-dev libatlas-base-dev redis-server espeak \ | |
| rustc python3-dev libopenblas-dev iptables iptables-persistent nodejs npm | |
| # Clean up after installation | |
| sudo apt-get clean | |
| echo "Installing Go Note Go!" | |
| mkdir -p /home/pi/code/github/dbieber | |
| cd /home/pi/code/github/dbieber | |
| git clone https://github.com/dbieber/GoNoteGo.git | |
| cd GoNoteGo | |
| # Checkout the specific commit | |
| git checkout $GITHUB_SHA | |
| # Make scripts executable | |
| chmod +x /home/pi/code/github/dbieber/GoNoteGo/.github/scripts/*.sh | |
| echo "Including web app" | |
| echo "Checking web app files at /web-app-dist:" | |
| ls -la /web-app-dist | |
| echo "Creating settings-server directory:" | |
| mkdir -p /home/pi/code/github/dbieber/GoNoteGo/gonotego/settings-server/ | |
| echo "Copying web app files:" | |
| cp -r /web-app-dist /home/pi/code/github/dbieber/GoNoteGo/gonotego/settings-server/dist | |
| echo "Verifying copied web app files:" | |
| ls -la /home/pi/code/github/dbieber/GoNoteGo/gonotego/settings-server/dist | |
| # Run the Python environment setup script | |
| bash /home/pi/code/github/dbieber/GoNoteGo/.github/scripts/setup_python_env.sh | |
| # Setup system boot configuration | |
| bash /home/pi/code/github/dbieber/GoNoteGo/.github/scripts/setup_boot.sh | |
| # Install geckodriver | |
| bash /home/pi/code/github/dbieber/GoNoteGo/.github/scripts/install_geckodriver.sh | |
| # Set up a wifi access point | |
| bash /home/pi/code/github/dbieber/GoNoteGo/.github/scripts/setup_wifi_ap.sh | |
| # Setup bash history | |
| bash /home/pi/code/github/dbieber/GoNoteGo/.github/scripts/setup_bash_history.sh | |
| - name: Compress the release image | |
| run: | | |
| sudo fdisk -l | |
| sudo ls /etc/xdg/autostart/ | |
| mv ${{ steps.build_image.outputs.image }} go-note-go.img | |
| xz -0 -T 0 -v go-note-go.img | |
| - name: Upload release image | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Release image | |
| path: go-note-go.img.xz |