Skip to content

Commit ff96dea

Browse files
authored
ci: introduce github actions (#59)
1 parent c5c114d commit ff96dea

24 files changed

+367
-137
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @ferhatelmas
1+
* @ferhatelmas @peterdeme

.github/workflows/ci.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [master]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.head_ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
basic:
14+
name: Run tests
15+
runs-on: ubuntu-latest
16+
env:
17+
DOTNET_CLI_TELEMETRY_OPTOUT: "true"
18+
steps:
19+
- uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 0
22+
23+
- uses: wagoid/commitlint-github-action@v4
24+
25+
- name: Setup dotnet
26+
uses: actions/setup-dotnet@v1
27+
with:
28+
dotnet-version: 5.0.x
29+
30+
- name: Dependency cache
31+
uses: actions/cache@v2
32+
id: cache
33+
with:
34+
path: ~/.nuget/packages
35+
key: ${{ runner.os }}-nuget-${{ hashFiles('src/**/*.csproj') }}
36+
37+
- name: Install dependencies
38+
if: steps.cache.outputs.cache-hit != 'true'
39+
run: dotnet restore ./src
40+
41+
- name: Run tests
42+
run: dotnet test ./src/stream-net-tests
43+
env:
44+
STREAM_API_SECRET: ${{ secrets.STREAM_API_SECRET }}
45+
STREAM_API_KEY: ${{ secrets.STREAM_API_KEY }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Create release PR
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'The new version number. Example: 1.40.1'
8+
required: true
9+
10+
jobs:
11+
init_release:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0 # gives the changelog generator access to all previous commits
17+
18+
- name: Create release branch
19+
run: scripts/create_release_branch.sh "${{ github.event.inputs.version }}"
20+
21+
- name: Get changelog diff
22+
uses: actions/github-script@v5
23+
with:
24+
script: |
25+
const get_change_log_diff = require('./scripts/get_changelog_diff.js')
26+
core.exportVariable('CHANGELOG', get_change_log_diff())
27+
28+
- name: Open pull request
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
run: |
32+
gh pr create \
33+
-t "Release ${{ github.event.inputs.version }}" \
34+
-b "# :rocket: ${{ github.event.inputs.version }}
35+
Make sure to use squash & merge when merging!
36+
Once this is merged, another job will kick off automatically and publish the package.
37+
# :memo: Changelog
38+
${{ env.CHANGELOG }}"

.github/workflows/release.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- master
8+
9+
jobs:
10+
Release:
11+
if: github.event.pull_request.merged && startsWith(github.head_ref, 'release-')
12+
runs-on: ubuntu-latest
13+
env:
14+
DOTNET_CLI_TELEMETRY_OPTOUT: "true"
15+
steps:
16+
- uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 0
19+
20+
- uses: actions/github-script@v5
21+
with:
22+
script: |
23+
const get_change_log_diff = require('./scripts/get_changelog_diff.js')
24+
core.exportVariable('CHANGELOG', get_change_log_diff())
25+
26+
// Getting the release version from the PR source branch
27+
// Source branch looks like this: release-1.0.0
28+
const version = context.payload.pull_request.head.ref.split('-')[1]
29+
core.exportVariable('VERSION', version)
30+
31+
- name: Setup dotnet
32+
uses: actions/setup-dotnet@v1
33+
with:
34+
dotnet-version: "5.0.x"
35+
36+
- name: Create the package
37+
run: dotnet pack --configuration Release ./src
38+
39+
- name: Publish the package
40+
run: dotnet nuget push "./src/stream-net/bin/Release/*.nupkg" -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
41+
42+
- name: Create release on GitHub
43+
uses: ncipollo/release-action@v1
44+
with:
45+
body: ${{ env.CHANGELOG }}
46+
tag: ${{ env.VERSION }}
47+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/reviewdog.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: reviewdog
2+
on:
3+
pull_request:
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.head_ref }}
7+
cancel-in-progress: true
8+
9+
jobs:
10+
reviewdog:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- uses: reviewdog/action-setup@v1
16+
with:
17+
reviewdog_version: latest
18+
19+
- name: Setup dotnet
20+
uses: actions/setup-dotnet@v1
21+
with:
22+
dotnet-version: 5.0.x
23+
24+
- name: Reviewdog
25+
env:
26+
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
run: |
28+
dotnet build -clp:NoSummary -p:GenerateFullPaths=true --no-incremental --nologo -f net5.0 -v q src \
29+
| reviewdog -f=dotnet -name=dotnet -reporter=github-pr-review

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ nuget.exe
2020
.vs/
2121
.vscode/
2222
.envrc
23+
.runsettings

CONTRIBUTING.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# :recycle: Contributing
2+
3+
We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our [Contributor License Agreement (CLA)](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) first. See our license file for more details.
4+
5+
## Getting started
6+
7+
### Restore dependencies and build
8+
9+
Most IDEs automatically prompt you to restore the dependencies but if not, use this command:
10+
11+
```shell
12+
$ dotnet restore ./src
13+
```
14+
15+
Building:
16+
17+
```shell
18+
$ dotnet build ./src
19+
```
20+
21+
### Run tests
22+
23+
The tests we have are full fledged integration tests, meaning they will actually reach out to a Stream app. Hence the tests require at least two environment variables: `STREAM_API_KEY` and `STREAM_API_SECRET`.
24+
25+
To have these env vars available for the test running, you need to set up a `.runsettings` file in the root of the project (don't worry, it's gitignored).
26+
27+
> :bulb: Microsoft has a super detailed [documentation](https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file) about .runsettings file.
28+
29+
It needs to look like this:
30+
31+
```xml
32+
<?xml version="1.0" encoding="utf-8"?>
33+
<RunSettings>
34+
<RunConfiguration>
35+
<EnvironmentVariables>
36+
<STREAM_API_KEY>api_key_here</STREAM_API_KEY>
37+
<STREAM_API_SECRET>secret_key_here</STREAM_API_SECRET>
38+
</EnvironmentVariables>
39+
</RunConfiguration>
40+
</RunSettings>
41+
```
42+
43+
In CLI:
44+
```shell
45+
$ dotnet test -s .runsettings ./src/stream-net-tests
46+
```
47+
48+
Go to the next section to see how to use it in IDEs.
49+
50+
## Recommended tools for day-to-day development
51+
52+
### VS Code
53+
54+
For VS Code, the recommended extensions are:
55+
- [C#](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) by Microsoft
56+
- [.NET Core Test Explorer](https://marketplace.visualstudio.com/items?itemName=formulahendry.dotnet-test-explorer) by Jun Huan
57+
58+
Recommended settings (`.vscode/settings.json`):
59+
```json
60+
{
61+
"omnisharp.testRunSettings": ".runsettings",
62+
"dotnet-test-explorer.testProjectPath": "./src/stream-net-tests",
63+
}
64+
```
65+
66+
### Visual Studio
67+
68+
Follow [Microsoft's documentation](https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2022#specify-a-run-settings-file-in-the-ide) on how to set up `.runsettings` file.
69+
70+
### Rider
71+
72+
Follow [Jetbrain's documentation](https://www.jetbrains.com/help/rider/Reference__Options__Tools__Unit_Testing__MSTest.html) on how to set up `.runsettings` file.

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
stream-net
22
===========
33

4-
[![Build status](https://ci.appveyor.com/api/projects/status/nhnrdhf64clbcv19/branch/master?svg=true)](https://ci.appveyor.com/project/tbarbugli/stream-net/branch/master) [![NuGet Badge](https://buildstats.info/nuget/stream-net)](https://www.nuget.org/packages/stream-net/)
4+
[![Build status](https://github.com/GetStream/stream-net/actions/workflows/ci.yaml/badge.svg)](https://github.com/GetStream/stream-net/actions/workflows/ci.yaml) [![NuGet Badge](https://buildstats.info/nuget/stream-net)](https://www.nuget.org/packages/stream-net/)
55

66
[stream-net](https://github.com/GetStream/stream-net) is a .Net client for [Stream](https://getstream.io/).
77

@@ -192,6 +192,12 @@ Og og = await client.Og("https://google.com");
192192

193193
Project is licensed under the [BSD 3-Clause](LICENSE).
194194

195+
## Contributing
196+
197+
We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our [Contributor License Agreement (CLA)](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) first. See our license file for more details.
198+
199+
Head over to [CONTRIBUTING.md](./CONTRIBUTING.md) for some development tips.
200+
195201
## We are hiring!
196202

197203
We've recently closed a [$38 million Series B funding round](https://techcrunch.com/2021/03/04/stream-raises-38m-as-its-chat-and-activity-feed-apis-power-communications-for-1b-users/) and we keep actively growing.

VERSION

-46 Bytes
Binary file not shown.

appveyor.yml

-2.44 KB
Binary file not shown.

0 commit comments

Comments
 (0)