diff --git a/docs/development/local-development.md b/docs/development/local-development.md index 852d41b4b90cd89c36e59a9fac874d5f32eca8ee..263a6bbb0c6fc4a79b9ffb38fb7672bf2dea957b 100644 --- a/docs/development/local-development.md +++ b/docs/development/local-development.md @@ -1,29 +1,30 @@ # Local Development -This document serves to give tips and tricks on how to run Renovate locally to add features or fix bugs. -Please submit PRs to improve it if you think anything is unclear or you can think of something that should be added. +This document gives tips and tricks on how to run Renovate locally to add features or fix bugs. +You can improve this documentation by opening a pull request. +For example, if you think anything is unclear, or you think something needs to be added, open a pull request! -## Install +## Installation -#### Prerequisites +### Prerequisites -For local development some dependencies are required: +You need the following dependencies for local development: - Git - Node.js `^12.13.0 || >=14.15.0` - Yarn `^1.17.0` - C++ compiler -- Python `^3.7` +- Python `^3.8` - Java between `8` and `12` -We support Node.js versions according to the [Node.js release schedule](https://github.com/nodejs/Release#release-schedule) +We support Node.js versions according to the [Node.js release schedule](https://github.com/nodejs/Release#release-schedule). -Java is required to execute Gradle in tests. -If you don’t have Java installed, the respective tests will be skipped. +You need Java to execute Gradle tests. +If you don’t have Java installed, the Gradle tests will be skipped. _Linux_ -You can use the following commands for `Ubuntu`. +You can use the following commands on Ubuntu. ```sh curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - @@ -37,16 +38,16 @@ You can also use [SDKMAN](https://sdkman.io/) to manage Java versions. _Windows_ -The following steps work to set up a brand new Windows 10 installation for developing Renovate. -If you already have some components installed, you can naturally skip them. +Follow these steps to set up your development environment on Windows 10. +If you already installed a component, skip the corresponding step. - Install [Git](https://git-scm.com/downloads). Make sure you've [configured your username and email](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup). -- Install [Node.js LTS](https://nodejs.org/en/download/) -- In an Administrator PowerShell prompt, run `npm install -global npm` and then `npm --add-python-to-path='true' --debug install --global windows-build-tools` -- Install [Yarn](https://yarnpkg.com/lang/en/docs/install/#windows-stable) -- Install Java, e.g. from [AdoptOpenJDK](https://adoptopenjdk.net/?variant=openjdk11) or any other distribution +- Install [Node.js LTS](https://nodejs.org/en/download/). +- In an Administrator PowerShell prompt, run `npm install -global npm` and then `npm --add-python-to-path='true' --debug install --global windows-build-tools`. +- Install [Yarn](https://yarnpkg.com/lang/en/docs/install/#windows-stable). +- Install Java, e.g. from [AdoptOpenJDK](https://adoptopenjdk.net/?variant=openjdk11) or any other distribution. - Verify you have everything installed with appropriate versions, e.g.: + Verify you're using the appropriate versions: ``` PS C:\Windows\system32> git --version @@ -75,56 +76,48 @@ If you are using [VS Code](https://code.visualstudio.com/) you can skip installi VS Code [integrated terminal](https://code.visualstudio.com/docs/editor/integrated-terminal) is now running in the container and can be used to run additional commands. -#### Fork and Clone +## Fork and Clone -If you will contribute to the project, you should first "fork" the main project using the GitHub Website and then clone your fork locally. +If you want to contribute to the project, you should first "fork" the main project using the GitHub Website and then clone your fork locally. +The Renovate project uses the [Yarn](https://github.com/yarnpkg/yarn) package management system instead of npm. -#### Install dependencies +To ensure everything is working properly on your end, you must: -We use [Yarn](https://github.com/yarnpkg/yarn) so run `yarn install` to install dependencies instead of `npm install`. +1. Make sure you don't have a local `.npmrc` file that overrides npm's default registry. +1. Install all dependencies with `yarn install`. +1. Make a build with `yarn build`, which should pass with no errors. +1. Verify all tests pass and have 100% test coverage, by running `yarn test`. +1. Verify the installation by running `yarn start`. You must see this error: `Fatal error: No authentication found for platform https://api.github.com/ (github)` -#### Build Renovate +You only need to do these 5 steps this one time. -Run `yarn build`. -You should get no errors. +Before you submit a pull request you should: -#### Verify tests - -Run `yarn test`. -You should see it pass with 100% test coverage. -Make sure you've run `yarn build` first. - -#### Verify installation - -Run `yarn start`. -You should see this error: - -``` -Fatal error: No authentication found for platform https://api.github.com/ (github) -``` +1. Install newer dependencies with `yarn install`. +1. Run the tests with `yarn test`. ## Platform Account Setup -Although it's possible to make small source code improvements without testing against a real repository, in most cases it's important that you run a "real" test on a repository before you submit a feature or fix. +Although it's possible to make small source code improvements without testing against a real repository, in most cases you should run a "real" test on a repository before you submit a feature or fix. It's possible to do this against GitHub, GitLab or Bitbucket public servers. -#### Register new account (optional) +### Register new account (optional) If you're going to be doing a lot of Renovate development then it's recommended that you set up a dedicated test account on GitHub or GitLab, so that you reduce the risk that you accidentally cause problems when testing out Renovate. e.g. if your GitHub username is "alex88" then maybe you register "alex88-testing" for use with Renovate. -#### Generate platform token +### Generate platform token Once you have decided on your platform and account, log in and [generate a "Personal Access Token"](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/) that can be used to authenticate Renovate. Select **repo** scope when generating the token. -#### Export platform token +### Export platform token Although you can specify a token to Renovate using `--token=`, it can be inconvenient if you need to include this every time. You are better off to instead export the Environment Variable `RENOVATE_TOKEN` for this. -#### Run against a real repo +### Run against a real repo To make sure everything is working, create a test repo in your account, e.g. like `https://github.com/r4harry/testrepo1`. Now, add a file called `.nvmrc` with the content `8.13.0`. @@ -136,23 +129,22 @@ If this is working then in future you can create other test repos to verify your ## Tests You can run `yarn test` locally to test your code. -We test all PRs using the same tests, run on CircleCI and Azure Pipelines. `yarn test` runs an `eslint` check, a `prettier` check, a `type` check and then all the unit tests using `jest`. +We test all PRs using the same tests, run on GitHub Actions. +`yarn test` runs an `eslint` check, a `prettier` check, a `type` check and then all the unit tests using `jest`. -## Jest - -You can run just the Jest unit tests by running `yarn jest`. -You can also run just a subset of the Jest tests using file matching, e.g. `yarn jest composer` or `yarn jest workers/branch`. -If you get a test failure due to a "snapshot" mismatch, and you are sure that you need to update the snapshot, then you can append `-u` to the end. -e.g. `yarn jest composer -u` would update the saved snapshots for _all_ tests in `test/manager/composer/*`. - -#### Prerequisites +### Prerequisites You need to have Python with `mock` installed for all tests to pass. Python 3 includes `mock` so that approach is recommended. -You also need to make sure that you don't have a local `.npmrc` file that overrides npm's default registry. +### Jest + +You can run just the Jest unit tests by running `yarn jest`. +You can also run just a subset of the Jest tests using file matching, e.g. `yarn jest composer` or `yarn jest workers/branch`. +If you get a test failure due to a "snapshot" mismatch, and you are sure that you need to update the snapshot, then you can append `-u` to the end. +e.g. `yarn jest composer -u` would update the saved snapshots for _all_ tests in `**/composer/**`. -#### Coverage +### Coverage The Renovate project maintains 100% test coverage, so any Pull Request will fail if it does not contain full coverage for code. Using `// istanbul ignore` is not ideal but sometimes is a pragmatic solution if an additional test wouldn't really prove anything. @@ -163,7 +155,7 @@ Do not let coverage put you off submitting a PR! Maybe we can help, or at least guide. Also, it can be good to submit your PR as a work in progress (WIP) without tests first so that you can get a thumbs up from others about the changes, and write tests after. -#### Linting and formatting +## Linting and formatting We use [Prettier](https://github.com/prettier/prettier) for code formatting. If your code fails `yarn test` due to a `prettier` rule then run `yarn lint-fix` to fix it or most `eslint` errors automatically before running `yarn test` again. @@ -181,7 +173,7 @@ Then, make sure your fork is up to date with `master` each time before creating ## Tips and tricks -#### Running Renovate against forked repositories +### Running Renovate against forked repositories Quite often, the quickest way for you to test or fix something is to fork an existing repository. However, by default Renovate skips over repositories that are forked. @@ -190,7 +182,7 @@ To override this default, you need to specify the setting `includeForks` as `tru Option 1: Add `"includeForks": true` to the `renovate.json` of the repository Option 2: Run Renovate with the CLI flag `--renovate-fork=true` -#### Log files +### Log files Usually, `debug` is good enough to troubleshoot most problems or verify functionality. @@ -202,7 +194,7 @@ $ rm -f debug.log && yarn start myaccount/therepo --log-level=debug > debug.log The above will delete any existing `debug.log` and then save Renovate's output to that file. -#### Adding configuration options +### Adding configuration options We wish to keep backwards-compatibility as often as possible, as well as make the code configurable, so most new functionality should be controllable via configuration options.