-
Notifications
You must be signed in to change notification settings - Fork 29
[CI] Automatic dependency updates #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yotamloe
wants to merge
15
commits into
master
Choose a base branch
from
feat/dependencies
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b201b4a
Add e2e test
yotamloe 12044d2
Update ci.yml
yotamloe 92da998
_remove_version_specific_fields unit tests
yotamloe aa220e0
secrets names
yotamloe 393bc4b
more python versions
yotamloe 4898f0a
Update README.md
yotamloe 1e32199
Update test_logzio_e2e.py
yotamloe 2cf0f28
Update test_logzio_e2e.py
yotamloe 7b7d080
Update test_logzio_e2e.py
yotamloe 19b82f0
Update test_logzio_e2e.py
yotamloe c6a6eab
Update dependabot.yaml
yotamloe f06debb
Create dependabot-automerge.yml
yotamloe e898598
Create dependabot-notifications.yml
yotamloe 2df2ec5
Update dependabot-automerge.yml
yotamloe 16bccf0
use crl and not rtCamp/action-slack-notify@v2
yotamloe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| pull_request: | ||
|
|
||
| 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! β " | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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