diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..88829ed --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,27 @@ +name: release + +on: + push: + branches: + - preview + - master + - v*.x + tags-ignore: + - "**" + +jobs: + release: + runs-on: ubuntu-latest + if: "! contains(github.event.head_commit.message, '[skip ci]') && ! contains(github.event.head_commit.message, '[ci skip]')" + steps: + - uses: actions/checkout@v2 + + - run: | + npm i --no-save https://gist.github.com/mob-sakai/c90044338361af97a7e8c8a78425bdb3 + npx semantic-release -e @mob-sakai/semantic-release-upm + env: + GITHUB_TOKEN: ${{ github.token }} + + - run: cat package.json + + - run: ls diff --git a/.github/workflows/unity-test.yml b/.github/workflows/unity-test.yml new file mode 100644 index 0000000..2a3d496 --- /dev/null +++ b/.github/workflows/unity-test.yml @@ -0,0 +1,145 @@ +# Secrets +# ULF_REPO: Git repository url contains ulf files. https://mob-sakai:{{token}}@github.com/mob-sakai/ulfs.git +name: unity-test + +on: + push: + branches: + - develop + tags: + - "!*" + pull_request: + types: + - opened + - synchronize + +jobs: + release-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - run: | + npm i --no-save https://gist.github.com/mob-sakai/c90044338361af97a7e8c8a78425bdb3 + npx semantic-release -e @mob-sakai/semantic-release-upm --dry-run --debug --branches develop + env: + GITHUB_TOKEN: ${{ github.token }} + + - run: cat package.json + + - run: ls + + unity-test: + strategy: + fail-fast: false + matrix: + unity: + [ + "2018.4.25f1", + "2019.4.10f1", + "2020.1.0f1", + "2020.1.1f1", + "2020.1.2f1", + "2020.1.3f1", + "2020.1.4f1", + "2020.1.5f1", + ] + + runs-on: ubuntu-latest + container: + # Use Unity image from https://hub.docker.com/r/gableroux/unity3d/tags + image: gableroux/unity3d:${{ matrix.unity }} + + steps: + # Activate Unity Editor + - name: Activate Unity Editor + id: activation + run: | + # Clone ulfs. + apt-get update + apt-get install software-properties-common -y + apt-add-repository ppa:git-core/ppa -y + apt-get update + apt-get install git -y + git clone --depth 1 ${ULF_REPO} .ulfs + + # Activate with ulf. + ULF_FILE=.ulfs/Unity_v${UNITY_VERSION}.ulf + echo $ULF_FILE + if [ -e ${ULF_FILE} ]; then + /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -manualLicenseFile ${ULF_FILE} \ + | grep -E 'LICENSE SYSTEM.*\w{32} != \w{32}' && FAILED=true + else + echo "::error:: ulf file '${ULF_FILE}' is not found." + FAILED=true + fi + + # Activation failed. + if [ $FAILED ]; then + echo "::error:: the unity activation may have failed. manual activation is required.%0A \ + 1. download the artifact's .alf file.%0A \ + 2. Go to https://license.unity3d.com/manual to activate manually.%0A \ + 3. Generate a .ulf file from the .alf file and download it.%0A \ + 4. Rename .ulf to 'Unity_v${UNITY_VERSION}.ulf'.%0A \ + 5. Add file to ulfs repository.%0A \ + 5. Re-run the jobs." + + /opt/Unity/Editor/Unity -quit -batchmode -nographics -logFile -createManualActivationFile + exit 1 + fi + env: + ULF_REPO: ${{ secrets.ULF_REPO }} + UNITY_VERSION: ${{ matrix.unity }} + + # (On failed activation) Upload unity activation file + - name: Upload unity activation file + uses: actions/upload-artifact@v2 + if: failure() + with: + name: Unity_v${{ matrix.unity }}.alf + path: ./*.alf + + # Setup testspace + - uses: testspace-com/setup-testspace@v1 + with: + domain: ${{ github.repository_owner }} + + # Checkout sandbox project + - uses: actions/checkout@v2 + with: + ref: "sandbox" + submodules: "true" + fetch-depth: "1" + + # Update package submodule + - name: "Update package submodule" + working-directory: Packages/dev + run: git checkout ${{ github.head_ref }} + + # Run playmode tests + - name: "Run playmode tests" + if: always() && steps.activation.conclusion == 'success' + run: | + xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \ + /opt/Unity/Editor/Unity -batchmode -nographics -silent-crashes -logFile -projectPath . -runTests -testPlatform playmode || exit 0 + + # Run editmode tests + - name: "Run editmode tests" + if: always() && steps.activation.conclusion == 'success' + run: | + # Install codecoverage + if [ -z "`echo ${{ matrix.unity }} | grep 2018.`" ]; then + npm i -g openupm-cli + openupm add com.unity.testtools.codecoverage + + xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \ + /opt/Unity/Editor/Unity -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod Coffee.CSharpCompilerSettings.Menus.SetDevelopMode + fi + + xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \ + /opt/Unity/Editor/Unity -batchmode -nographics -silent-crashes -logFile -projectPath . -runEditorTests -enableCodeCoverage -coverageOptions 'assemblyFilters:+CSharpCompilerSettings' || exit 0 + + # Push test results + - name: Push test results + if: always() && steps.activation.conclusion == 'success' + run: testspace "[${{ matrix.unity }}]TestResults-*.xml" "[Code Coverage]CodeCoverage/**/TestCoverageResults_*.xml" diff --git a/CHANGELOG.md b/CHANGELOG.md index f1d939c..84c5637 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,22 @@ +# [1.2.0](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/compare/1.1.1...1.2.0) (2020-10-23) + + +### Bug Fixes + +* fix release workflow ([073f310](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/commit/073f310220eadf3343b51f9849e1807330867e36)) + + +### Features + +* add nullable option ([9bc0b85](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/commit/9bc0b858e27dfb6da561404336389064a35c2cf8)), closes [#5](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/issues/5) + +# [1.2.0](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/compare/1.1.1...1.2.0) (2020-10-22) + + +### Features + +* add nullable option ([9bc0b85](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/commit/9bc0b858e27dfb6da561404336389064a35c2cf8)), closes [#5](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/issues/5) + ## [1.1.1](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/compare/v1.1.0...v1.1.1) (2020-10-13) diff --git a/Editor/CSharpProjectModifier.cs b/Editor/CSharpProjectModifier.cs index 1ca0c1d..15ae233 100644 --- a/Editor/CSharpProjectModifier.cs +++ b/Editor/CSharpProjectModifier.cs @@ -28,6 +28,10 @@ private static string OnGeneratedCSProject(string path, string content) if (!setting.UseDefaultCompiler) content = Regex.Replace(content, ".*", "" + setting.LanguageVersion + "", RegexOptions.Multiline); + // Enable nullable. + if (setting.EnableNullable) + content = Regex.Replace(content, "(\\s+)(.*)([\r\n]+)", "$1$2$3$1enable$3"); + return content; } } diff --git a/Editor/CscSettingsProvider.cs b/Editor/CscSettingsProvider.cs index 21bfe8d..2bf711f 100644 --- a/Editor/CscSettingsProvider.cs +++ b/Editor/CscSettingsProvider.cs @@ -36,6 +36,7 @@ private static void OnGUI(string searchContext) EditorGUILayout.PropertyField(serializedObject.FindProperty("m_PackageName")); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_PackageVersion")); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_LanguageVersion")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EnableNullable")); EditorGUI.indentLevel--; } diff --git a/Editor/InspectorGUI.cs b/Editor/InspectorGUI.cs index e96cf62..ec8e316 100644 --- a/Editor/InspectorGUI.cs +++ b/Editor/InspectorGUI.cs @@ -143,6 +143,7 @@ private static void OnPostHeaderGUI(Editor editor) EditorGUILayout.PropertyField(_serializedObject.FindProperty("m_PackageName")); EditorGUILayout.PropertyField(_serializedObject.FindProperty("m_PackageVersion")); EditorGUILayout.PropertyField(_serializedObject.FindProperty("m_LanguageVersion")); + EditorGUILayout.PropertyField(_serializedObject.FindProperty("m_EnableNullable")); EditorGUI.indentLevel--; } diff --git a/Plugins/CSharpCompilerSettings.dll b/Plugins/CSharpCompilerSettings.dll index b4135c6..cfe8488 100644 Binary files a/Plugins/CSharpCompilerSettings.dll and b/Plugins/CSharpCompilerSettings.dll differ diff --git a/README.md b/README.md index 51c188f..1a6dabb 100755 --- a/README.md +++ b/README.md @@ -5,11 +5,14 @@ Change the C# compiler (csc) used on your Unity project, as you like! [![](https://img.shields.io/npm/v/com.coffee.csharp-compiler-settings?label=openupm®istry_uri=https://package.openupm.com)](https://openupm.com/packages/com.coffee.csharp-compiler-settings/) [![](https://img.shields.io/github/v/release/mob-sakai/CSharpCompilerSettingsForUnity?include_prereleases)](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/releases) -[![](https://img.shields.io/github/release-date/mob-sakai/CSharpCompilerSettingsForUnity.svg)](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/releases) -![](https://img.shields.io/badge/unity-2018.3%20or%20later-green.svg) -[![](https://img.shields.io/github/license/mob-sakai/CSharpCompilerSettingsForUnity.svg)](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/blob/upm/LICENSE.txt) -[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-orange.svg)](http://makeapullrequest.com) -[![](https://img.shields.io/twitter/follow/mob_sakai.svg?label=Follow&style=social)](https://twitter.com/intent/follow?screen_name=mob_sakai) +[![](https://img.shields.io/github/release-date/mob-sakai/CSharpCompilerSettingsForUnity.svg)](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/releases) [![](https://img.shields.io/github/license/mob-sakai/CSharpCompilerSettingsForUnity.svg)](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/blob/master/LICENSE.txt) +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-orange.svg)](http://makeapullrequest.com) +![](https://img.shields.io/badge/Unity%202018.3%20or%20later-supported-blue.svg) +![](https://img.shields.io/badge/Unity%202019.x-supported-blue.svg) +![](https://img.shields.io/badge/Unity%202020.x-supported-blue.svg) +[![Test](https://mob-sakai.testspace.com/spaces/130862/badge?token=43a50d2fc998aa362d36934597de0c84527e5690)](https://mob-sakai.testspace.com/spaces/130862) +[![CodeCoverage](https://mob-sakai.testspace.com/spaces/130862/metrics/99758/badge)](https://mob-sakai.testspace.com/spaces/130862/current/Code%20Coverage/Code%20Coverage") +![GitHub Workflow Status](https://img.shields.io/github/workflow/status/mob-sakai/CSharpCompilerSettingsForUnity/unity-test) << [Description](#description) | [Installation](#installation) | [Usage](#usage) | [Contributing](#contributing) >> @@ -92,6 +95,7 @@ Let's enjoy C# 8.0 features with your Unity project! * If `dotnet` is required, install it automatically. * `CompilerType.BuiltIn` compiler option to disable this plugin. * `Enable Logging` option to display compilation log. +* `Allow Nullable` option to enable [Nullable reference types (C# 8.0)](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-reference-types). [OpenSesame.Net.Compilers]: https://www.nuget.org/packages/OpenSesame.Net.Compilers [OpenSesame.Net.Compilers.Toolset]: https://www.nuget.org/packages/OpenSesame.Net.Compilers.Toolset @@ -197,7 +201,7 @@ The project setting asset for C# Compiler will be saved in `ProjectSettings/CSha ### For C# 8.0 features [C# 8.0 features](https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8) -[samples](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/tree/develop/Assets/C%23%208.0%20Features) +[samples](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/tree/sandbox/Assets/C%23%208.0%20Features) If you want to use the C# 8.0 features, set it up as follows: @@ -223,7 +227,7 @@ Some features required external library. ### For C# 9.0 features (preview) [C# 9.0 features](https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-9) -[samples](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/tree/develop/Assets/C%23%209.0%20Features) +[samples](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/tree/sandbox/Assets/C%23%209.0%20Features) If you want to use the C# 9.0 features, set it up as follows: @@ -248,7 +252,7 @@ Issues are very valuable to this project. ### Pull Requests Pull requests are, a great way to get your ideas into this repository. -See [CONTRIBUTING.md](/../../blob/develop/CONTRIBUTING.md) and [develop](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/tree/develop) branch. +See [CONTRIBUTING.md](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/blob/master/CONTRIBUTING.md) and [sandbox](https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/tree/sandbox) branch. ### Support @@ -267,12 +271,13 @@ With your support, I can spend more time on development. :) ## Author -[mob-sakai](https://github.com/mob-sakai) -[![](https://img.shields.io/twitter/follow/mob_sakai.svg?label=Follow&style=social)](https://twitter.com/intent/follow?screen_name=mob_sakai) +* [mob-sakai](https://github.com/mob-sakai) [![](https://img.shields.io/twitter/follow/mob_sakai.svg?label=Follow&style=social)](https://twitter.com/intent/follow?screen_name=mob_sakai) ![GitHub followers](https://img.shields.io/github/followers/mob-sakai?style=social) +![](https://user-images.githubusercontent.com/12690315/96912074-bcede500-14dc-11eb-8acd-3fdd8d0e4606.png) ## See Also * GitHub page : https://github.com/mob-sakai/CSharpCompilerSettingsForUnity * Releases : https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/releases * Issue tracker : https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/issues -* Change log : https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/blob/upm/CHANGELOG.md +* Change log : https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/blob/master/CHANGELOG.md +* Test Space : https://mob-sakai.testspace.com/spaces/130862/current diff --git a/package.json b/package.json index eccf761..c6f2c45 100755 --- a/package.json +++ b/package.json @@ -2,13 +2,12 @@ "name": "com.coffee.csharp-compiler-settings", "displayName": "C# Compiler Settings", "description": "Change the C# compiler (csc) used in your Unity project, as you like!", - "version": "1.1.1", + "version": "1.2.0", "unity": "2018.3", "license": "MIT", "repository": { "type": "git", "url": "https://github.com/mob-sakai/CSharpCompilerSettingsForUnity.git" }, - "author": "mob-sakai (https://github.com/mob-sakai)", - "dependencies": {} + "author": "mob-sakai (https://github.com/mob-sakai)" }