Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
upsilon committed Dec 15, 2023
2 parents d479e7f + e4a828f commit 2dbbfa9
Show file tree
Hide file tree
Showing 146 changed files with 6,510 additions and 3,024 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* text=auto
*.sh eol=lf
144 changes: 8 additions & 136 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Build
name: Run msbuild

on:
push:
branches: ['develop', 'release']
pull_request:
workflow_call:
inputs:
msbuild_args:
type: string

env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
Expand All @@ -14,6 +15,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
Expand All @@ -37,144 +40,13 @@ jobs:
- name: Build
shell: pwsh
run: |
msbuild /target:restore,build "/p:Configuration=$($env:CONFIGURATION)" /p:DebugType=None /verbosity:minimal
msbuild /target:restore,build "/p:Configuration=$($env:CONFIGURATION)" /verbosity:minimal ${{ inputs.msbuild_args }}
- name: Upload build result
uses: actions/upload-artifact@v3
with:
name: build
path: |
./OpenTween/bin/
./OpenTween/obj/
./OpenTween.Tests/bin/
retention-days: 1

test:
runs-on: windows-2022
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1

- name: Set configuration env
shell: pwsh
run: |
if ($env:GITHUB_REF -eq 'refs/heads/release') {
echo 'CONFIGURATION=Release' >> $env:GITHUB_ENV
} else {
echo 'CONFIGURATION=Debug' >> $env:GITHUB_ENV
}
- uses: actions/cache@v3
with:
path: ${{ github.workspace }}/.nuget/packages
key: nuget-${{ hashFiles('*/*.csproj') }}
restore-keys: |
nuget-
- name: Restore build result
uses: actions/download-artifact@v3
with:
name: build

- name: Run tests
shell: pwsh
run: |
$altCoverVersion = '8.6.61'
$xunitVersion = '2.4.2'
$targetFramework = 'net48'
$altCoverPath = "$($env:NUGET_PACKAGES)\altcover\$($altCoverVersion)\tools\net472\AltCover.exe"
$xunitPath = "$($env:NUGET_PACKAGES)\xunit.runner.console\$($xunitVersion)\tools\net472\xunit.console.exe"
$p = Start-Process `
-FilePath $altCoverPath `
-ArgumentList (
'--inputDirectory',
".\OpenTween.Tests\bin\$($env:CONFIGURATION)\$($targetFramework)",
'--outputDirectory',
'.\__Instrumented\',
'--assemblyFilter',
'?^OpenTween(?!\.Tests)',
'--typeFilter',
'?^OpenTween\.',
'--fileFilter',
'\.Designer\.cs',
'--visibleBranches'
) `
-NoNewWindow `
-PassThru `
-Wait
if ($p.ExitCode -ne 0) {
exit $p.ExitCode
}
$p = Start-Process `
-FilePath $altCoverPath `
-ArgumentList (
'runner',
'--recorderDirectory',
'.\__Instrumented\',
'--executable',
$xunitPath,
'--',
'.\__Instrumented\OpenTween.Tests.dll'
) `
-NoNewWindow `
-PassThru `
-Wait
if ($p.ExitCode -ne 0) {
exit $p.ExitCode
}
- name: Upload test results to codecov
shell: pwsh
run: |
Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe
.\codecov.exe -f coverage.xml
package:
runs-on: windows-2022
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: '${{ github.event.pull_request.head.sha }}'

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1

- name: Set configuration env
shell: pwsh
run: |
if ($env:GITHUB_REF -eq 'refs/heads/release') {
echo 'CONFIGURATION=Release' >> $env:GITHUB_ENV
} else {
echo 'CONFIGURATION=Debug' >> $env:GITHUB_ENV
}
- name: Restore build result
uses: actions/download-artifact@v3
with:
name: build

- name: Build package
shell: powershell # runtime-versionを取得するため従来のPowershellを使用する
run: |
$env:PATH = $env:PATH + ';C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Msbuild\Current\Bin\Roslyn\'
$binDir = '.\OpenTween\bin\' + $env:CONFIGURATION + '\net48\'
$destPath = 'OpenTween.zip'
$headCommit = '${{ github.event.pull_request.head.sha }}'
.\tools\build-zip-archive.ps1 -BinDir $binDir -DestPath $destPath -HeadCommit $headCommit
- name: Upload build result
uses: actions/upload-artifact@v3
with:
name: package
path: |
./OpenTween.zip
57 changes: 57 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build reproducible zip archive

on:
push:
branches: ['develop', 'release']
pull_request:

env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages

jobs:
build:
uses: ./.github/workflows/build.yml
with:
# package のビルド時は *.pdb を生成しない (https://github.com/opentween/OpenTween/pull/256)
msbuild_args: /p:DebugType=None

package:
runs-on: windows-2022
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: '${{ github.event.pull_request.head.sha }}'

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1

- name: Set configuration env
shell: pwsh
run: |
if ($env:GITHUB_REF -eq 'refs/heads/release') {
echo 'CONFIGURATION=Release' >> $env:GITHUB_ENV
} else {
echo 'CONFIGURATION=Debug' >> $env:GITHUB_ENV
}
- name: Restore build result
uses: actions/download-artifact@v3
with:
name: build

- name: Build package
shell: powershell # runtime-versionを取得するため従来のPowershellを使用する
run: |
$env:PATH = $env:PATH + ';C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Msbuild\Current\Bin\Roslyn\'
$binDir = '.\OpenTween\bin\' + $env:CONFIGURATION + '\net48\'
$destPath = 'OpenTween.zip'
.\tools\build-zip-archive.ps1 -BinDir $binDir -DestPath $destPath
- name: Upload build result
uses: actions/upload-artifact@v3
with:
name: package
path: |
./OpenTween.zip
102 changes: 102 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Run tests

on:
push:
branches: ['develop', 'release']
pull_request:

env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages

jobs:
build:
uses: ./.github/workflows/build.yml

test:
runs-on: windows-2022
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1

- name: Set configuration env
shell: pwsh
run: |
if ($env:GITHUB_REF -eq 'refs/heads/release') {
echo 'CONFIGURATION=Release' >> $env:GITHUB_ENV
} else {
echo 'CONFIGURATION=Debug' >> $env:GITHUB_ENV
}
- uses: actions/cache@v3
with:
path: ${{ github.workspace }}/.nuget/packages
key: nuget-${{ hashFiles('*/*.csproj') }}
restore-keys: |
nuget-
- name: Restore build result
uses: actions/download-artifact@v3
with:
name: build

- name: Run tests
shell: pwsh
run: |
$altCoverVersion = '8.6.95'
$xunitVersion = '2.6.2'
$targetFramework = 'net48'
$altCoverPath = "$($env:NUGET_PACKAGES)\altcover\$($altCoverVersion)\tools\net472\AltCover.exe"
$xunitPath = "$($env:NUGET_PACKAGES)\xunit.runner.console\$($xunitVersion)\tools\net481\xunit.console.exe"
$p = Start-Process `
-FilePath $altCoverPath `
-ArgumentList (
'--inputDirectory',
".\OpenTween.Tests\bin\$($env:CONFIGURATION)\$($targetFramework)",
'--outputDirectory',
'.\__Instrumented\',
'--assemblyFilter',
'?^OpenTween(?!\.Tests)',
'--typeFilter',
'?^OpenTween\.',
'--fileFilter',
'\.Designer\.cs',
'--visibleBranches'
) `
-NoNewWindow `
-PassThru `
-Wait
if ($p.ExitCode -ne 0) {
exit $p.ExitCode
}
$p = Start-Process `
-FilePath $altCoverPath `
-ArgumentList (
'runner',
'--recorderDirectory',
'.\__Instrumented\',
'--executable',
$xunitPath,
'--',
'.\__Instrumented\OpenTween.Tests.dll'
) `
-NoNewWindow `
-PassThru `
-Wait
if ($p.ExitCode -ne 0) {
exit $p.ExitCode
}
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
4 changes: 4 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
更新履歴

==== Ver 3.10.0(2023/12/16)
* NEW: graphqlエンドポイント経由で取得した引用ツイートの表示に対応
* FIX: APIリクエストがタイムアウトした場合のキャンセル処理を改善

==== Ver 3.9.0(2023/12/03)
* NEW: graphqlエンドポイントに対するレートリミットの表示に対応
* CHG: タイムライン更新時に全件ではなく新着投稿のみ差分を取得する動作に変更
Expand Down
15 changes: 5 additions & 10 deletions OpenTween.Tests/Api/BitlyApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public async Task ShortenAsync_OAuth2Test()

bitly.EndUserAccessToken = "hogehoge";

var result = await bitly.ShortenAsync(new Uri("http://www.example.com/"), "bit.ly")
.ConfigureAwait(false);
var result = await bitly.ShortenAsync(new Uri("http://www.example.com/"), "bit.ly");
Assert.Equal("http://bit.ly/foo", result.OriginalString);

Assert.Equal(0, mockHandler.QueueCount);
Expand Down Expand Up @@ -96,8 +95,7 @@ public async Task ShortenAsync_LegacyApiKeyTest()
bitly.EndUserLoginName = "username";
bitly.EndUserApiKey = "hogehoge";

var result = await bitly.ShortenAsync(new Uri("http://www.example.com/"), "bit.ly")
.ConfigureAwait(false);
var result = await bitly.ShortenAsync(new Uri("http://www.example.com/"), "bit.ly");
Assert.Equal("http://bit.ly/foo", result.OriginalString);

Assert.Equal(0, mockHandler.QueueCount);
Expand All @@ -122,8 +120,7 @@ public async Task GetAccessTokenAsync_Test()
x.Headers.Authorization.Parameter
);

var body = await x.Content.ReadAsStringAsync()
.ConfigureAwait(false);
var body = await x.Content.ReadAsStringAsync();
var query = HttpUtility.ParseQueryString(body);

Assert.Equal("password", query["grant_type"]);
Expand All @@ -136,8 +133,7 @@ public async Task GetAccessTokenAsync_Test()
};
});

var result = await bitly.GetAccessTokenAsync("hogehoge", "tetete")
.ConfigureAwait(false);
var result = await bitly.GetAccessTokenAsync("hogehoge", "tetete");
Assert.Equal("abcdefg", result);

Assert.Equal(0, mockHandler.QueueCount);
Expand All @@ -158,8 +154,7 @@ public async Task GetAccessTokenAsync_ErrorResponseTest()
};
});

await Assert.ThrowsAsync<WebApiException>(() => bitly.GetAccessTokenAsync("hogehoge", "tetete"))
.ConfigureAwait(false);
await Assert.ThrowsAsync<WebApiException>(() => bitly.GetAccessTokenAsync("hogehoge", "tetete"));

Assert.Equal(0, mockHandler.QueueCount);
}
Expand Down
Loading

0 comments on commit 2dbbfa9

Please sign in to comment.