Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions .github/workflows/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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" \
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
25 changes: 19 additions & 6 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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.
11 changes: 6 additions & 5 deletions scripts/upload_model.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 -)
Expand All @@ -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..."
Expand Down
Loading