Serverlibrary CI / test-serverlibrary (push) Successful in 12s
Serverlibrary CI / lint-serverlibrary (push) Successful in 8s
Wallpaper Changer CI / test-wallpaper-changer (push) Successful in 20s
Wallpaper Changer CI / build (push) Skipped
Wallpaper Changer CI / install (mediahost) (push) Skipped
Wallpaper Changer CI / install (quiethost) (push) Skipped
Wallpaper Changer CI / install (serverhost) (push) Skipped
Wallpaper Changer CI / install (vivohost) (push) Skipped
Wallpaper Changer CI / lint-wallpaper-changer (push) Successful in 8s
209 lines
6.3 KiB
YAML
209 lines
6.3 KiB
YAML
name: Wallpaper Changer CI
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- dev
|
|
- main
|
|
paths:
|
|
- "wallpaper_changer/python/**"
|
|
- ".gitea/workflows/wallpaper_changer.yaml"
|
|
pull_request:
|
|
branches:
|
|
- dev
|
|
paths:
|
|
- "wallpaper_changer/python/**"
|
|
- ".gitea/workflows/wallpaper_changer.yaml"
|
|
|
|
jobs:
|
|
test-wallpaper-changer:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: nikolaik/python-nodejs:python3.12-nodejs20
|
|
|
|
steps:
|
|
- name: Check out the tested commit
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install serverlibrary and wallpaper_changer
|
|
working-directory: wallpaper_changer/python
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
python -m pip install ../../serverlibrary
|
|
python -m pip install --group test .
|
|
|
|
- name: Run wallpaper_changer tests
|
|
working-directory: wallpaper_changer/python
|
|
run: python tests/run_tests.py all
|
|
|
|
lint-wallpaper-changer:
|
|
if: >-
|
|
${{ github.event_name != 'workflow_run'
|
|
|| github.event.workflow_run.conclusion == 'success' }}
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: nikolaik/python-nodejs:python3.12-nodejs20
|
|
|
|
steps:
|
|
- name: Check out the tested commit
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }}
|
|
|
|
- name: Install Ruff
|
|
run: python -m pip install ruff
|
|
|
|
- name: Lint wallpaper_changer
|
|
run: ruff check wallpaper_changer/python
|
|
|
|
build:
|
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
|
needs: test-wallpaper-changer
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: nikolaik/python-nodejs:python3.12-nodejs20
|
|
|
|
steps:
|
|
- name: Check out the tested commit
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install build dependencies
|
|
working-directory: wallpaper_changer/python
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
python -m pip install ../../serverlibrary
|
|
python -m pip install --group test .
|
|
python -m pip install build
|
|
|
|
- name: Build executable
|
|
working-directory: wallpaper_changer/python
|
|
run: |
|
|
python -m PyInstaller \
|
|
--clean \
|
|
--onefile \
|
|
--paths src \
|
|
--name wallpaper_changer \
|
|
main.py
|
|
|
|
- name: Build wheel
|
|
working-directory: wallpaper_changer/python
|
|
run: python -m build --wheel
|
|
|
|
- name: Include user service unit
|
|
working-directory: wallpaper_changer/python
|
|
run: cp systemd/wallpaper-changer.service dist/
|
|
|
|
- name: Verify build outputs
|
|
working-directory: wallpaper_changer/python
|
|
run: |
|
|
ls -lh dist/
|
|
test -f dist/wallpaper_changer
|
|
test -f dist/wallpaper-changer.service
|
|
ls dist/*.whl
|
|
|
|
- name: Upload build artifacts
|
|
uses: https://github.com/christopherHX/gitea-upload-artifact@v4
|
|
with:
|
|
name: wallpaper-changer-build
|
|
path: wallpaper_changer/python/dist/
|
|
if-no-files-found: error
|
|
install:
|
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
|
needs: build
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
runner:
|
|
- vivohost
|
|
- quiethost
|
|
- serverhost
|
|
- mediahost
|
|
runs-on: ${{ matrix.runner }}
|
|
timeout-minutes: 5
|
|
|
|
steps:
|
|
- name: Check runner environment
|
|
run: |
|
|
set -eux
|
|
whoami
|
|
echo "$HOME"
|
|
id
|
|
echo "UID: $(id -u)"
|
|
echo "Checking user systemd bus..."
|
|
ls -l "/run/user/$(id -u)/bus" || true
|
|
|
|
- name: Download build artifacts
|
|
uses: https://github.com/christopherHX/gitea-download-artifact@v4
|
|
with:
|
|
name: wallpaper-changer-build
|
|
path: dist/
|
|
|
|
- name: Verify downloaded artifacts
|
|
run: |
|
|
set -eux
|
|
ls -lah dist/
|
|
test -f dist/wallpaper_changer
|
|
test -f dist/wallpaper-changer.service
|
|
|
|
- name: Install executable and provision encryption passphrase
|
|
env:
|
|
WALLPAPER_ENCRYPTION_PASSPHRASE: ${{ secrets.WALLPAPER_ENCRYPTION_PASSPHRASE }}
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
echo "1. Preparing directories"
|
|
key_dir="$HOME/.wallpaper"
|
|
passphrase_file="$key_dir/encryption.passphrase"
|
|
install -d -m 700 "$key_dir"
|
|
install -d -m 755 "$HOME/tools"
|
|
|
|
temporary_passphrase=""
|
|
cleanup() {
|
|
test -z "$temporary_passphrase" || rm -f "$temporary_passphrase"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
echo "2. Installing encryption passphrase"
|
|
if [ -L "$passphrase_file" ] || { [ -e "$passphrase_file" ] && [ ! -f "$passphrase_file" ]; }; then
|
|
echo "Invalid passphrase path" >&2
|
|
exit 1
|
|
fi
|
|
if [ ! -f "$passphrase_file" ]; then
|
|
: "${WALLPAPER_ENCRYPTION_PASSPHRASE:?Missing encryption passphrase secret}"
|
|
temporary_passphrase="$(mktemp "$key_dir/.encryption_passphrase.XXXXXX")"
|
|
printf '%s' "$WALLPAPER_ENCRYPTION_PASSPHRASE" > "$temporary_passphrase"
|
|
chmod 600 "$temporary_passphrase"
|
|
mv "$temporary_passphrase" "$passphrase_file"
|
|
else
|
|
echo "Preserving existing encryption passphrase"
|
|
fi
|
|
|
|
echo "3. Installing executable"
|
|
install -m 755 dist/wallpaper_changer "$HOME/tools/wallpaper_changer"
|
|
|
|
echo "4. Installing systemd service"
|
|
user_unit_dir="$HOME/.config/systemd/user"
|
|
install -d -m 755 "$user_unit_dir"
|
|
install -m 644 dist/wallpaper-changer.service "$user_unit_dir/wallpaper-changer.service"
|
|
|
|
echo "5. Connecting to user systemd"
|
|
export XDG_RUNTIME_DIR="/run/user/$(id -u)"
|
|
export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
|
|
|
|
test -S "$XDG_RUNTIME_DIR/bus"
|
|
|
|
echo "6. Reloading systemd"
|
|
timeout 15s systemctl --user daemon-reload
|
|
|
|
echo "7. Enabling service"
|
|
timeout 15s systemctl --user enable wallpaper-changer.service
|
|
|
|
echo "8. Starting service"
|
|
timeout 15s systemctl --user restart --no-block wallpaper-changer.service
|
|
|
|
echo "9. Installation completed"
|