From 60e40721b0c6f0454afc3b7366e31e5206e2b6c9 Mon Sep 17 00:00:00 2001 From: Gourav Shah Date: Sun, 21 Sep 2025 11:11:09 +0530 Subject: [PATCH 1/5] Create goose.yml --- .github/workflows/goose.yml | 87 +++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 .github/workflows/goose.yml diff --git a/.github/workflows/goose.yml b/.github/workflows/goose.yml new file mode 100644 index 0000000..2d1d8c6 --- /dev/null +++ b/.github/workflows/goose.yml @@ -0,0 +1,87 @@ + + +name: Goose + +on: +pull_request: + types: [opened, synchronize, reopened, labeled] + +permissions: +contents: write +pull-requests: write +issues: write + +env: +PROVIDER_API_KEY: ${{ secrets.GOOGLE_API_KEY }} +PR_NUMBER: ${{ github.event.pull_request.number }} +GH_TOKEN: ${{ github.token }} + +jobs: +goose-comment: + name: Goose Comment + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Gather PR information + run: | + { + echo "# Files Changed" + gh pr view $PR_NUMBER --json files \ + -q '.files[] | "* " + .path + " (" + (.additions|tostring) + " additions, " + (.deletions|tostring) + " deletions)"' + echo "" + echo "# Changes Summary" + gh pr diff $PR_NUMBER + } > changes.txt + + - name: Install Goose CLI + run: | + mkdir -p /home/runner/.local/bin + curl -fsSL https://github.com/block/goose/releases/download/stable/download_cli.sh \ + | CONFIGURE=false INSTALL_PATH=/home/runner/.local/bin bash + echo "/home/runner/.local/bin" >> $GITHUB_PATH + + - name: Configure Goose + run: | + mkdir -p ~/.config/goose + cat < ~/.config/goose/config.yaml + GOOSE_PROVIDER: google + GOOSE_MODEL: gemini-2.0-flash-exp + keyring: false + EOF + + - name: Create instructions for Goose + run: | + cat < instructions.txt + Create a summary of the changes provided. Don't provide any session or logging details. + The summary for each file should be brief and structured as: + + - dot points of changes + You don't need any extensions, don't mention extensions at all. + The changes to summarise are: + $(cat changes.txt) + EOF + + - name: Test + run: cat instructions.txt + + - name: Run Goose and filter output + run: | + goose run --instructions instructions.txt | \ + # Remove ANSI color codes + sed -E 's/\x1B\[[0-9;]*[mK]//g' | \ + # Remove session/logging lines + grep -v "logging to /home/runner/.config/goose/sessions/" | \ + grep -v "^starting session" | \ + grep -v "^Closing session" | \ + # Trim trailing whitespace + sed 's/[[:space:]]*$//' \ + > pr_comment.txt + + - name: Post comment to PR + run: | + cat -A pr_comment.txt + gh pr comment $PR_NUMBER --body-file pr_comment.txt From a22439066bea45e1d954598bea714e8e430baa43 Mon Sep 17 00:00:00 2001 From: Gourav Shah Date: Sun, 21 Sep 2025 11:15:56 +0530 Subject: [PATCH 2/5] Update goose.yml --- .github/workflows/goose.yml | 101 +++++++++++++++++------------------- 1 file changed, 48 insertions(+), 53 deletions(-) diff --git a/.github/workflows/goose.yml b/.github/workflows/goose.yml index 2d1d8c6..c491d1b 100644 --- a/.github/workflows/goose.yml +++ b/.github/workflows/goose.yml @@ -1,87 +1,82 @@ - - name: Goose on: -pull_request: - types: [opened, synchronize, reopened, labeled] + pull_request: + types: [opened, synchronize, reopened, labeled] permissions: -contents: write -pull-requests: write -issues: write + contents: write + pull-requests: write + issues: write env: -PROVIDER_API_KEY: ${{ secrets.GOOGLE_API_KEY }} -PR_NUMBER: ${{ github.event.pull_request.number }} -GH_TOKEN: ${{ github.token }} + PROVIDER_API_KEY: ${{ secrets.GOOGLE_API_KEY }} + PR_NUMBER: ${{ github.event.pull_request.number }} + GH_TOKEN: ${{ github.token }} jobs: -goose-comment: - name: Goose Comment - runs-on: ubuntu-latest - steps: + goose-comment: + name: Goose Comment + runs-on: ubuntu-latest + steps: - name: Check out repository uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: 0 - name: Gather PR information run: | - { - echo "# Files Changed" - gh pr view $PR_NUMBER --json files \ + { + echo "# Files Changed" + gh pr view "$PR_NUMBER" --json files \ -q '.files[] | "* " + .path + " (" + (.additions|tostring) + " additions, " + (.deletions|tostring) + " deletions)"' - echo "" - echo "# Changes Summary" - gh pr diff $PR_NUMBER - } > changes.txt + echo "" + echo "# Changes Summary" + gh pr diff "$PR_NUMBER" + } > changes.txt - name: Install Goose CLI run: | - mkdir -p /home/runner/.local/bin - curl -fsSL https://github.com/block/goose/releases/download/stable/download_cli.sh \ - | CONFIGURE=false INSTALL_PATH=/home/runner/.local/bin bash - echo "/home/runner/.local/bin" >> $GITHUB_PATH + mkdir -p /home/runner/.local/bin + curl -fsSL https://github.com/block/goose/releases/download/stable/download_cli.sh \ + | CONFIGURE=false INSTALL_PATH=/home/runner/.local/bin bash + echo "/home/runner/.local/bin" >> "$GITHUB_PATH" - name: Configure Goose run: | - mkdir -p ~/.config/goose - cat < ~/.config/goose/config.yaml - GOOSE_PROVIDER: google - GOOSE_MODEL: gemini-2.0-flash-exp - keyring: false - EOF + mkdir -p ~/.config/goose + cat > ~/.config/goose/config.yaml <<'EOF' + GOOSE_PROVIDER: google + GOOSE_MODEL: gemini-2.0-flash-exp + keyring: false + EOF - name: Create instructions for Goose run: | - cat < instructions.txt - Create a summary of the changes provided. Don't provide any session or logging details. - The summary for each file should be brief and structured as: - - - dot points of changes - You don't need any extensions, don't mention extensions at all. - The changes to summarise are: - $(cat changes.txt) - EOF + cat > instructions.txt <<'EOF' + Create a summary of the changes provided. Don't provide any session or logging details. + The summary for each file should be brief and structured as: + + - dot points of changes + You don't need any extensions, don't mention extensions at all. + The changes to summarise are: + EOF + cat changes.txt >> instructions.txt - name: Test run: cat instructions.txt - name: Run Goose and filter output run: | - goose run --instructions instructions.txt | \ - # Remove ANSI color codes - sed -E 's/\x1B\[[0-9;]*[mK]//g' | \ - # Remove session/logging lines - grep -v "logging to /home/runner/.config/goose/sessions/" | \ - grep -v "^starting session" | \ - grep -v "^Closing session" | \ - # Trim trailing whitespace - sed 's/[[:space:]]*$//' \ - > pr_comment.txt + goose run --instructions instructions.txt \ + | sed -E 's/\x1B\[[0-9;]*[mK]//g' \ + | grep -v "logging to /home/runner/.config/goose/sessions/" \ + | grep -v "^starting session" \ + | grep -v "^Closing session" \ + | sed 's/[[:space:]]*$//' \ + > pr_comment.txt - name: Post comment to PR run: | - cat -A pr_comment.txt - gh pr comment $PR_NUMBER --body-file pr_comment.txt + cat -A pr_comment.txt + gh pr comment "$PR_NUMBER" --body-file pr_comment.txt From fca6aad0304f8343270d9a33221b95d18307f895 Mon Sep 17 00:00:00 2001 From: Gourav Shah Date: Sun, 21 Sep 2025 11:17:48 +0530 Subject: [PATCH 3/5] Update goose.yml --- .github/workflows/goose.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/goose.yml b/.github/workflows/goose.yml index c491d1b..e8cd368 100644 --- a/.github/workflows/goose.yml +++ b/.github/workflows/goose.yml @@ -3,7 +3,8 @@ name: Goose on: pull_request: types: [opened, synchronize, reopened, labeled] - + workflow_dispatch: + permissions: contents: write pull-requests: write From 73f88f50a28f6fe0e82f8c8ed1ef104964fb06cd Mon Sep 17 00:00:00 2001 From: Gourav Shah Date: Sun, 21 Sep 2025 11:19:37 +0530 Subject: [PATCH 4/5] Create Dockerfile --- Dockerfile | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..330a4ff --- /dev/null +++ b/Dockerfile @@ -0,0 +1,54 @@ +# Multi-stage Dockerfile for Tech Stack Advisor ML App + +# Stage 1: Builder stage for training the model +FROM python:3.11-slim AS builder + +WORKDIR /app + +# Install build dependencies +RUN apt-get update && apt-get install -y \ + gcc \ + python3-dev \ + && rm -rf /var/lib/apt/lists/* + +# Copy requirements and install Python dependencies +COPY requirements.txt . +RUN pip install --no-cache-dir --user -r requirements.txt + +# Copy training script and train the model +COPY train.py . +RUN python train.py + +# Stage 2: Production runtime stage +FROM python:3.11-slim AS production + +# Create non-root user for security +RUN useradd --create-home --shell /bin/bash mluser + +WORKDIR /app + +# Copy Python packages from builder stage +COPY --from=builder /root/.local /home/mluser/.local + +# Copy application files +COPY app.py . +COPY requirements.txt . + +# Copy trained model from builder stage +COPY --from=builder /app/model.pkl . +COPY --from=builder /app/encoders.pkl . + +# Set ownership and switch to non-root user +RUN chown -R mluser:mluser /app +USER mluser + +# Make sure scripts in .local are usable +ENV PATH=/home/mluser/.local/bin:$PATH + +# Add health check +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD python -c "import requests; requests.get('http://localhost:7860', timeout=3)" || exit 1 + +EXPOSE 7860 + +CMD ["python", "app.py"] From 0fffecae2794bae5916f2c5be7cd839545a269ea Mon Sep 17 00:00:00 2001 From: Gourav Shah Date: Sun, 21 Sep 2025 11:28:29 +0530 Subject: [PATCH 5/5] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 330a4ff..f9554ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Multi-stage Dockerfile for Tech Stack Advisor ML App - +# # Stage 1: Builder stage for training the model FROM python:3.11-slim AS builder