diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 5932c6e..9f4eb08 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -9,7 +9,7 @@ ] }, "jetbrains.resharper.globaltools": { - "version": "2022.1.1", + "version": "2022.2.3", "commands": [ "jb" ] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5c5861..7bbc108 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,6 @@ +on: [push, pull_request] name: Continuous Integration -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - jobs: inspect-code: name: Code Quality @@ -14,7 +9,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - # FIXME: Tools won't run in .NET 6.0 unless you install 3.1.x LTS side by side. + # FIXME: Tools won't run in .NET 5.0 unless you install 3.1.x LTS side by side. # https://itnext.io/how-to-support-multiple-net-sdks-in-github-actions-workflows-b988daa884e - name: Install .NET 3.1.x LTS uses: actions/setup-dotnet@v1 @@ -30,34 +25,29 @@ jobs: run: dotnet tool restore - name: Restore Packages - run: dotnet restore + run: dotnet restore osu-framework-microphone.Desktop.slnf - name: Restore inspectcode cache uses: actions/cache@v3 with: path: ${{ github.workspace }}/inspectcode - key: inspectcode-${{ hashFiles('.config/dotnet-tools.json', '.github/workflows/ci.yml', 'osu-framework-microphone.sln*', '.editorconfig', '.globalconfig', 'CodeAnalysis/*') }} + key: inspectcode-${{ hashFiles('.config/dotnet-tools.json', '.github/workflows/ci.yml', 'osu-framework-microphone.sln*', 'osu-framework-microphone*.slnf', '.editorconfig', '.globalconfig', 'CodeAnalysis/*') }} - name: Dotnet code style - run: dotnet build -c Debug -warnaserror build/Desktop.proj -p:EnforceCodeStyleInBuild=true - - # todo: add this test back. - # - name: CodeFileSanity - # run: | - # # TODO: Add ignore filters and GitHub Workflow Command Reporting in CFS. That way we don't have to do this workaround. - # # FIXME: Suppress warnings from templates project - # exit_code=0 - # while read -r line; do - # if [[ ! -z "$line" && "$line" != *"/osu.Framework.Templates/"* ]]; then - # echo "::error::$line" - # exit_code=1 - # fi - # done <<< $(dotnet codefilesanity) - # exit $exit_code - - # Temporarily disabled due to test failures, but it won't work anyway until the tool is upgraded. - # - name: .NET Format (Dry Run) - # run: dotnet format --dry-run --check + run: dotnet build -c Debug -warnaserror osu-framework-microphone.Desktop.slnf -p:EnforceCodeStyleInBuild=true + + - name: CodeFileSanity + run: | + # TODO: Add ignore filters and GitHub Workflow Command Reporting in CFS. That way we don't have to do this workaround. + # FIXME: Suppress warnings from templates project + exit_code=0 + while read -r line; do + if [[ ! -z "$line" && "$line" != *"/osu.Framework.Templates/"* ]]; then + echo "::error::$line" + exit_code=1 + fi + done <<< $(dotnet codefilesanity) + exit $exit_code - name: InspectCode run: dotnet jb inspectcode $(pwd)/osu-framework-microphone.Desktop.slnf --no-build --output="inspectcodereport.xml" --caches-home="inspectcode" --verbosity=WARN @@ -70,15 +60,17 @@ jobs: runs-on: ${{matrix.os.fullname}} env: OSU_EXECUTION_MODE: ${{matrix.threadingMode}} + OSU_TESTS_LOCAL_HTTPBIN: 1 strategy: - fail-fast: false - matrix: - os: - - { prettyname: Windows, fullname: windows-latest } - - { prettyname: macOS, fullname: macos-latest } - - { prettyname: Linux, fullname: ubuntu-latest } - threadingMode: ['SingleThread', 'MultiThreaded'] + fail-fast: false + matrix: + os: + - { prettyname: Windows, fullname: windows-latest } + - { prettyname: macOS, fullname: macos-latest } + - { prettyname: Linux, fullname: ubuntu-latest } + threadingMode: ['SingleThread', 'MultiThreaded'] timeout-minutes: 60 + steps: - name: Checkout uses: actions/checkout@v2 @@ -88,20 +80,21 @@ jobs: with: dotnet-version: "6.0.x" - # FIXME: libavformat is not included in Ubuntu. Let's fix that. - # https://github.com/ppy/osu-framework/issues/4349 - # Remove this once https://github.com/actions/virtual-environments/issues/3306 has been resolved. - - name: Install libavformat-dev - if: ${{matrix.os.fullname == 'ubuntu-latest'}} - run: | - sudo apt-get update && \ - sudo apt-get -y install libavformat-dev + - name: Setup Go + uses: actions/setup-go@v3 + + - name: Install httpbin + run: go install github.com/mccutchen/go-httpbin/v2/cmd/go-httpbin@latest + + - name: Run httpbin + run: $HOME/go/bin/go-httpbin & + shell: bash - name: Compile - run: dotnet build -c Debug -warnaserror build/Desktop.proj + run: dotnet build -c Debug -warnaserror osu-framework-microphone.Desktop.slnf - name: Test - run: dotnet test $pwd/*.Tests/bin/Debug/*/*.Tests.dll --settings $pwd/build/vstestconfig.runsettings --logger "trx;LogFileName=TestResults-${{matrix.os.prettyname}}-${{matrix.threadingMode}}.trx" + run: dotnet test $pwd/**/*.Tests/bin/Debug/*/*.Tests.dll --settings $pwd/build/vstestconfig.runsettings --logger "trx;LogFileName=TestResults-${{matrix.os.prettyname}}-${{matrix.threadingMode}}.trx" shell: pwsh # Attempt to upload results even if test fails. @@ -126,11 +119,11 @@ jobs: with: dotnet-version: "6.0.x" - - name: Setup MSBuild - uses: microsoft/setup-msbuild@v1 + - name: Restore .NET workloads + run: dotnet workload restore - - name: Build - run: msbuild osu-framework-microphone.Android.slnf /restore /p:Configuration=Debug + - name: Compile + run: dotnet build -c Debug osu-framework-microphone.Android.slnf build-only-ios: name: Build only (iOS) @@ -145,8 +138,8 @@ jobs: with: dotnet-version: "6.0.x" - # Contrary to seemingly any other msbuild, msbuild running on macOS/Mono - # cannot accept .sln(f) files as arguments. - # Build just the iOS framework project for now. - - name: Build - run: msbuild osu.Framework.Microphone.iOS/osu.Framework.Microphone.iOS.csproj /restore /p:Configuration=Debug + - name: Restore .NET workloads + run: dotnet workload restore osu.Framework.Microphone.iOS/osu.Framework.Microphone.iOS.csproj + + - name: Compile + run: dotnet build -c Debug osu-framework-microphone.iOS.slnf diff --git a/.github/workflows/deploy-pack.yml b/.github/workflows/deploy-pack.yml index 1c6a988..3f12de9 100644 --- a/.github/workflows/deploy-pack.yml +++ b/.github/workflows/deploy-pack.yml @@ -16,11 +16,15 @@ jobs: run: | REPOSITORY="https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}.git" BRANCH="${GITHUB_REF/#refs\/heads\//}" + git version git clone --no-checkout ${REPOSITORY} . git config --local gc.auto 0 + git -c protocol.version=2 fetch --no-tags --prune --progress --depth=2 origin +${GITHUB_SHA}:refs/remotes/origin/${BRANCH} git checkout --progress --force -B $BRANCH refs/remotes/origin/$BRANCH + + - name: Set Variables id: deployment shell: bash @@ -31,6 +35,7 @@ jobs: echo "fatal: no tag detected for HEAD. Workflow will now stop." exit 128; fi + pack-framework: name: Pack (Framework) runs-on: windows-latest @@ -46,14 +51,18 @@ jobs: id: artifactsPath run: echo "::set-output name=NUGET_ARTIFACTS::${{github.workspace}}\artifacts" + # FIXME: 3.1 LTS is required here because iOS builds refuse to build without it. + # https://itnext.io/how-to-support-multiple-net-sdks-in-github-actions-workflows-b988daa884e + - name: Install .NET 3.1.x LTS + uses: actions/setup-dotnet@v1 + with: + dotnet-version: "3.1.x" + - name: Install .NET 6.0.x uses: actions/setup-dotnet@v1 with: dotnet-version: "6.0.x" - - name: Build (Framework) - run: dotnet build -c Release osu.Framework.Microphone /p:Version=${{needs.check-if-tag.outputs.version}} /p:GenerateDocumentationFile=true - - name: Pack (Framework) run: dotnet pack -c Release osu.Framework.Microphone /p:Version=${{needs.check-if-tag.outputs.version}} /p:GenerateDocumentationFile=true -o ${{steps.artifactsPath.outputs.nuget_artifacts}} @@ -66,7 +75,7 @@ jobs: release: name: Release runs-on: ubuntu-latest - needs: [ check-if-tag, pack-framework ] + needs: [check-if-tag, pack-framework] steps: - name: Create Artifact Directory run: mkdir ${{github.workspace}}/artifacts/ @@ -83,6 +92,8 @@ jobs: run: | mv -v **/*.nupkg $(pwd) rm -rfv */ + - name: Deploy run: | - dotnet nuget push ${{github.workspace}}/artifacts/*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_AUTH_TOKEN}} + dotnet nuget add source https://api.nuget.org/v3/index.json -n authed-nuget -u ${{secrets.NUGET_USER_NAME}} -p ${{secrets.NUGET_AUTH_TOKEN}} + dotnet nuget push ${{github.workspace}}/artifacts/*.nupkg --skip-duplicate --source authed-nuget diff --git a/osu.Framework.Microphone.Android.props b/osu.Framework.Microphone.Android.props index bcf1bdd..c998d01 100644 --- a/osu.Framework.Microphone.Android.props +++ b/osu.Framework.Microphone.Android.props @@ -1,52 +1,12 @@ 9.0 - bin\$(Configuration) - 4 - 2.0 - false - false - Library - 512 - Off - True - Xamarin.Android.Net.AndroidClientHandler - v10.0 - false - true - armeabi-v7a;x86;arm64-v8a - true - cjk,mideast,other,rare,west - prompt - - - True - portable - False - DEBUG;TRACE - false - true - false - None - - - false - none - true - false - False + 21.0 + android-x86;android-arm;android-arm64 + apk + Xamarin.Android.Net.AndroidMessageHandler + + true true - SdkOnly - - - - - - - - - - - diff --git a/osu.Framework.Microphone.Android/global.json b/osu.Framework.Microphone.Android/global.json deleted file mode 100644 index e032ebd..0000000 --- a/osu.Framework.Microphone.Android/global.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "sdk": { - "allowPrerelease": false, - "rollForward": "minor", - "version": "3.1.100" - } -} \ No newline at end of file diff --git a/osu.Framework.Microphone.Android/osu.Framework.Microphone.Android.csproj b/osu.Framework.Microphone.Android/osu.Framework.Microphone.Android.csproj index 441ff34..fd8e834 100644 --- a/osu.Framework.Microphone.Android/osu.Framework.Microphone.Android.csproj +++ b/osu.Framework.Microphone.Android/osu.Framework.Microphone.Android.csproj @@ -1,6 +1,7 @@ - + - monoandroid10.0 + net6.0-android + 21.0 Library true osu.Framework.Microphone.Android @@ -13,16 +14,10 @@ osu.Framework.Microphone.Android osu-framework microphone andy840119 - - - - - - - + diff --git a/osu.Framework.Microphone.Tests.Android/Properties/AndroidManifest.xml b/osu.Framework.Microphone.Tests.Android/AndroidManifest.xml similarity index 97% rename from osu.Framework.Microphone.Tests.Android/Properties/AndroidManifest.xml rename to osu.Framework.Microphone.Tests.Android/AndroidManifest.xml index 112ca58..fdb95f7 100644 --- a/osu.Framework.Microphone.Tests.Android/Properties/AndroidManifest.xml +++ b/osu.Framework.Microphone.Tests.Android/AndroidManifest.xml @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/osu.Framework.Microphone.Tests.Android/osu.Framework.Microphone.Tests.Android.csproj b/osu.Framework.Microphone.Tests.Android/osu.Framework.Microphone.Tests.Android.csproj index 4af8667..d711081 100644 --- a/osu.Framework.Microphone.Tests.Android/osu.Framework.Microphone.Tests.Android.csproj +++ b/osu.Framework.Microphone.Tests.Android/osu.Framework.Microphone.Tests.Android.csproj @@ -1,23 +1,11 @@ - + - 9.0 - Debug - AnyCPU - {320089C6-A141-4D3E-BD5F-C4A6CE9E567B} - {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + net6.0-android + Exe osu.Framework.Microphone.Tests.Android osu.Framework.Tests.Android - Properties\AndroidManifest.xml - armeabi-v7a;x86;arm64-v8a - v10.0 - - - - - - %(RecursiveDir)%(Filename)%(Extension) @@ -26,18 +14,7 @@ Resources\%(RecursiveDir)%(Filename)%(Extension) - - - {4d112e30-462b-4264-b44d-53b61abb185e} - osu.Framework.Microphone.Android - - - {D0F85C61-800A-4645-8633-AC59208FA732} - osu.Framework.Microphone - - - - + + - diff --git a/osu.Framework.Microphone.Tests.iOS/AppDelegate.cs b/osu.Framework.Microphone.Tests.iOS/AppDelegate.cs index ece902b..5b13f12 100644 --- a/osu.Framework.Microphone.Tests.iOS/AppDelegate.cs +++ b/osu.Framework.Microphone.Tests.iOS/AppDelegate.cs @@ -2,26 +2,13 @@ // See the LICENCE file in the repository root for full licence text. using Foundation; -using osu.Framework.Input.Handlers.Microphone; using osu.Framework.iOS; -using osu.Framework.iOS.Input; namespace osu.Framework.Tests { [Register("AppDelegate")] public class AppDelegate : GameAppDelegate { - protected override Game CreateGame() => new TestingVisualTestGame(); - - internal class TestingVisualTestGame : VisualTestGame - { - protected override void LoadComplete() - { - base.LoadComplete(); - - // Need to cache IOSMicrophoneHandler in here to let MicrophoneInputManager knows. - Host.Dependencies.CacheAs(typeof(MicrophoneHandler), new IOSMicrophoneHandler()); - } - } + protected override Game CreateGame() => new VisualTestGame(); } } diff --git a/osu.Framework.Microphone.Tests.iOS/Application.cs b/osu.Framework.Microphone.Tests.iOS/Application.cs index 3b12975..6eda2af 100644 --- a/osu.Framework.Microphone.Tests.iOS/Application.cs +++ b/osu.Framework.Microphone.Tests.iOS/Application.cs @@ -1,19 +1,15 @@ // Copyright (c) karaoke.dev . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.iOS; using UIKit; namespace osu.Framework.Tests { public static class Application { - // This is the main entry point of the application. public static void Main(string[] args) { - // if you want to use a different Application Delegate class from "AppDelegate" - // you can specify it here. - UIApplication.Main(args, typeof(GameUIApplication), typeof(AppDelegate)); + UIApplication.Main(args, null, typeof(AppDelegate)); } } } diff --git a/osu.Framework.Microphone.Tests.iOS/Info.plist b/osu.Framework.Microphone.Tests.iOS/Info.plist index d3603c7..4bfac8e 100644 --- a/osu.Framework.Microphone.Tests.iOS/Info.plist +++ b/osu.Framework.Microphone.Tests.iOS/Info.plist @@ -2,10 +2,10 @@ - CFBundleIdentifier - ppy.osu-Framework-Microphone-Tests-iOS CFBundleName - osu.Framework.Tests.iOS + ppy.osu-Framework-Microphone-Tests-iOS + CFBundleIdentifier + sh.ppy.osu-framework-visual-tests CFBundleShortVersionString 1.0 CFBundleVersion @@ -13,7 +13,7 @@ LSRequiresIPhoneOS MinimumOSVersion - 11.0 + 13.4 NSMicrophoneUsageDescription Ask for microphone permission UIApplicationSupportsIndirectInputEvents @@ -29,10 +29,6 @@ armv7 - UIRequiresFullScreen - - UIStatusBarHidden - UISupportedInterfaceOrientations UIInterfaceOrientationPortrait @@ -42,5 +38,13 @@ XSAppIconAssets Assets.xcassets/AppIcon.appiconset + UIStatusBarHidden + + UIRequiresFullScreen + + UIApplicationSupportsIndirectInputEvents + + CADisableMinimumFrameDurationOnPhone + diff --git a/osu.Framework.Microphone.Tests.iOS/osu.Framework.Microphone.Tests.iOS.csproj b/osu.Framework.Microphone.Tests.iOS/osu.Framework.Microphone.Tests.iOS.csproj index f270be9..51bd243 100644 --- a/osu.Framework.Microphone.Tests.iOS/osu.Framework.Microphone.Tests.iOS.csproj +++ b/osu.Framework.Microphone.Tests.iOS/osu.Framework.Microphone.Tests.iOS.csproj @@ -1,36 +1,12 @@ - - + - Debug - iPhoneSimulator - {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} Exe - osu.Framework.Microphone.Tests + net6.0-ios + 13.4 osu.Framework.Tests - Resources - {D972753E-45FC-4B82-B017-34BDE485F1BB} + osu.Framework.Tests - - - false - - - false - - - - - - - - - - - - - - %(RecursiveDir)%(Filename)%(Extension) @@ -40,17 +16,7 @@ - - {431614f4-d662-4cbd-b6c2-3e0d79ca968b} - osu.Framework.Microphone.iOS - - - {D0F85C61-800A-4645-8633-AC59208FA732} - osu.Framework.Microphone - - - - + + - diff --git a/osu.Framework.Microphone.iOS.props b/osu.Framework.Microphone.iOS.props index 7a39d69..9c7b34b 100644 --- a/osu.Framework.Microphone.iOS.props +++ b/osu.Framework.Microphone.iOS.props @@ -1,69 +1,17 @@  + iPhone Developer 9.0 - --nolinkaway - -lstdc++ -lbz2 -framework AudioToolbox -framework AVFoundation -framework CoreMedia -framework VideoToolbox -framework SystemConfiguration -framework CFNetwork -framework Accelerate - PackageReference - bin\$(Platform)\$(Configuration) - cjk,mideast,other,rare,west - false - $(DefaultMtouchExtraArgs) -gcc_flags "$(DefaultMtouchGccFlags)" - NSUrlSessionHandler - - - - true - full - false - DEBUG;ENABLE_TEST_CLOUD; - true - true - - - pdbonly - true - - - x86_64 - None + true + + MT7091 - true - SdkOnly - ARM64 - Entitlements.plist + ios-arm64 - - true - 25823 - false - - - true - - - true - 28126 + + iossimulator-x64 - - - - - - - - - - - - - Static - False - True - - - - - - diff --git a/osu.Framework.Microphone.iOS/Input/IOSMicrophoneHandler.cs b/osu.Framework.Microphone.iOS/Input/IOSMicrophoneHandler.cs index d51a520..f9f5be8 100644 --- a/osu.Framework.Microphone.iOS/Input/IOSMicrophoneHandler.cs +++ b/osu.Framework.Microphone.iOS/Input/IOSMicrophoneHandler.cs @@ -1,4 +1,7 @@ -using AVFoundation; +// Copyright (c) karaoke.dev . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using AVFoundation; using Foundation; using osu.Framework.Input.Handlers.Microphone; using osu.Framework.Logging; diff --git a/osu.Framework.Microphone.iOS/global.json b/osu.Framework.Microphone.iOS/global.json deleted file mode 100644 index e032ebd..0000000 --- a/osu.Framework.Microphone.iOS/global.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "sdk": { - "allowPrerelease": false, - "rollForward": "minor", - "version": "3.1.100" - } -} \ No newline at end of file diff --git a/osu.Framework.Microphone.iOS/osu.Framework.Microphone.iOS.csproj b/osu.Framework.Microphone.iOS/osu.Framework.Microphone.iOS.csproj index 3163e90..d05d16d 100644 --- a/osu.Framework.Microphone.iOS/osu.Framework.Microphone.iOS.csproj +++ b/osu.Framework.Microphone.iOS/osu.Framework.Microphone.iOS.csproj @@ -1,12 +1,12 @@ - + - xamarinios10 + net6.0-ios + 13.4 Library true osu.Framework.Microphone.iOS osu.Framework.Microphone.iOS osu.Framework.iOS - Resources Unofficial osu!framework extension for using microphon as input device. @@ -14,16 +14,10 @@ osu.Framework.Microphone.iOS osu-framework microphone andy840119 - - - - - - - + diff --git a/osu.Framework.Microphone/Input/Voice.cs b/osu.Framework.Microphone/Input/Voice.cs index 57cf8a2..44b0360 100644 --- a/osu.Framework.Microphone/Input/Voice.cs +++ b/osu.Framework.Microphone/Input/Voice.cs @@ -39,7 +39,7 @@ public Voice(float pitch, float decibel) public static bool operator ==(Voice left, Voice right) => left.Equals(right); public static bool operator !=(Voice left, Voice right) => !(left == right); - public override bool Equals(object obj) => obj is Voice other && Equals(other); + public override bool Equals(object? obj) => obj is Voice other && Equals(other); public override int GetHashCode() => Pitch.GetHashCode(); } diff --git a/osu.Framework.Microphone/osu.Framework.Microphone.csproj b/osu.Framework.Microphone/osu.Framework.Microphone.csproj index 4a54d44..d526e51 100644 --- a/osu.Framework.Microphone/osu.Framework.Microphone.csproj +++ b/osu.Framework.Microphone/osu.Framework.Microphone.csproj @@ -1,7 +1,7 @@  Library - netstandard2.1 + net6.0 enable @@ -24,8 +24,6 @@ - - + -