Skip to content
Open
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
39 changes: 31 additions & 8 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,40 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
# Dependabot configuration for automated dependency updates
# See: https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "09:00"
timezone: "Asia/Jerusalem"
groups:
python-dependencies:
patterns:
- "*"
commit-message:
prefix: "deps"
labels:
- "dependencies"
- "python"
open-pull-requests-limit: 5

- package-ecosystem: "github-actions"
# Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.)
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: "weekly"
day: "monday"
time: "09:00"
timezone: "Asia/Jerusalem"
groups:
github-actions:
patterns:
- "*"
commit-message:
prefix: "ci"
labels:
- "dependencies"
- "github-actions"
open-pull-requests-limit: 5
105 changes: 105 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: CI

on:
pull_request:
Comment on lines +3 to +4
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should run only on dependabot's PRs, no? We need to make sure we do not auto merge PRs that are not depedabot's PRs

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh nvm, I see this now


permissions:
contents: read

jobs:
test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov future requests

- name: Install package in development mode
run: pip install -e .

- name: Run unit tests with coverage
run: |
pytest --cov-report=term-missing --cov=logzio tests/ -v --ignore=tests/e2e/

- name: Upload coverage report
if: matrix.python-version == '3.11'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: .coverage
retention-days: 5

e2e-integration:
name: E2E Integration Test
runs-on: ubuntu-latest
needs: [test]

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest requests

- name: Install package in development mode
run: pip install -e .

- name: Generate unique ENV_ID
id: env-id
run: echo "value=e2e-${{ github.run_id }}-${{ github.run_attempt }}" >> $GITHUB_OUTPUT

- name: Run E2E integration test
env:
LOGZIO_TOKEN: ${{ secrets.LOGZIO_TOKEN }}
LOGZIO_API_KEY: ${{ secrets.LOGZIO_API_KEY }}
ENV_ID: ${{ steps.env-id.outputs.value }}
run: |
pytest tests/e2e/test_logzio_e2e.py -v --tb=long

ci-success:
name: CI Success
runs-on: ubuntu-latest
needs: [test, e2e-integration]
if: always()
steps:
- name: Check all jobs passed
run: |
if [[ "${{ needs.test.result }}" != "success" ]]; then
echo "Test job failed"
exit 1
fi
if [[ "${{ needs.e2e-integration.result }}" != "success" ]]; then
echo "E2E integration job failed"
exit 1
fi
echo "All CI checks passed! βœ…"
53 changes: 53 additions & 0 deletions .github/workflows/dependabot-automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Dependabot Auto-Merge

# This workflow runs AFTER CI completes for Dependabot PRs.
# It waits for CI to pass, then enables auto-merge.

on:
workflow_run:
workflows: ["CI"]
types:
- completed

permissions:
contents: write
pull-requests: write

jobs:
auto-merge:
name: Auto-Merge Dependabot PR
runs-on: ubuntu-latest
# Run if:
# 1. CI passed
# 2. It was triggered by Dependabot
# 3. It was a pull request
if: |
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.actor.login == 'dependabot[bot]' &&
github.event.workflow_run.event == 'pull_request'

steps:
- name: Checkout for metadata
uses: actions/checkout@v4

- name: Fetch Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Auto-merge patch/minor updates
if: |
steps.metadata.outputs.update-type == 'version-update:semver-patch' ||
steps.metadata.outputs.update-type == 'version-update:semver-minor'
run: |
echo "Enabling auto-merge for ${{ steps.metadata.outputs.dependency-names }} (${{ steps.metadata.outputs.update-type }})"
gh pr merge --auto --merge "$HEAD_BRANCH"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}

- name: Skip major updates
if: steps.metadata.outputs.update-type == 'version-update:semver-major'
run: |
echo "Major version update for ${{ steps.metadata.outputs.dependency-names }} - review required"
184 changes: 184 additions & 0 deletions .github/workflows/dependabot-notifications.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
name: Dependabot Notifications

# This workflow sends Slack notifications when CI completes for Dependabot PRs.
# It uses workflow_run to trigger AFTER the CI workflow finishes.


on:
workflow_run:
workflows: ["CI"]
types:
- completed

permissions:
contents: read
pull-requests: read
actions: read

jobs:
notify-success:
name: Notify Success
runs-on: ubuntu-latest
if: |
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.actor.login == 'dependabot[bot]'

steps:
- name: Get PR information
id: pr-info
uses: actions/github-script@v7
with:
script: |
const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${context.repo.owner}:${context.payload.workflow_run.head_branch}`
});

if (pullRequests.length > 0) {
const pr = pullRequests[0];
core.setOutput('pr_number', pr.number);
core.setOutput('pr_title', pr.title);
core.setOutput('pr_url', pr.html_url);
core.setOutput('found', 'true');
} else {
core.setOutput('found', 'false');
}

- name: Send Slack notification (Success)
if: steps.pr-info.outputs.found == 'true'
run: |
curl -X POST -H 'Content-type: application/json' --data '{
"attachments": [{
"color": "#36a64f",
"blocks": [
{
"type": "header",
"text": {"type": "plain_text", "text": "βœ… Dependabot Update - CI Passed", "emoji": true}
},
{
"type": "section",
"fields": [
{"type": "mrkdwn", "text": "*Repository:*\n${{ github.repository }}"},
{"type": "mrkdwn", "text": "*PR:*\n<${{ steps.pr-info.outputs.pr_url }}|#${{ steps.pr-info.outputs.pr_number }}>"}
]
},
{
"type": "section",
"text": {"type": "mrkdwn", "text": "${{ steps.pr-info.outputs.pr_title }}"}
},
{
"type": "context",
"elements": [{"type": "mrkdwn", "text": "Auto-merge enabled β€’ logzio-python-handler CI"}]
}
]
}]
}' "$SLACK_WEBHOOK"
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}


notify-failure:
name: Notify Failure
runs-on: ubuntu-latest
if: |
github.event.workflow_run.conclusion == 'failure' &&
github.event.workflow_run.actor.login == 'dependabot[bot]'

steps:
- name: Get PR information
id: pr-info
uses: actions/github-script@v7
with:
script: |
const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${context.repo.owner}:${context.payload.workflow_run.head_branch}`
});

if (pullRequests.length > 0) {
const pr = pullRequests[0];
core.setOutput('pr_number', pr.number);
core.setOutput('pr_title', pr.title);
core.setOutput('pr_url', pr.html_url);
core.setOutput('found', 'true');
} else {
core.setOutput('found', 'false');
}

- name: Get workflow run URL
id: run-url
run: |
echo "url=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}" >> $GITHUB_OUTPUT

- name: Send Slack notification (Failure)
if: steps.pr-info.outputs.found == 'true'
run: |
curl -X POST -H 'Content-type: application/json' --data '{
"attachments": [{
"color": "#ff0000",
"blocks": [
{
"type": "header",
"text": {"type": "plain_text", "text": "🚨 Dependabot Update - CI Failed", "emoji": true}
},
{
"type": "section",
"fields": [
{"type": "mrkdwn", "text": "*Repository:*\n${{ github.repository }}"},
{"type": "mrkdwn", "text": "*PR:*\n<${{ steps.pr-info.outputs.pr_url }}|#${{ steps.pr-info.outputs.pr_number }}>"}
]
},
{
"type": "section",
"text": {"type": "mrkdwn", "text": "${{ steps.pr-info.outputs.pr_title }}\n\n<${{ steps.run-url.outputs.url }}|View CI Run> to investigate"}
},
{
"type": "context",
"elements": [{"type": "mrkdwn", "text": "Manual intervention required β€’ logzio-python-handler CI"}]
}
]
}]
}' "$SLACK_WEBHOOK"
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

notify-merged:
name: Notify Merged
runs-on: ubuntu-latest
if: |
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push' &&
contains(github.event.workflow_run.head_commit.message, 'dependabot')

steps:
- name: Send Slack notification (Merged)
run: |
curl -X POST -H 'Content-type: application/json' --data '{
"attachments": [{
"color": "#2eb886",
"blocks": [
{
"type": "header",
"text": {"type": "plain_text", "text": "πŸŽ‰ Dependencies Updated Successfully", "emoji": true}
},
{
"type": "section",
"fields": [
{"type": "mrkdwn", "text": "*Repository:*\n${{ github.repository }}"},
{"type": "mrkdwn", "text": "*Commit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.event.workflow_run.head_sha }}|${{ github.event.workflow_run.head_sha }}>"}
]
},
{
"type": "context",
"elements": [{"type": "mrkdwn", "text": "Merged to main β€’ logzio-python-handler CI"}]
}
]
}]
}' "$SLACK_WEBHOOK"
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

Loading
Loading