Skip to content

Commit

Permalink
Update CONTRIBUTING.md and add dotnet-format to the SDK (dropbox#203)
Browse files Browse the repository at this point in the history
* Update CONTRIBUTING.md and add dotnet-format to the SDK

* restore before running dotnet-format

* explicitly restore .sln before linting

* checkout before linting
  • Loading branch information
connorworley authored Jan 5, 2021
1 parent 46fc070 commit 3daf910
Show file tree
Hide file tree
Showing 39 changed files with 763 additions and 619 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@ jobs:
- name: Run Unit Tests
run: |
dotnet test dropbox-sdk-dotnet/Dropbox.Api.Unit.Tests
Linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run Linter
run: |
# Install latest dotnet-format
dotnet tool install -g dotnet-format --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json
dotnet restore dropbox-sdk-dotnet/
dotnet format --check --fix-whitespace --fix-style warn --fix-analyzers warn dropbox-sdk-dotnet/
55 changes: 36 additions & 19 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,56 @@ We are more than happy to recieve pull requests helping us improve the state of

2. Please add tests confirming the new functionality works. Pull requests will not be merged without passing continuous integration tests unless the pull requests aims to fix existing issues with these tests.

## Updating Generated Code
## Working with the SDK

Generated code can be updated by running the following code:
This guide is geared towards developing on a Linux machine. Visual Studio may or may not behave as expected.

```
$ git submodule init
$ git submodule update --remote --recursive
$ cd stone
$ python setup.py install
$ cd ..
$ python generate.py
```
You'll need to install the following tools.
* .NET 5.0
* PowerShell

Note: the `buildall.ps1` file also will update generated code so unless you are looking to explicitely test something new, this step is generally unnecessary
### Building

## Testing the Code
Building using the `dotnet` CLI is straightforward.

Tests live under the Dropbox.Api.Tests Project. Please fill in the dropbox.runsettings file with test tokens in order to successfully make calls to the Dropbox servers.
```sh
dotnet build dropbox-sdk-dotnet/Dropbox.Api/
```

The tests are run as a part of the build script we use, this can be run the following way:
### Running tests

```
powershell -ExecutionPolicy Bypass -File buildall.ps1 -testSettings <PATH_TO_TEST_SETTINGS>
Testing is also straightforward. Make sure to fill out `dropbox-sdk-dotnet/Dropbox.Api.Integration.Tests/dropbox.runsettings` before running integration tests.

```sh
dotnet test dropbox-sdk-dotnet/Dropbox.Api.Unit.Tests/
dotnet test dropbox-sdk-dotnet/Dropbox.Api.Integration.Tests/
```

Where test settings is the `dropbox.runsettings` file mentioned above.
### Linting

If you need to test the documentation, you can add the `-doc` flag to the build command to also generate that.
You can use [dotnet-format](https://github.com/dotnet/format) to lint from the command line.

```sh
# Install a recent dotnet-format build
dotnet tool install -g dotnet-format --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json
# Optionally omit `--check` to auto-fix lint issues
dotnet format --check --fix-whitespace --fix-style info --fix-analyzers info dropbox-sdk-dotnet/
```
powershell -ExecutionPolicy Bypass -File buildall.ps1 -testSettings <PATH_TO_TEST_SETTINGS> -doc

### Updating Generated Code

Install PowerShell and execute `./scripts/generate_stone.ps1` to regenerate Stone types.

```sh
git submodule init
git submodule update --remote --recursive
./scripts/generate_stone.ps1
```

### Cutting New Versions (for Dropboxers)

To cut a new version, create a new GitHub release using `vX.Y.Z` as the tag name. GitHub Actions will automatically build the SDK and publish it to NuGet as version `X.Y.Z`.

[issues]: https://github.com/dropbox/dropbox-sdk-dotnet/issues
[pr]: https://github.com/dropbox/dropbox-sdk-dotnet/pulls
[coc]: https://github.com/dropbox/dropbox-sdk-dotnet/blob/main/CODE_OF_CONDUCT.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<RunSettingsFilePath>dropbox.runsettings</RunSettingsFilePath>

<IsPackable>false</IsPackable>

<CodeAnalysisRuleSet>../stylecop.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
Expand All @@ -15,6 +17,14 @@
<PackageReference Include="coverlet.collector" Version="1.3.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<AdditionalFiles Include="../stylecop.json" Link="stylecop.json" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Dropbox.Api\Dropbox.Api.csproj" />
</ItemGroup>
Expand Down
Loading

0 comments on commit 3daf910

Please sign in to comment.