### Install Dependencies and Setup Source: https://github.com/chdsbd/kodiak/blob/master/web_api/README.md Installs project dependencies using Poetry and sets up the local environment by copying and modifying the example .env file. ```console # install dependencies poetry config settings.virtualenvs.in-project true poetry install # copy & modify example .env file cp example.env .env ``` -------------------------------- ### Local Development Server Setup Source: https://github.com/chdsbd/kodiak/blob/master/bot/README.md Sets up a local development environment by copying the example environment file, starting ngrok for webhook forwarding, and running the development webserver. A Redis server must be running and configured in the `.env` file. The workers should be started in a separate terminal. ```shell cp example.env .env ngrok http 3000 s/dev-ingest --reload ``` ```shell s/dev-workers ``` -------------------------------- ### Install Dependencies and Run Dev Server Source: https://github.com/chdsbd/kodiak/blob/master/docs/README.md Installs project dependencies and starts the development server for the documentation site. Also includes commands for type checking, formatting, and building with Algolia search integration. ```shell # docs/ yarn install s/dev s/typecheck --watch s/fmt ALGOLIA_APP_ID= AGOLIA_API_KEY= AGOLIA_INDEX_NAME= yarn build ``` -------------------------------- ### Install Dependencies and Run Linters Source: https://github.com/chdsbd/kodiak/blob/master/bot/README.md Installs project dependencies using Poetry and formats/lints the code with Ruff and MyPy. Ensure Poetry is installed and configured. ```shell poetry config virtualenvs.in-project true poetry install s/lint ``` -------------------------------- ### Full Kodiak Configuration with All Options Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/config-reference.md A comprehensive `.kodiak.toml` example demonstrating all available configuration options with comments explaining each setting. ```toml # .kodiak.toml # Kodiak's configuration file should be placed at `.kodiak.toml` (repository # root) or `.github/.kodiak.toml`. # docs: https://kodiakhq.com/docs/config-reference # version is the only required setting in a kodiak config. # `1` is the only valid setting for this field. version = 1 [merge] # Label to enable Kodiak to merge a PR. # By default, Kodiak will only act on PRs that have this label. You can disable # this requirement via `merge.require_automerge_label`. automerge_label = "automerge" # default: "automerge" # Require that the automerge label (`merge.automerge_label`) be set for Kodiak # to merge a PR. # # When disabled, Kodiak will immediately attempt to merge any PR that passes all # GitHub branch protection requirements. require_automerge_label = true # If a PR's title matches this regex, Kodiak will not merge the PR. This is # useful to prevent merging work-in-progress PRs. # # Setting `merge.blocking_title_regex = ""` disables this option. blocking_title_regex = "" # default: "^WIP:.*", options: "" (disables regex), a regex string (e.g. ".*DONT\s*MERGE.*") # Kodiak will not merge a PR with any of these labels. blocking_labels = [] # default: [], options: list of label names (e.g. ["wip"]) # Choose merge method for Kodiak to use. # # Kodiak will report a configuration error if the selected merge method is # disabled for a repository. # # If you're using the "Require signed commits" GitHub Branch Protection setting # to require commit signatures, "merge" or "squash" are the only compatible options. "rebase" will cause Kodiak to raise a configuration error. method = "merge" # default: first valid merge method in list "merge", "squash", "rebase", options: "merge", "squash", "rebase" # Once a PR is merged, delete the branch. This option behaves like the GitHub # repository setting "Automatically delete head branches", which automatically # deletes head branches after pull requests are merged. delete_branch_on_merge = false # default: false # DEPRECATED # # Due to limitations with the GitHub API this feature is fundamentally broken # and cannot be fixed. Prefer the GitHub branch protection "required reviewers" # setting instead. # # When a user leaves a comment on a PR, GitHub counts that as satisfying a # review request, so the PR will be allowed to merge, even though a reviewer was # likely just starting a review. # # See this issue comment for more information: # https://github.com/chdsbd/kodiak/issues/153#issuecomment-523057332 # # If you request review from a user, don't merge until that user provides a # review, even if the PR is passing all status checks. block_on_reviews_requested = false # default: false # If there is a merge conflict, make a comment on the PR and remove the # automerge label. This option only applies when `merge.require_automerge_label` # is enabled. notify_on_conflict = true # default: true # Don't wait for in-progress status checks on a PR to finish before updating the # branch. optimistic_updates = false # default: true # Don't wait for specified status checks when merging a PR. If a configured # status check is incomplete when a PR is being merged, Kodiak will skip the PR. # Use this option for status checks that run indefinitely, like deploy jobs or # the WIP GitHub App. dont_wait_on_status_checks = [] # default: [], options: list of check names (e.g. ["ci/circleci: lint_api"]) # DEPRECATED # # Prefer `update.always`, which will deliver better behavior in most use cases. # `merge.update_branch_immediately` only affects PRs eligible for merging, while # `update.always` will keep all PRs up-to-date. # # Update PRs that are passing all branch requirements or are waiting for status # checks to pass. update_branch_immediately = false # default: false # If a PR is passing all checks and is able to be merged, merge it without # placing it in the merge queue. This option adds some unfairness where PRs # waiting in the queue the longest are not served first. prioritize_ready_to_merge = false # default: false # Never merge a PR. This option can be used with `update.always` to ``` -------------------------------- ### Kodiak Configuration File Example Source: https://github.com/chdsbd/kodiak/blob/master/bot/kodiak/test/fixtures/config_utils/pydantic-error.md A basic example of a Kodiak configuration file using TOML format. Ensure the version is set correctly according to Kodiak's requirements. ```toml version = 12 ``` -------------------------------- ### Install Dependencies and Run Scripts Source: https://github.com/chdsbd/kodiak/blob/master/web_ui/README.md Installs project dependencies using yarn and provides commands for development, testing, linting, and building the application. ```console # install dependencies yarn install # copy & modify example .env file cp example.env .env s/dev s/test s/lint s/build ``` -------------------------------- ### Build and Run Kodiak with Docker Compose Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/contributing.md Build the Docker images and start the Kodiak service using docker-compose. This is part of the integration testing setup. ```bash docker-compose build docker-compose up ``` -------------------------------- ### Start ngrok for Docker Integration Testing Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/contributing.md Start an ngrok tunnel on port 3000 to make your local machine accessible for the GitHub app webhook during Docker integration tests. ```bash ngrok http 3000 ``` -------------------------------- ### Example Ignored Usernames Configuration Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/config-reference.md Illustrates how to specify a list of usernames that Kodiak should ignore for updates. ```toml update.ignored_usernames = ["bernard-lowe", "dependabot-preview"] ``` -------------------------------- ### Run Production App Server Source: https://github.com/chdsbd/kodiak/blob/master/web_api/README.md Starts the production application server using Gunicorn, binding to all available network interfaces on the specified port. ```console # run production app server .venv/bin/gunicorn --bind 0.0.0.0:$PORT web_api.wsgi ``` -------------------------------- ### Run Kodiak Development Server Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/contributing.md Start the Kodiak development server using uvicorn. Replace placeholder values with your actual GitHub App ID, private key path, and shared secret. ```bash SECRET_KEY=$SHARED_SECRET GITHUB_PRIVATE_KEY_PATH=$GH_PRIVATE_KEY_PATH GITHUB_APP_ID=$GITHUB_APP_ID poetry run uvicorn kodiak.main:app ``` -------------------------------- ### Heroku Setup for Kodiak Deployment Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/self-hosting.md This script sets up a unique Heroku application, configures it to use a container stack, logs into the Heroku container registry, pulls the latest Kodiak Docker image, tags it for Heroku, and pushes it to the registry. It also includes commands for setting essential environment variables like GitHub App ID, secret key, private key, and app name, along with optional configurations for Sentry, GitHub Enterprise API URLs, and custom API headers. Finally, it provisions a Redis add-on and releases the containerized web application. ```shell # a unique name for the heroku app export APP_NAME='kodiak-prod' # create app with container stack heroku apps:create $APP_NAME heroku stack:set container -a $APP_NAME # login to registry heroku container:login # download latest release from docker hub and tag for push to heroku docker pull cdignam/kodiak docker tag cdignam/kodiak registry.heroku.com/$APP_NAME/web # push tagged image to Heroku docker push registry.heroku.com/$APP_NAME/web # create gihub app at https://developer.github.com/apps/building-github-apps/creating-a-github-app/ # The APP_ID and PRIVATE_KEY are needed to run the app. You must also set a SECRET_KEY to pass to the app. # configure app environment (this can also be done through the Heroku web ui) heroku config:set -a $APP_NAME GITHUB_APP_ID='' SECRET_KEY='' GITHUB_PRIVATE_KEY="$(cat github_private_key.pem)" GITHUB_APP_NAME='' # (optional) configure your Sentry DSN to report any errors Kodiak encounters heroku config:set -a $APP_NAME SENTRY_DSN='' # (optional) GitHub Enterprise users should set their v3 and v4 GitHub API URLs # # GITHUB_V3_API_ROOT # default: https://api.github.com # examples: https://github.acme-corp.intern/api/v3 # http(s)://[hostname]/api/v3 # # GITHUB_V4_API_URL # default: https://api.github.com/graphql # examples: https://github.acme-corp.intern/api/graphql # http(s)://[hostname]/api/graphql heroku config:set -a $APP_NAME GITHUB_V3_API_ROOT="" heroku config:set -a $APP_NAME GITHUB_V4_API_URL="" # (optional) Some GitHub Enterprise users require an extra header for API requests. # # GITHUB_API_HEADER_NAME # default: null # # GITHUB_API_HEADER_VALUE # default: null # # If your API required the following `X-Acme-Api` header, # X-Acme-Api: MyAcmeToken # # Your headers would be the following # GITHUB_API_HEADER_NAME='X-Acme-Api' # GITHUB_API_HEADER_VALUE='MyAcmeToken' # heroku config:set -a $APP_NAME GITHUB_API_HEADER_NAME="" heroku config:set -a $APP_NAME GITHUB_API_HEADER_VALUE="" # Redis v5 is required and provided by RedisCloud heroku addons:create -a $APP_NAME rediscloud:30 --wait # release app heroku container:release web -a $APP_NAME ``` -------------------------------- ### Example Commit Message with PR URL Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/config-reference.md Demonstrates how the `merge.message.include_pull_request_url` setting appends the PR URL to the commit message body. ```text Add new github login flow (#17) This change adds the new GitHub social login flow. PR-URL: https://github.com/ghost/app/pull/17 ``` -------------------------------- ### Start ngrok for Webhook Tunneling Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/contributing.md Use ngrok to create a tunnel for your local development server to receive webhook events from GitHub. Ensure you append the correct API path and use the HTTPS URL. ```bash ngrok http 8000 ``` -------------------------------- ### Example Commit with Co-authors Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/config-reference.md Demonstrates how the `merge.message.include_coauthors` option adds `Co-authored-by` trailers to merge commit messages when a PR includes commits from multiple authors. This trailer syntax is used by GitHub for attributing commits. ```text Add new github login flow (#17) This change adds the new GitHub social login flow. Steve provided some great UI tweaks. Co-authored-by: Steve Dignam <7340772+sbdchd@users.noreply.github.com> ``` -------------------------------- ### Run Tests with Pytest Source: https://github.com/chdsbd/kodiak/blob/master/bot/README.md Executes the project's tests using Pytest. Custom Pytest flags can be passed directly, for example: `s/test -s --pdb`. ```shell s/test ``` -------------------------------- ### Create Mock Pull Request Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/contributing.md A shell function to automate the creation of a mock pull request for testing. Requires the 'hub' tool to be installed. This function pulls the latest changes, creates a new branch, adds a file, commits, pushes, and opens a pull request. ```bash create_mock_pr() { git pull && uuidgen >> "$(uuidgen).txt" && git checkout -b $(uuidgen) && git add . && git commit -am $(uuidgen) && git push --set-upstream origin $(git symbolic-ref --short HEAD) && hub pull-request -l automerge -m "$(uuidgen)" && git checkout master } ``` -------------------------------- ### Configure Dependabot with Automerge Label Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/recipes.md Set up Dependabot to add a specific label ('automerge') to its pull requests, enabling Kodiak to automatically merge them. This example uses npm. ```yaml # dependabot.yml # Specify labels for pull requests version = 2 updates: - package-ecosystem: "npm" directory: "/" schedule: interval: "daily" labels: - "dependencies" # Add default Kodiak `merge.automerge_label` - "automerge" ``` -------------------------------- ### Invalid Kodiak TOML Configuration Source: https://github.com/chdsbd/kodiak/blob/master/bot/kodiak/test/fixtures/config_utils/toml-error.md This snippet shows an example of an invalid TOML configuration file that would cause a parsing error in Kodiak. ```toml [[[ version = 12 ``` -------------------------------- ### Development and Testing Commands Source: https://github.com/chdsbd/kodiak/blob/master/web_api/README.md Commands for running development, testing, linting, and building processes. ```console s/dev s/test s/lint s/build ``` -------------------------------- ### Deploy Dashboard Service with Ansible Source: https://github.com/chdsbd/kodiak/blob/master/infrastructure/README.md Runs the Ansible playbook to deploy the dashboard service. Use the `--check` flag for a dry run. Ensure you are in the `/kodiak` directory and specify the correct target. ```shell # /kodiak # note: # - when deploying to prod, don't forget to change the target # - use the `--check` flag to see what changes will occur before making them ansible-playbook -e 'target=kodiak_staging_ingestor' infrastructure/playbooks/dashboard-deploy.yml ``` -------------------------------- ### TOML Configuration for Update Labels Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/config-reference.md Shows how to configure `merge.automerge_label` and `update.autoupdate_label` in a TOML file. ```toml version = 1 [merge] automerge_label = "ship it!" [update] autoupdate_label = "update me please!" ``` -------------------------------- ### Custom Merge Commit Messages Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/recipes.md Configure Kodiak to use the pull request title and body for merge commits, providing cleaner and more informative messages. This example also includes the PR number and strips HTML comments from the body. ```toml # .kodiak.toml version = 1 [merge.message] # use title of PR for merge commit. title = "pull_request_title" # default: "github_default" # use body of PR for merge commit. body = "pull_request_body" # default: "github_default" # add the PR number to the merge commit title, like GitHub. include_pr_number = true # default: true # use the default markdown content of the PR for the merge commit. body_type = "markdown" # default: "markdown" # remove html comments to auto remove PR templates. strip_html_comments = true # default: false ``` -------------------------------- ### Merge Method Options Table Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/config-reference.md A reference table showing the available labels for setting different merge methods in Kodiak. ```markdown | merge method | label | | ------------ | --------------------------------- | | merge | `kodiak: merge.method = 'merge'` | | squash | `kodiak: merge.method = 'squash'` | | rebase | `kodiak: merge.method = 'rebase'` | ``` -------------------------------- ### Prioritize Ready-to-Merge Pull Requests Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/recipes.md Enable this setting to bypass the merge queue for pull requests that can be merged immediately. This can speed up the merge process for straightforward changes. ```toml # .kodiak.toml version = 1 [merge] # if a PR is ready, merge it, don't place it in the merge queue. prioritize_ready_to_merge = true # default: false [update] # immediately update a pull request's branch when outdated. always = true # default: false ``` -------------------------------- ### Minimal Kodiak Configuration Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/quickstart.md This is the minimal configuration required for Kodiak. The 'version' field is mandatory. ```toml # .kodiak.toml # Minimal config. version is the only required field. version = 1 ``` -------------------------------- ### Ansible Inventory Configuration Source: https://github.com/chdsbd/kodiak/blob/master/infrastructure/README.md Defines the structure for Ansible to manage hosts in production and staging environments. Ensure 'ansible_host' points to the correct IP addresses. ```yaml --- all: children: kodiak_prod: hosts: kodiak_prod_app_server: ansible_host: 255.255.255.255 ansible_user: root ansible_python_interpreter: /usr/bin/python3 kodiak_prod_ingestor: ansible_host: 255.255.255.255 ansible_user: root ansible_python_interpreter: /usr/bin/python3 kodiak_staging: hosts: kodiak_staging_ingestor: ansible_host: 255.255.255.255 ansible_user: root ansible_python_interpreter: /usr/bin/python3 kodiak_prod_app_server: ansible_host: 255.255.255.255 ansible_user: root ansible_python_interpreter: /usr/bin/python3 ``` -------------------------------- ### Generate Configuration Schema Source: https://github.com/chdsbd/kodiak/blob/master/bot/README.md Updates the JSON schema for configuration files. This command should be run after making any changes related to configuration settings. ```shell poetry run kodiak gen-conf-json-schema > kodiak/test/fixtures/config/config-schema.json ``` -------------------------------- ### Configure Automatic Approvals Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/config-reference.md Set up automatic approvals for pull requests based on the author's username or assigned labels. This streamlines the review process for trusted contributors or specific types of changes. ```toml [approve] auto_approve_usernames = ["dependabot"] auto_approve_labels = ["dependencies"] ``` -------------------------------- ### Automerge Dependabot PRs by Version Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/recipes.md Configure Kodiak to automatically merge Dependabot PRs for specific version upgrade types (minor, patch). Requires Dependabot to open PRs with the 'ship it!' label. ```toml # .kodiak.toml [merge] automerge_label = "ship it!" [merge.automerge_dependencies] # auto merge all PRs opened by "dependabot" that are "minor" or "patch" version upgrades. "major" version upgrades will be ignored. versions = ["minor", "patch"] usernames = ["dependabot"] # if using `update.always`, add dependabot to `update.ignore_usernames` to allow # dependabot to update and close stale dependency upgrades. [update] ignored_usernames = ["dependabot"] ``` -------------------------------- ### Ingest Events for Analysis Source: https://github.com/chdsbd/kodiak/blob/master/web_api/README.md Continuously runs the command to ingest events for analysis. This command should be run as a long-running process. ```console # ingest events for analysis (run continuously) ./manage.py ingest_events ``` -------------------------------- ### Configure Dependency Automerge Usernames Only Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/config-reference.md Specify a list of usernames for whom dependency upgrades will be automerged. This setting works in conjunction with version restrictions. ```toml # .kodiak.toml [merge.automerge_dependencies] versions = ["minor", "patch"] # automerge by upgrade version for pull requests authored by dependabot or renovate. usernames = ["dependabot", "renovate"] ``` -------------------------------- ### Configure Dependency Automerge Versions and Usernames Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/config-reference.md Control which types of dependency upgrades (major, minor, patch) are eligible for automerge and specify the allowed authors for these upgrades. This requires the PR to pass branch protection rules. ```toml # .kodiak.toml [merge.automerge_dependencies] # only auto merge "minor" and "patch" version upgrades. # do not automerge "major" version upgrades. versions = ["minor", "patch"] usernames = ["dependabot", "renovate"] ``` -------------------------------- ### Configure Blocking Labels for Merging Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/config-reference.md Specify labels that should block merging. This setting is an alias for `merge.blacklist_labels`. ```yaml merge.blocking_labels = ["wip"] ``` -------------------------------- ### Configure Status Checks to Skip Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/config-reference.md Define a list of status checks that Kodiak should not wait for when merging a PR. Useful for checks that run indefinitely. ```yaml merge.dont_wait_on_status_checks = ["ci/circleci: deploy", "WIP"] ``` -------------------------------- ### Approve Dependabot PRs Automatically Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/recipes.md Configure Kodiak to automatically approve pull requests from specified usernames (e.g., 'dependabot') when GitHub Branch Protection requires approvals. This allows for fully automated merging of Dependabot PRs. ```toml # .kodiak.toml version = 1 [approve] # note: remove the "[bot]" suffix from GitHub Bot usernames. # Instead of "dependabot[bot]" use "dependabot". auto_approve_usernames = ["dependabot"] # if using `update.always`, add dependabot to `update.ignore_usernames` to allow # dependabot to update and close stale dependency upgrades. [update] ignored_usernames = ["dependabot"] ``` -------------------------------- ### Aggregate User Pull Request Activity Source: https://github.com/chdsbd/kodiak/blob/master/web_api/README.md Aggregates user pull request activity data. This command is also intended to be run on a cron schedule. ```console # aggregate user activity (run on cron) ./manage.py aggregate_user_pull_request_activity ``` -------------------------------- ### Release New Kodiak Version to Heroku Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/contributing.md Deploy a new version of Kodiak to Heroku. This involves pulling a specific Docker image, tagging it for Heroku, pushing it, and releasing the container. ```bash GIT_SHA='62fcc1870b609f43b95de41b8be41a2858eb56bd' APP_NAME='kodiak-prod' docker pull cdignam/kodiak:$GIT_SHA docker tag cdignam/kodiak:$GIT_SHA registry.heroku.com/$APP_NAME/web docker push registry.heroku.com/$APP_NAME/web heroku container:release -a $APP_NAME web ``` -------------------------------- ### Sync PRs with Master Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/recipes.md Automatically update all pull requests whenever the target branch updates. This ensures PRs are always up-to-date with the main branch. ```toml # .kodiak.toml version = 1 [update] always = true # default: false require_automerge_label = false # default: true ``` -------------------------------- ### Aggregate Pull Request Activity Source: https://github.com/chdsbd/kodiak/blob/master/web_api/README.md Aggregates pull request activity data. This command is intended to be run on a cron schedule. ```console # aggregate events into chartable data (run on cron) ./manage.py aggregate_pull_request_activity ``` -------------------------------- ### Kodiak Outgoing IP Addresses Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/troubleshooting.md When using GitHub Enterprise with an IP allow list, add these outgoing IP addresses to your allow list to ensure Kodiak can run. ```text 174.138.118.176 165.227.248.81 ``` -------------------------------- ### Kodiak Configuration Error Message (Pretty) Source: https://github.com/chdsbd/kodiak/blob/master/bot/kodiak/test/fixtures/config_utils/pydantic-error.md The pretty-formatted error message displayed when a Kodiak configuration file has an invalid version. This format is human-readable and highlights the specific validation issue. ```text # pretty 1 validation error for V1 version Version must be `1` (type=value_error.invalidversion) ``` -------------------------------- ### Set Multiple Automerge Labels Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/config-reference.md Specify an array of labels; if any of these labels are present on a pull request, Kodiak will consider it for automerging. ```toml merge.automerge_label = ["🚢 it!", "merge it!"] ``` -------------------------------- ### Configure Merge Commit Message Source: https://github.com/chdsbd/kodiak/blob/master/docs/docs/config-reference.md Customize the title and body of merge commits. Options include using GitHub's default, the PR title, or custom content. This affects how PR information is presented in the commit history. ```toml do_not_merge = false [merge.message] title = "github_default" body = "github_default" include_pull_request_author = false include_pull_request_url = false include_pr_number = true body_type = "markdown" strip_html_comments = false cut_body_before = "" ``` -------------------------------- ### Kodiak Configuration Error Message (JSON) Source: https://github.com/chdsbd/kodiak/blob/master/bot/kodiak/test/fixtures/config_utils/pydantic-error.md The JSON-formatted error message for an invalid Kodiak configuration version. This format is useful for programmatic parsing and handling of validation errors. ```json [ { "loc": [ "version" ], "msg": "Version must be `1`", "type": "value_error.invalidversion" } ] ```