From 5443ca2197599a0e45d7a1c1e9dfce10bc39158d Mon Sep 17 00:00:00 2001 From: Isaiah Inuwa Date: Sun, 27 Dec 2020 22:14:50 -0600 Subject: [PATCH 1/3] Make shell examples easier to copy --- README.md | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 80b5df3e..58a48aad 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,10 @@ probably want [Dependabot][dependabot] itself. ## Setup and usage -* `rbenv install` (Install Ruby version from `.ruby-version`) -* `bundle install` +```shell +rbenv install # (Install Ruby version from ./.ruby-version) +bundle install +``` ### Native helpers @@ -20,10 +22,12 @@ To install the native helpers, export an environment variable that points to the directory into which the helpers should be installed and add the relevant bins to your PATH: -* `export DEPENDABOT_NATIVE_HELPERS_PATH="$(pwd)/native-helpers"` -* `mkdir -p $DEPENDABOT_NATIVE_HELPERS_PATH/{terraform,python,dep,go_modules,hex,composer,npm_and_yarn}` -* `export PATH="$PATH:$DEPENDABOT_NATIVE_HELPERS_PATH/terraform/bin:$DEPENDABOT_NATIVE_HELPERS_PATH/python/bin:$DEPENDABOT_NATIVE_HELPERS_PATH/go_modules/bin:$DEPENDABOT_NATIVE_HELPERS_PATH/dep/bin"` -* `export MIX_HOME="$DEPENDABOT_NATIVE_HELPERS_PATH/hex/mix"` +```shell +export DEPENDABOT_NATIVE_HELPERS_PATH="$(pwd)/native-helpers" +mkdir -p $DEPENDABOT_NATIVE_HELPERS_PATH/{terraform,python,dep,go_modules,hex,composer,npm_and_yarn} +export PATH="$PATH:$DEPENDABOT_NATIVE_HELPERS_PATH/terraform/bin:$DEPENDABOT_NATIVE_HELPERS_PATH/python/bin:$DEPENDABOT_NATIVE_HELPERS_PATH/go_modules/bin:$DEPENDABOT_NATIVE_HELPERS_PATH/dep/bin" +export MIX_HOME="$DEPENDABOT_NATIVE_HELPERS_PATH/hex/mix" +``` Copy the relevant helpers from the gem source to the new install location @@ -69,21 +73,21 @@ Steps: 1. Pull dependabot-core Docker image -```shell -$ docker pull dependabot/dependabot-core -``` + ```shell + $ docker pull dependabot/dependabot-core + ``` 2. Install dependencies -```shell -docker run -v "$(pwd):/home/dependabot/dependabot-script" -w /home/dependabot/dependabot-script dependabot/dependabot-core bundle install -j 3 --path vendor -``` + ```shell + docker run -v "$(pwd):/home/dependabot/dependabot-script" -w /home/dependabot/dependabot-script dependabot/dependabot-core bundle install -j 3 --path vendor + ``` 3. Run dependabot -```shell -docker run -v "$(pwd):/home/dependabot/dependabot-script" -w /home/dependabot/dependabot-script -e ENV_VARIABLE=value dependabot/dependabot-core bundle exec ruby ./generic-update-script.rb -``` + ```shell + docker run -v "$(pwd):/home/dependabot/dependabot-script" -w /home/dependabot/dependabot-script -e ENV_VARIABLE=value dependabot/dependabot-core bundle exec ruby ./generic-update-script.rb + ``` You'll have to pass the right environment variables to make the script work with your configuration. You can find how to pass environment variables to your container in [Docker run reference](https://docs.docker.com/engine/reference/run/#env-environment-variables). From 1c5f53d8373a635a83b52522f0b847d9d29fba38 Mon Sep 17 00:00:00 2001 From: Isaiah Inuwa Date: Sun, 27 Dec 2020 22:45:48 -0600 Subject: [PATCH 2/3] Explicitly document environment variables --- README.md | 73 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 58a48aad..11c1bc74 100644 --- a/README.md +++ b/README.md @@ -53,10 +53,56 @@ Build the helpers you want to use (you'll also need the corresponding language i | PHP | `$DEPENDABOT_NATIVE_HELPERS_PATH/composer/helpers/build $DEPENDABOT_NATIVE_HELPERS_PATH/composer` | | JS | `$DEPENDABOT_NATIVE_HELPERS_PATH/npm_and_yarn/helpers/build $DEPENDABOT_NATIVE_HELPERS_PATH/npm_and_yarn` | +### Environment Variables + +The update scripts are configured using environment variables. The available +variables are listed in the table below. (See +[./generic-update-script.rb][generic-script] for more context.) + +Variable Name | Default | Notes +:------------ | :--------------- | :---- +`DIRECTORY_PATH ` | `/` | Directory where the base dependency files are. +`PACKAGE_MANAGER` | `bundler` | Valid values: `bundler`, `cargo`, `composer`, `dep`, `docker`, `elm`, `go_modules`, `gradle`, `hex`, `maven`, `npm_and_yarn`, `nuget`, `pip` (includes pipenv), `submodules`, `terraform` +`PROJECT_PATH` | None. Required. | Path to repository. Usually in the format `/`. +`PULL_REQUEST_ASSIGNEE` | None. Optional. | User to assign to the created pull request. + +There are other variables that you must pass to your container that will depend on the Git source you use: + +**Github** + +Variable | Default +:------- | :------ +GITHUB_ACCESS_TOKEN | None. Required. + +**Github Enterprise** + +Variable | Default +:------- | :------ +GITHUB_ENTERPRISE_ACCESS_TOKEN | None. Required. +GITHUB_ENTERPRISE_HOSTNAME | None. Required. + +**Gitlab** + +Variable | Default +:------- | :------ +GITLAB_ACCESS_TOKEN | None. Required. +GITLAB_AUTO_MERGE | None. Optional. +GITLAB_HOSTNAME | `gitlab.com` +GITLAB_ASSIGNEE_ID | None. Deprecated. Use `PULL_REQUEST_ASSIGNEE` instead. + +**Azure DevOps** + +Variable | Default +:------- | :------ +AZURE_ACCESS_TOKEN | None. Required. +AZURE_HOSTNAME | `dev.azure.com` + +Also note that the `PROJECT_PATH` variable should be in the format: `organization/project/_git/package-name`. + ### Running `update-script.rb` * `bundle exec irb` -* Edit the variables at the top of the script you're using, or set the corresponding environment variables. +* Edit the variables at the top of the script you're using, or set the corresponding [environment variables](#environment-variables). * Copy and paste the script into the Ruby session to see how Dependabot works. If you run into any trouble with the above please create an issue! @@ -66,8 +112,10 @@ If you run into any trouble with the above please create an issue! If you don't want to setup the machine where the script will be executed, you could run the script within a `dependabot/dependabot-core` container. In order to do that, you'll have to pull the image from Docker Hub and mount your working directory into the container. -You'll also have to set several environment variables to make the script work with your configuration, -as specified in the documentation. + +You'll also have to set several [environment variables](#environment-variables) to make the script work with your configuration, as specified above. +(You can find how to pass environment variables to your container in [Docker run reference](https://docs.docker.com/engine/reference/run/#env-environment-variables).) + Steps: @@ -89,25 +137,6 @@ Steps: docker run -v "$(pwd):/home/dependabot/dependabot-script" -w /home/dependabot/dependabot-script -e ENV_VARIABLE=value dependabot/dependabot-core bundle exec ruby ./generic-update-script.rb ``` -You'll have to pass the right environment variables to make the script work with your configuration. You can find how to pass environment variables to your container in [Docker run reference](https://docs.docker.com/engine/reference/run/#env-environment-variables). - -You'll have to set some mandatory variables like `PROJECT_PATH` and `PACKAGE_MANAGER` (see [script](https://github.com/dependabot/dependabot-script/blob/master/generic-update-script.rb) to know more). -There are other variables that you must pass to your container that will depend on the Git source you use: - -* Github - * GITHUB_ACCESS_TOKEN -* Github Enterprise - * GITHUB_ENTERPRISE_HOSTNAME - * GITHUB_ENTERPRISE_ACCESS_TOKEN -* Gitlab - * GITLAB_HOSTNAME: default value `gitlab.com` - * GITLAB_ACCESS_TOKEN -* Azure DevOps - * AZURE_HOSTNAME: default value `dev.azure.com` - * AZURE_ACCESS_TOKEN - * PROJECT_PATH: `organization/project/_git/package-name` - - If everything goes well you should be able to see something like: ```shell From 252afdb3439f1ff6a3079dbfceec7a6249b1d155 Mon Sep 17 00:00:00 2001 From: Isaiah Inuwa Date: Sun, 27 Dec 2020 22:51:15 -0600 Subject: [PATCH 3/3] Document generic script execution. --- README.md | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 11c1bc74..c3a58e0b 100644 --- a/README.md +++ b/README.md @@ -99,14 +99,28 @@ AZURE_HOSTNAME | `dev.azure.com` Also note that the `PROJECT_PATH` variable should be in the format: `organization/project/_git/package-name`. -### Running `update-script.rb` +### Running dependabot -* `bundle exec irb` -* Edit the variables at the top of the script you're using, or set the corresponding [environment variables](#environment-variables). -* Copy and paste the script into the Ruby session to see how Dependabot works. +There are a few ways of running the script: + * interactively with `./update-script.rb`, + * non-interactively with `./generic-update-script.rb`, + * and non-interactively using Docker. + +#### Running `update-script.rb` (GitHub only) + +1. `bundle exec irb` +2. Edit the variables at the top of the script you're using, or set the corresponding [environment variables](#environment-variables). +3. Copy and paste the script into the Ruby session to see how Dependabot works. If you run into any trouble with the above please create an issue! +#### Running `generic-update-script.rb` + +1. Configure your shell with the correct [environment variables](#environment-variables). +2. Execute the script with Bundler: + ```shell + bundle exec ruby ./generic-update-script.rb + ``` #### Running script with Docker If you don't want to setup the machine where the script will be executed, you could run the script within