Skip to content

Commit 76ef4af

Browse files
Merge branch 'blowfishpro:master' into master
2 parents b021d5c + 1149556 commit 76ef4af

File tree

71 files changed

+1646
-1152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1646
-1152
lines changed
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: Build and Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build-and-test:
7+
name: Build and Test
8+
runs-on: ubuntu-latest
9+
outputs:
10+
ksp-version: ${{ steps.set-ksp-version.outputs.ksp-version }}
11+
release-package-name: ${{ steps.set-release-package-name.outputs.release-package-name }}
12+
release-changelog: ${{ steps.extract-single-changelog.outputs.changelog-single }}
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 100
18+
- name: Fetch master
19+
run: git fetch --depth=100 origin master
20+
- name: Fetch tags
21+
run: git fetch --depth=1 --tags origin
22+
- name: Describe current revision with tags
23+
id: describe-tags
24+
run: |
25+
GIT_TAGISH="$(git describe --tags)"
26+
echo "${GIT_TAGISH}"
27+
echo "::set-output name=git-tagish::${GIT_TAGISH}"
28+
- name: Install Ruby
29+
uses: ruby/setup-ruby@v1
30+
- name: Install NuGet
31+
uses: nuget/setup-nuget@v1
32+
- name: Install Gems
33+
run: bundle install
34+
- name: Install NuGet packages
35+
run: nuget restore
36+
- name: Set KSP Version
37+
id: set-ksp-version
38+
run: |
39+
KSP_VERSION="$(cat ./KSP_VERSION)"
40+
echo "KSP Version: ${KSP_VERSION}"
41+
echo "::set-output name=ksp-version::${KSP_VERSION}"
42+
- name: Download KSP DLLs
43+
id: download-ksp-dlls
44+
run: |
45+
aws --no-sign-request --region us-east-1 s3 cp s3://blowfish-ksp-dlls/ksp-${{ steps.set-ksp-version.outputs.ksp-version }}.zip '/tmp/KSP_DLLs.zip'
46+
KSP_DLL_PATH="/opt/ksp/assembly/${{ steps.set-ksp-version.outputs.ksp-version }}"
47+
echo "::set-output name=ksp-dll-path::${KSP_DLL_PATH}"
48+
mkdir -p "${KSP_DLL_PATH}"
49+
unzip '/tmp/KSP_DLLs.zip' -d "${KSP_DLL_PATH}"
50+
rm '/tmp/KSP_DLLs.zip'
51+
- name: Run Rubocop
52+
run: bundle exec rubocop
53+
- name: Compile Project
54+
run: msbuild /p:Configuration=Release /p:ReferencePath="${{ steps.download-ksp-dlls.outputs.ksp-dll-path }}"
55+
- name: Run Unit Tests
56+
run: mono packages/xunit.runner.console.*/tools/net471/xunit.console.exe B9PartSwitchTests/bin/Release/B9PartSwitchTests.dll
57+
- name: Extract Changelog
58+
run: |
59+
curl 'https://raw.githubusercontent.com/wiki/blowfishpro/B9PartSwitch/Changelog.md' -o "${RUNNER_TEMP}/B9PartSwitch-Changelog-all.md"
60+
bundle exec extract-changelog -u "$(git describe --tags)" -i "${RUNNER_TEMP}/B9PartSwitch-Changelog-all.md" -o "${RUNNER_TEMP}/B9PartSwitch-Changelog-current.md"
61+
- name: Extract changelog for current release
62+
id: extract-single-changelog
63+
if: startsWith(github.ref, 'refs/tags/v')
64+
shell: bash
65+
run: |
66+
CHANGELOG_SINGLE_CONTENT="$(bundle exec extract-changelog -s "$(git describe --tags)" -i "${RUNNER_TEMP}/B9PartSwitch-Changelog-all.md")"
67+
echo '--- Changelog for this version: ---'
68+
echo "${CHANGELOG_SINGLE_CONTENT}"
69+
echo '--- End changelog ---'
70+
CHANGELOG_SINGLE_CONTENT="${CHANGELOG_SINGLE_CONTENT//'%'/'%25'}"
71+
CHANGELOG_SINGLE_CONTENT="${CHANGELOG_SINGLE_CONTENT//$'\n'/'%0A'}"
72+
CHANGELOG_SINGLE_CONTENT="${CHANGELOG_SINGLE_CONTENT//$'\r'/'%0D'}"
73+
echo "::set-output name=changelog-single::${CHANGELOG_SINGLE_CONTENT}"
74+
- name: Create version file
75+
id: create-version-file
76+
run: |
77+
VERSION_FILE="${RUNNER_TEMP}/B9PartSwitch.version"
78+
bundle exec fill-version "${GITHUB_WORKSPACE}/templates/B9PartSwitch.version.erb" "${VERSION_FILE}"
79+
echo "::set-output name=version-file::${VERSION_FILE}"
80+
- name: Assemble Release
81+
id: assemble-release
82+
run: |
83+
RELEASE_DIR="${RUNNER_TEMP}/release"
84+
echo "Release dir: ${RELEASE_DIR}"
85+
mkdir -v "${RELEASE_DIR}"
86+
echo "::set-output name=release-dir::${RELEASE_DIR}"
87+
cp -v -R "${GITHUB_WORKSPACE}/GameData" "${RELEASE_DIR}"
88+
cp -v "${GITHUB_WORKSPACE}/README.md" "${RELEASE_DIR}"
89+
cp -v "${GITHUB_WORKSPACE}/LICENSE" "${RELEASE_DIR}"
90+
cp -v "${RUNNER_TEMP}/B9PartSwitch-Changelog-current.md" "${RELEASE_DIR}/CHANGELOG.md"
91+
cp -v "${GITHUB_WORKSPACE}/README.md" "${RELEASE_DIR}/GameData/B9PartSwitch"
92+
cp -v "${GITHUB_WORKSPACE}/LICENSE" "${RELEASE_DIR}/GameData/B9PartSwitch"
93+
cp -v "${RUNNER_TEMP}/B9PartSwitch-Changelog-current.md" "${RELEASE_DIR}/GameData/B9PartSwitch/CHANGELOG.md"
94+
cp -v "${{ steps.create-version-file.outputs.version-file }}" "${RELEASE_DIR}/GameData/B9PartSwitch/B9PartSwitch.version"
95+
- name: Set release package name
96+
id: set-release-package-name
97+
run: echo "::set-output name=release-package-name::B9PartSwitch_${{ steps.describe-tags.outputs.git-tagish }}"
98+
- name: Upload result as artifact
99+
uses: actions/upload-artifact@v1
100+
with:
101+
name: ${{ steps.set-release-package-name.outputs.release-package-name }}
102+
path: ${{ steps.assemble-release.outputs.release-dir }}
103+
- name: Verify result
104+
run: bundle exec rake spec
105+
release:
106+
name: Release
107+
needs: build-and-test
108+
if: startsWith(github.ref, 'refs/tags/v')
109+
runs-on: ubuntu-latest
110+
steps:
111+
- name: Download release package artifact
112+
id: download-release
113+
uses: actions/download-artifact@v2
114+
with:
115+
name: ${{ needs.build-and-test.outputs.release-package-name }}
116+
path: release/${{ needs.build-and-test.outputs.release-package-name }}
117+
- name: Upload .version file to S3
118+
env:
119+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
120+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
121+
run:
122+
aws --region us-east-1 s3 cp "${{ steps.download-release.outputs.download-path }}/GameData/B9PartSwitch/B9PartSwitch.version" "s3://blowfish-ksp-b9partswitch-avc/versions/$(git describe --tags)/B9PartSwitch.version"
123+
- name: Package release
124+
id: package-release
125+
working-directory: ${{ steps.download-release.outputs.download-path }}
126+
run: |
127+
RELEASE_FILENAME="${RUNNER_TEMP}/${{ needs.build-and-test.outputs.release-package-name }}.zip"
128+
echo "Release filename: ${RELEASE_FILENAME}"
129+
zip -v -r "${RELEASE_FILENAME}" *
130+
echo "::set-output name=release-package-filename::${RELEASE_FILENAME}"
131+
- name: Create release
132+
id: create-release
133+
uses: actions/create-release@v1
134+
env:
135+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
136+
with:
137+
prerelease: true
138+
tag_name: ${{ github.ref }}
139+
release_name: B9PartSwitch ${{ github.ref }} for KSP ${{ needs.build-and-test.outputs.ksp-version }}
140+
body: ${{ needs.build-and-test.outputs.release-changelog }}
141+
- name: Upload package to release
142+
uses: actions/upload-release-asset@v1
143+
env:
144+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145+
with:
146+
upload_url: ${{ steps.create-release.outputs.upload_url }}
147+
asset_path: ${{ steps.package-release.outputs.release-package-filename }}
148+
asset_name: ${{ needs.build-and-test.outputs.release-package-name }}.zip
149+
asset_content_type: application/zip
150+
- name: Print release url
151+
run: echo "Release successful! You can view it at ${{ steps.create-release.outputs.html_url }}"

.travis.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

B9PartSwitch/B9PartSwitch.csproj

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\packages\Microsoft.Net.Compilers.3.3.1\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.3.3.1\build\Microsoft.Net.Compilers.props')" />
3+
<Import Project="..\packages\Microsoft.Net.Compilers.3.9.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.3.9.0\build\Microsoft.Net.Compilers.props')" />
44
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
55
<PropertyGroup>
66
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -18,15 +18,15 @@
1818
</PropertyGroup>
1919
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2020
<DebugSymbols>true</DebugSymbols>
21-
<DebugType>full</DebugType>
21+
<DebugType>portable</DebugType>
2222
<Optimize>false</Optimize>
2323
<OutputPath>bin\Debug\</OutputPath>
2424
<DefineConstants>DEBUG;TRACE</DefineConstants>
2525
<ErrorReport>prompt</ErrorReport>
2626
<WarningLevel>4</WarningLevel>
2727
</PropertyGroup>
2828
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
29-
<DebugType>pdbonly</DebugType>
29+
<DebugType>none</DebugType>
3030
<Optimize>true</Optimize>
3131
<OutputPath>bin\Release\</OutputPath>
3232
<DefineConstants>TRACE</DefineConstants>
@@ -108,18 +108,28 @@
108108
<Compile Include="Fishbones\OperationManager.cs" />
109109
<Compile Include="Fishbones\UseParser.cs" />
110110
<Compile Include="Localization.cs" />
111+
<Compile Include="ModuleB9AssignUiGroups.cs" />
112+
<Compile Include="ModuleMatcher.cs" />
113+
<Compile Include="PartSwitch\PartModifiers\AttachNodeSizeModifier.cs" />
114+
<Compile Include="Utils\ChangeTransactionManager.cs" />
111115
<Compile Include="ModuleB9DisableTransform.cs" />
112116
<Compile Include="ModuleB9PropagateCopyEvents.cs" />
113117
<Compile Include="PartSwitch\AttachNodeModifierInfo.cs" />
114118
<Compile Include="PartSwitch\BestSubtypeDeterminator.cs" />
119+
<Compile Include="PartSwitch\FloatPropertyModifierInfo.cs" />
120+
<Compile Include="PartSwitch\ColorPropertyModifierInfo.cs" />
115121
<Compile Include="PartSwitch\LockedSubtypeWarningHandler.cs" />
116122
<Compile Include="PartSwitch\ModuleB9PartInfo.cs" />
117123
<Compile Include="PartSwitch\ModuleB9PartSwitch.cs" />
118124
<Compile Include="PartSwitch\ModuleModifierInfo.cs" />
119125
<Compile Include="PartSwitch\PartModifiers\AttachNodeMover.cs" />
120126
<Compile Include="PartSwitch\PartModifiers\AttachNodeToggler.cs" />
127+
<Compile Include="PartSwitch\PartModifiers\FloatPropertyModifier.cs" />
128+
<Compile Include="PartSwitch\PartModifiers\ColorPropertyModifier.cs" />
121129
<Compile Include="PartSwitch\PartModifiers\EffectDeactivator.cs" />
130+
<Compile Include="PartSwitch\PartModifiers\IPartAspectLock.cs" />
122131
<Compile Include="PartSwitch\PartModifiers\IPartModifier.cs" />
132+
<Compile Include="PartSwitch\MaterialModifierInfo.cs" />
123133
<Compile Include="PartSwitch\PartModifiers\ModuleDataHandlerBasic.cs" />
124134
<Compile Include="PartSwitch\PartModifiers\ModuleDeactivator.cs" />
125135
<Compile Include="PartSwitch\PartModifiers\ModuleOutputResourceResetter.cs" />
@@ -142,6 +152,7 @@
142152
<Compile Include="PartSwitch\PartModifiers\TransformToggler.cs" />
143153
<Compile Include="PartSwitch\PartSubtype.cs" />
144154
<Compile Include="PartSwitch\PartSwitchFlightDialog.cs" />
155+
<Compile Include="PartSwitch\TexturePropertyModifierInfo.cs" />
145156
<Compile Include="PartSwitch\TextureSwitchInfo.cs" />
146157
<Compile Include="PartSwitch\TransformModifierInfo.cs" />
147158
<Compile Include="Serialization\SerializedDataContainer.cs" />
@@ -159,26 +170,30 @@
159170
<Compile Include="Utils\ColorParser.cs" />
160171
<Compile Include="Utils\GroupedStringBuilder.cs" />
161172
<Compile Include="Utils\ResourceColors.cs" />
173+
<Compile Include="Utils\StringMatcher.cs" />
162174
</ItemGroup>
163175
<ItemGroup>
164176
<None Include="packages.config" />
165177
</ItemGroup>
166178
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
167179
<PropertyGroup>
168180
<PreBuildEvent>
169-
sh -e -c "cd '$(SolutionDir)' &amp;&amp; 'bin/fill-version' '$(SolutionDir)/templates/AssemblyInfo.cs.erb' '$(ProjectDir)/Properties/AssemblyInfo.cs'"
181+
sh -e -c "cd '$(SolutionDir)' &amp;&amp; bundle exec fill-version '$(SolutionDir)/templates/AssemblyInfo.cs.erb' '$(ProjectDir)/Properties/AssemblyInfo.cs'"
170182
</PreBuildEvent>
171183
</PropertyGroup>
172184
<PropertyGroup>
173185
<PostBuildEvent>
174186
sh -e -c " mkdir -p '$(SolutionDir)/GameData/B9PartSwitch/Plugins/' &amp;&amp; cp '$(TargetPath)' '$(SolutionDir)/GameData/B9PartSwitch/Plugins/'"
175187
</PostBuildEvent>
176188
</PropertyGroup>
189+
<PropertyGroup>
190+
<LangVersion>9.0</LangVersion>
191+
</PropertyGroup>
177192
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
178193
<PropertyGroup>
179194
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
180195
</PropertyGroup>
181-
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.3.3.1\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.3.3.1\build\Microsoft.Net.Compilers.props'))" />
196+
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.3.9.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.3.9.0\build\Microsoft.Net.Compilers.props'))" />
182197
</Target>
183198
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
184199
Other similar extension points exist, see Microsoft.Common.targets.

B9PartSwitch/Extensions/PartExtensions.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ public static PartResource AddResource(this Part part, PartResourceDefinition in
2424
resource.flowMode = PartResource.FlowMode.Both;
2525
part.Resources.dict.Add(info.name.GetHashCode(), resource);
2626

27-
PartResource simulationResource = new PartResource(resource);
28-
simulationResource.simulationResource = true;
27+
PartResource simulationResource = new PartResource(resource)
28+
{
29+
simulationResource = true
30+
};
2931
part.SimulationResources.dict.Add(info.name.GetHashCode(), simulationResource);
3032

3133
GameEvents.onPartResourceListChange.Fire(part);
@@ -123,14 +125,6 @@ public static Transform GetModelRoot(this Part part)
123125
return part.partTransform.Find("model");
124126
}
125127

126-
public static IEnumerable<Transform> GetModelTransforms(this Part part, string name)
127-
{
128-
part.ThrowIfNullArgument(nameof(part));
129-
name.ThrowIfNullOrEmpty(nameof(name));
130-
131-
return part.GetModelRoot().GetChildrenNamedRecursive(name);
132-
}
133-
134128
public static void FixModuleJettison(this Part part)
135129
{
136130
if (!HighLogic.LoadedSceneIsFlight) return;

B9PartSwitch/Extensions/PartModuleExtensions.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,27 @@ public static class PartModuleExtensions
55
// partInfo is assigned after modules are created and loaded
66
public static bool ParsedPrefab(this PartModule module) => module.part.partInfo != null;
77

8+
public static void SetUiGroups(this PartModule module, string uiGroupName, string uiGroupDisplayName)
9+
{
10+
module.ThrowIfNullArgument(nameof(module));
11+
12+
foreach (BaseField field in module.Fields)
13+
{
14+
if (!field.group.name.IsNullOrEmpty()) continue;
15+
16+
field.group.name = uiGroupName;
17+
field.group.displayName = uiGroupDisplayName;
18+
}
19+
20+
foreach (BaseEvent baseEvent in module.Events)
21+
{
22+
if (!baseEvent.group.name.IsNullOrEmpty()) continue;
23+
24+
baseEvent.group.name = uiGroupName;
25+
baseEvent.group.displayName = uiGroupDisplayName;
26+
}
27+
}
28+
829
#region Logging
930

1031
public static void LogInfo(this PartModule module, object message) => module.part.LogInfo($"{module.LogTagString()} {message}");

B9PartSwitch/Extensions/TransformExtensions.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@ public static class TransformExtensions
88
public static void Enable(this Transform trans) => trans.gameObject.SetActive(true);
99
public static void Disable(this Transform trans) => trans.gameObject.SetActive(false);
1010

11-
public static IEnumerable<Transform> GetChildrenNamedRecursive(this Transform transform, string name)
11+
public static IEnumerable<Transform> TraverseHierarchy(this Transform transform)
1212
{
1313
transform.ThrowIfNullArgument(nameof(transform));
14-
name.ThrowIfNullOrEmpty(nameof(name));
1514

1615
for (int i = 0; i < transform.childCount; i++)
1716
{
1817
Transform child = transform.GetChild(i);
1918

20-
if (child.name == name) yield return child;
19+
yield return child;
2120

22-
foreach (Transform childChild in child.GetChildrenNamedRecursive(name))
21+
foreach (Transform childChild in child.TraverseHierarchy())
2322
{
2423
yield return childChild;
2524
}

0 commit comments

Comments
 (0)