uxoxo/eb2ab
0
1name: Mac E2A Test2 3on:4 workflow_dispatch:5 inputs:6 wipeAndReinstall:7 type: boolean8 description: 'Wipe & Re-Install E2A'9 10 pull_request:11 branches:12 - main13 types:14 - opened15 - synchronize16 - reopened17 paths-ignore:18 - CODE_OF_CONDUCT.md19 - LICENSE20 - README.md21 - readme/**22 - dockerfiles/**23 - Notebooks/**24 - .github/workflows/stale.yml25 - .github/workflows/custom-command.yml26 27 push:28 branches:29 - main30 paths-ignore:31 - CODE_OF_CONDUCT.md32 - LICENSE33 - README.md34 - readme/**35 - dockerfiles/**36 - Notebooks/**37 - .github/workflows/stale.yml38 - .github/workflows/custom-command.yml39 40 release:41 types:42 - published43 44jobs:45 macos-E2A:46 runs-on: [self-hosted, macos]47 48 steps:49 50 - name: Print runner info51 shell: bash52 run: |53 echo "Running on:"54 uname -a55 sw_vers56 57 - name: Wipe & Re-Install E2A58 if: ${{ inputs.wipeAndReinstall }}59 shell: bash60 run: rm -rf ~/ebook2audiobook61 62 - name: Clone ebook2audiobook63 shell: bash64 run: |65 set -e66 67 REPO_DIR=~/ebook2audiobook68 REPO_URL="https://github.com/${{ github.repository }}"69 IS_PR="${{ github.event_name == 'pull_request' }}"70 BASE_REF="${{ github.event.pull_request.base.ref }}"71 HEAD_REF="${{ github.event.pull_request.head.ref }}"72 HEAD_SHA="${{ github.event.pull_request.head.sha }}"73 TRIGGER_SHA="${{ github.sha }}"74 FRESH_CLONE=075 76 echo "==> Event: ${{ github.event_name }}"77 echo "==> Repo: $REPO_URL"78 79 # Clone or reuse80 if [ -d "$REPO_DIR" ]; then81 echo "==> Reusing existing repo"82 cd "$REPO_DIR"83 # Set correct remote and fix ambiguous refs84 git remote set-url origin "$REPO_URL"85 git remote set-head origin -a86 git remote prune origin87 git fetch --all --prune88 89 echo "==> Cleaning working directory"90 git reset --hard91 else92 echo "==> Cloning fresh"93 git clone "$REPO_URL" "$REPO_DIR"94 cd "$REPO_DIR"95 git remote set-head origin -a96 git remote prune origin97 git fetch --all --prune98 FRESH_CLONE=199 fi100 101 if [ "$IS_PR" = "true" ]; then102 echo "==> PR detected: simulating GitHub merge (base: $BASE_REF ← head: $HEAD_REF)"103 104 # Fetch both branches105 git fetch origin "$BASE_REF":"origin/$BASE_REF"106 git fetch origin "$HEAD_REF":"origin/$HEAD_REF"107 108 # Reset to base branch109 git checkout -B "$BASE_REF" "remotes/origin/$BASE_REF"110 git reset --hard "origin/$BASE_REF"111 112 # Merge PR source113 if ! git merge --no-ff --no-edit "origin/$HEAD_REF"; then114 echo "❌ Merge conflict simulating PR merge"115 echo "❌ Initial merge failed, attempting cleanup of __pycache__ and retry..."116 117 # Remove known __pycache__ dirs that may cause conflict118 echo "==> Cleaning up untracked files like __pycache__"119 git clean -ffd lib/120 121 # Retry the merge122 if ! git merge --no-ff --no-edit "origin/$HEAD_REF"; then123 echo "❌ Merge still failed after cleanup"124 exit 1125 fi126 fi127 else128 echo "==> Not a PR: checking out triggered commit directly"129 git fetch origin "$TRIGGER_SHA"130 git checkout --detach "$TRIGGER_SHA"131 git reset --hard "$TRIGGER_SHA"132 fi133 134 echo "==> Final repo state:"135 git status136 git log -1 --oneline137 138 if [ "$FRESH_CLONE" -eq 1 ]; then139 echo "==> Running ./ebook2audiobook.sh --help because this was a fresh clone"140 if ! ./ebook2audiobook.sh --help; then141 echo "==> Attempting fallback with conda deactivation"142 source "$(conda info --base 2>/dev/null)/etc/profile.d/conda.sh" 2>/dev/null && conda deactivate || true143 ./ebook2audiobook.sh --help144 fi145 else146 echo "==> Skipping script run because repo already existed"147 fi148 149 150 - name: Create Audiobook Output folders for Artifacts151 shell: bash152 run: |153 mkdir -p ~/ebook2audiobook/audiobooks/{TACOTRON2,FAIRSEQ,UnFAIRSEQ,VITS,YOURTTS,XTTSv2,XTTSv2FineTune,BARK}154 find ~/ebook2audiobook/audiobooks/{TACOTRON2,FAIRSEQ,UnFAIRSEQ,VITS,YOURTTS,XTTSv2,XTTSv2FineTune,BARK} -mindepth 1 -exec rm -rf {} +155 156 - name: Add set -e at beginning of ebook2audiobook.sh (for error passing)157 shell: bash158 run: |159 echo "Adding set -e at beginning of ebook2audiobook.sh (for error passing)..."160 cd ~/ebook2audiobook161 source "$(conda info --base)/etc/profile.d/conda.sh"162 conda deactivate163 sed -i '' '1s;^;set -e\n;' ebook2audiobook.sh164 165 - name: English TACOTRON2 Custom-Voice headless single test166 shell: bash167 run: |168 echo "Running English TACOTRON2 Custom-Voice headless single test..."169 cd ~/ebook2audiobook170 source "$(conda info --base)/etc/profile.d/conda.sh"171 conda deactivate172 ./ebook2audiobook.sh --headless --language eng --ebook "tools/workflow-testing/test1.txt" --tts_engine TACOTRON2 --voice "voices/eng/elder/male/DavidAttenborough.wav" --output_dir ~/ebook2audiobook/audiobooks/TACOTRON2173 174 175 - name: English FAIRSEQ Custom-Voice headless single test176 shell: bash177 run: |178 echo "Running English FAIRSEQ Custom-Voice headless single test..."179 cd ~/ebook2audiobook180 source "$(conda info --base)/etc/profile.d/conda.sh"181 conda deactivate182 ./ebook2audiobook.sh --headless --language eng --ebook "tools/workflow-testing/test1.txt" --tts_engine FAIRSEQ --voice "voices/eng/elder/male/DavidAttenborough.wav" --output_dir ~/ebook2audiobook/audiobooks/FAIRSEQ183 184 185 - name: Unusual FAIRSEQ Custom-Voice headless single test186 shell: bash187 run: |188 echo "Running Unusual FAIRSEQ Custom-Voice headless single test..."189 cd ~/ebook2audiobook190 source "$(conda info --base)/etc/profile.d/conda.sh"191 conda deactivate192 ./ebook2audiobook.sh --headless --language urd-script_devanagari --ebook "tools/workflow-testing/urd-script_davanagari-test.txt" --tts_engine FAIRSEQ --voice "voices/eng/elder/male/DavidAttenborough.wav" --output_dir ~/ebook2audiobook/audiobooks/UnFAIRSEQ193 194 - name: English VITS Custom-Voice headless single test195 shell: bash196 run: |197 echo "Running English VITS Custom-Voice headless single test..."198 199 cd ~/ebook2audiobook200 source "$(conda info --base)/etc/profile.d/conda.sh"201 conda deactivate202 ./ebook2audiobook.sh --headless --language eng --ebook "tools/workflow-testing/test1.txt" --tts_engine VITS --voice "voices/eng/elder/male/DavidAttenborough.wav" --output_dir ~/ebook2audiobook/audiobooks/VITS203 204 - name: English YOURTTS Custom-Voice headless batch test205 shell: bash206 run: |207 echo "Running English YOURTTS Custom-Voice headless batch test..."208 cd ~/ebook2audiobook209 source "$(conda info --base)/etc/profile.d/conda.sh"210 conda deactivate211 ./ebook2audiobook.sh --headless --language eng --ebooks_dir "tools/workflow-testing" --tts_engine YOURTTS --voice "voices/eng/elder/male/DavidAttenborough.wav" --output_dir ~/ebook2audiobook/audiobooks/YOURTTS212 213 214 - name: Default XTTSv2 headless Custom-Voice single test215 shell: bash216 run: |217 echo "Running Default XTTSv2 headless Custom-Voice single test..."218 cd ~/ebook2audiobook219 source "$(conda info --base)/etc/profile.d/conda.sh"220 conda deactivate221 ./ebook2audiobook.sh --headless --language eng --ebook "tools/workflow-testing/test1.txt" --tts_engine XTTSv2 --voice "voices/eng/elder/male/DavidAttenborough.wav" --output_dir ~/ebook2audiobook/audiobooks/XTTSv2222 223 - name: English XTTSv2 headless fine-tuned XTTSv2 model single test224 shell: bash225 run: |226 echo "Running English XTTSv2 headless fine-tuned XTTSv2 model single test..."227 cd ~/ebook2audiobook228 source "$(conda info --base)/etc/profile.d/conda.sh"229 conda deactivate230 ./ebook2audiobook.sh --headless --language eng --ebook "tools/workflow-testing/test1.txt" --tts_engine XTTSv2 --fine_tuned AiExplained --output_dir ~/ebook2audiobook/audiobooks/XTTSv2FineTune231 232 - name: English BARK Custom-Voice headless single test233 shell: bash234 run: |235 echo "Running English XTTSv2 headless fine-tuned XTTSv2 model single test..."236 cd ~/ebook2audiobook237 source "$(conda info --base)/etc/profile.d/conda.sh"238 conda deactivate239 ./ebook2audiobook.sh --headless --language eng --ebook "tools/workflow-testing/test1.txt" --tts_engine BARK --voice "voices/eng/elder/male/DavidAttenborough.wav" --output_dir ~/ebook2audiobook/audiobooks/BARK 240 241 - name: Upload audiobooks folder artifact242 if: always()243 uses: actions/upload-artifact@v4244 with:245 name: audiobooks246 path: ~/ebook2audiobook/audiobooks247 