From ee07d09b8989bc53f630af2cc16b92ba04fcbb71 Mon Sep 17 00:00:00 2001 From: alexciechonski Date: Fri, 28 Nov 2025 22:21:17 +0100 Subject: [PATCH 1/3] updated workflow to use the source branch --- .github/workflows/run.yml | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index 031d00a2..fc27bbd4 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -43,7 +43,18 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - RAW_BRANCH="${{ github.ref_name }}" + echo "=== Determining correct model for CI ===" + + # Correct branch resolution for both push and pull_request + if [ "${{ github.event_name }}" = "pull_request" ]; then + RAW_BRANCH="${{ github.event.pull_request.head.ref }}" + echo "Pull Request detected → using source branch: $RAW_BRANCH" + else + RAW_BRANCH="${{ github.ref_name }}" + echo "Regular push → using branch: $RAW_BRANCH" + fi + + # Convert slashes to hyphens for release names SAFE_BRANCH=$(echo "$RAW_BRANCH" | sed 's|/|-|g') echo "Raw branch: $RAW_BRANCH" @@ -55,9 +66,8 @@ jobs: ASSET_NAME="model-${SAFE_BRANCH}.tar.gz" FALLBACK_ASSET="model-main.tar.gz" - echo "Attempting to download branch-specific model: $ASSET_NAME" + echo "Attempting to download branch-specific model asset: $ASSET_NAME" - # Try branch-specific release set +e gh release download "$SAFE_BRANCH" \ --pattern "$ASSET_NAME" \ @@ -66,14 +76,16 @@ jobs: set -e if [ $STATUS -ne 0 ]; then - echo "Branch-specific model not found, falling back to main..." + echo "Branch-specific model not found. Falling back to: $FALLBACK_ASSET" gh release download "main" \ --pattern "$FALLBACK_ASSET" \ --dir "$MODEL_DIR" ASSET_NAME="$FALLBACK_ASSET" + else + echo "Found branch-specific model." fi - echo "Extracting: $ASSET_NAME" + echo "Extracting model archive: $ASSET_NAME" tar -xzf "$MODEL_DIR/$ASSET_NAME" -C "$MODEL_DIR" - name: Stage model under test @@ -91,7 +103,7 @@ jobs: test: name: Run tests with model runs-on: ubuntu-latest - needs: prepare-model # ensures model is ready before testing + needs: prepare-model services: redis: @@ -141,9 +153,8 @@ jobs: - name: Inspect session cache contents run: | - echo "Contents of session_cache/:" - ls -R session_cache/ || echo "session_cache/ missing or empty" - echo "Disk usage:" + echo "=== Session Cache Contents ===" + ls -R session_cache/ || echo "session_cache/ missing" du -sh session_cache/ || true - name: Fetch DNS dataset From e6ea597c6baaf100bb28a247c65cce6608d0c01e Mon Sep 17 00:00:00 2001 From: alexciechonski Date: Fri, 28 Nov 2025 22:37:08 +0100 Subject: [PATCH 2/3] fixed branch name bug in upload script --- scripts/upload_model.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/upload_model.sh b/scripts/upload_model.sh index 3fedce42..34caba16 100755 --- a/scripts/upload_model.sh +++ b/scripts/upload_model.sh @@ -19,6 +19,7 @@ echo "Model directory: $MODEL_DIR" # Get raw branch name RAW_BRANCH=$(git rev-parse --abbrev-ref HEAD) +RAW_BRANCH="${RAW_BRANCH#heads/}" echo "Raw branch name: $RAW_BRANCH" # Sanitize branch for filenames (replace / with -) @@ -42,16 +43,16 @@ tar -czf "$ARCHIVE" -C "$MODEL_DIR" . echo "Archive created: $(pwd)/$ARCHIVE" # Ensure the branch-specific GitHub release exists -echo "Ensuring release \"$RAW_BRANCH\" exists..." -if ! gh release view "$RAW_BRANCH" &>/dev/null; then - gh release create "$RAW_BRANCH" \ +if ! gh release view "$SAFE_BRANCH" &>/dev/null; then + gh release create "$SAFE_BRANCH" \ --title "Model for $RAW_BRANCH" \ - --notes "Auto-uploaded model artifact for branch $RAW_BRANCH" + --notes "Auto-uploaded model artifact for branch $RAW_BRANCH" \ + --target "$RAW_BRANCH" fi # Upload (replace any existing archive) echo "Uploading archive to GitHub Release..." -gh release upload "$RAW_BRANCH" "$ARCHIVE" --clobber +gh release upload "$SAFE_BRANCH" "$ARCHIVE" --clobber # Clean up local file echo "Cleaning up local archive..." From d66f077f08e05b118840f277b3e3006c4a407a8a Mon Sep 17 00:00:00 2001 From: alexciechonski Date: Fri, 28 Nov 2025 23:25:13 +0100 Subject: [PATCH 3/3] updated docs for testing --- docs/testing.md | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/docs/testing.md b/docs/testing.md index 93058429..a1ca7092 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -47,15 +47,28 @@ This setup reflects a deliberate trade-off: favoring simplicity and speed over a ### CI Test Troubleshooting -The CI system relies on a GitHub Release containing the model under test. -During the workflow, CI automatically downloads this model and uses it during test execution. +The CI pipeline tests each branch using a **model artifact** stored in GitHub Releases. +Because the model files are **local and git‑ignored**, CI cannot generate the model itself. -Because of this dependency, changing the model under test (for example retraining or modifying the model directory) can occasionally cause CI failures—especially if the release artifact is missing or outdated. +Whenever the model changes locally, you **must upload a new version**. -Although the upload process normally runs automatically, you can manually refresh the model artifact at any time by running: +--- + +## When You MUST Run `upload_model.sh` -```bash +Run: + +``` ./scripts/upload_model.sh ``` -This forces the model archive to be rebuilt and re-uploaded to the correct GitHub Release, which typically resolves CI-related issues. \ No newline at end of file +whenever: + +### 1. You retrain or change the model locally +The CI artifact becomes outdated otherwise. + +### 2. Before pushing a branch +Prevents CI from failing because the model archive is missing. + +### 3. Before opening or updating a pull request +Ensures CI tests use the correct model for your feature branch. \ No newline at end of file