Skip to content

Commit 389c228

Browse files
Merge pull request #486: [EXP] Use Git with builtin FS Monitor
This also adjusts the true/false part of the CI builds to correspond to the FS Monitor builtin instead of Watchman.
2 parents f0e862e + 56e66af commit 389c228

File tree

6 files changed

+48
-59
lines changed

6 files changed

+48
-59
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
os: [ubuntu-16.04, ubuntu-18.04, ubuntu-20.04, windows-2019, macos-10.15]
18-
watchman: [false, true]
18+
experimental: [false, true]
1919

2020
env:
2121
BUILD_FRAGMENT: bin/Release/netcoreapp3.1
@@ -45,20 +45,20 @@ jobs:
4545
if: runner.os == 'Linux'
4646
run: |
4747
echo "BUILD_PLATFORM=${{ runner.os }}" >>$GITHUB_ENV
48-
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.watchman }}" >>$GITHUB_ENV
48+
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.experimental }}" >>$GITHUB_ENV
4949
5050
- name: Setup platform (Mac)
5151
if: runner.os == 'macOS'
5252
run: |
5353
echo 'BUILD_PLATFORM=Mac' >>$GITHUB_ENV
54-
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.watchman }}" >>$GITHUB_ENV
54+
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.experimental }}" >>$GITHUB_ENV
5555
5656
- name: Setup platform (Windows)
5757
if: runner.os == 'Windows'
5858
run: |
5959
echo "BUILD_PLATFORM=${{ runner.os }}" >>$env:GITHUB_ENV
6060
echo 'BUILD_FILE_EXT=.exe' >>$env:GITHUB_ENV
61-
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.watchman }}" >>$env:GITHUB_ENV
61+
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.experimental }}" >>$env:GITHUB_ENV
6262
6363
- name: Setup Git installer
6464
shell: bash
@@ -98,39 +98,9 @@ jobs:
9898
Wait-Process $files[0].Basename
9999
Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\GitForWindows'
100100
101-
- name: Install Watchman (Linux)
102-
if: runner.os == 'Linux' && matrix.watchman
103-
run: |
104-
cd ..
105-
git clone https://github.com/facebook/watchman.git -b v4.9.0 --depth 1
106-
cd watchman
107-
./autogen.sh
108-
GCC_VERSION=$(gcc -dumpversion | cut -d. -f1)
109-
if [ "$GCC_VERSION" -ge 7 ]; then CPPFLAGS="-Wno-error=format-truncation"; fi
110-
if [ "$GCC_VERSION" -ge 8 ]; then CPPFLAGS="$CPPFLAGS -Wno-error=class-memaccess"; fi
111-
export CPPFLAGS
112-
./configure --without-python
113-
make
114-
sudo make install
115-
116-
- name: Install Watchman (Mac)
117-
if: runner.os == 'macOS' && matrix.watchman
118-
run: brew install watchman
119-
120-
- name: Install Watchman (Windows)
121-
if: runner.os == 'Windows' && matrix.watchman
122-
run: |
123-
Write-Host 'Downloading Watchman ...'
124-
$Uri = (Select-Xml -Path Directory.Build.props -XPath /Project/PropertyGroup/WatchmanPackageUrl).Node.'#text'
125-
Set-Location -Path ..
126-
Invoke-WebRequest -Uri $Uri -OutFile watchman.zip
127-
Expand-Archive watchman.zip
128-
Write-Host 'Installing Watchman ...'
129-
New-Item -Path 'C:\Program Files' -Name Watchman -ItemType Directory | Out-Null
130-
Copy-Item -Path 'watchman\watchman-*-windows\bin\*' -Destination 'C:\Program Files\Watchman'
131-
$ENV:PATH="$ENV:PATH;C:\Program Files\Watchman"
132-
& watchman --version
133-
echo "PATH=$ENV:PATH" >>$env:GITHUB_ENV
101+
- name: Configure Experimental
102+
if: matrix.experimental
103+
run: git config --global feature.scalar experimental
134104

135105
- id: functional_test
136106
name: Functional test
@@ -140,6 +110,7 @@ jobs:
140110
export GIT_TRACE2_PERF="$PWD/$TRACE2_BASENAME/Perf"
141111
export GIT_TRACE2_EVENT_BRIEF=true
142112
export GIT_TRACE2_PERF_BRIEF=true
113+
export SCALAR_FUNCTIONAL_TEST_EXPERIMENTAL=${{ matrix.experimental }}
143114
mkdir -p "$TRACE2_BASENAME"
144115
mkdir -p "$TRACE2_BASENAME/Event"
145116
mkdir -p "$TRACE2_BASENAME/Perf"

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
VFS for Git (which is less flexible). Only update that version if we rely upon a
4444
new command-line interface in Git or if there is a truly broken interaction.
4545
-->
46-
<GitPackageVersion>2.20210114.2</GitPackageVersion>
46+
<GitPackageVersion>2.20210208.1-exp</GitPackageVersion>
4747
<MinimumGitVersion>v2.25.0.vfs.1.1</MinimumGitVersion>
4848

4949
<WatchmanPackageUrl>https://github.com/facebook/watchman/releases/download/v2020.08.03.00/watchman-v2020.08.03.00-windows.zip</WatchmanPackageUrl>

Scalar.Common/Git/GitVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public GitFeatureFlags GetFeatures()
4949
flags |= GitFeatureFlags.MaintenanceBuiltin;
5050
}
5151

52-
if (this.Features.Contains("fsmonitor--daemon"))
52+
if (this.Extra?.Equals("exp") == true)
5353
{
5454
flags |= GitFeatureFlags.BuiltinFSMonitor;
5555
}

Scalar.Common/Maintenance/ConfigStep.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,16 @@ public bool TrySetConfig(out string error)
219219
);
220220
GitFeatureFlags flags = GitVersion.GetAvailableGitFeatures(this.Context.Tracer);
221221
config.TryParseAsString(out string scalar, out error, defaultValue: "true");
222+
this.Context.Tracer.RelatedInfo($"feature.scalar={scalar}");
223+
224+
string envVar = Environment.GetEnvironmentVariable("SCALAR_FUNCTIONAL_TEST_EXPERIMENTAL");
225+
226+
if (bool.TryParse(envVar, out bool result) && result)
227+
{
228+
scalar = "experimental";
229+
}
230+
231+
this.Context.Tracer.RelatedInfo($"feature.scalar={scalar}, SCALAR_FUNCTIONAL_TEST_EXPERIMENTAL={envVar}");
222232

223233
if (StringComparer.OrdinalIgnoreCase.Equals(scalar, "false"))
224234
{
@@ -231,7 +241,9 @@ public bool TrySetConfig(out string error)
231241
}
232242
else if (StringComparer.OrdinalIgnoreCase.Equals(scalar, "experimental")
233243
// Make sure Git supports builtin FS Monitor
234-
&& flags.HasFlag(GitFeatureFlags.BuiltinFSMonitor))
244+
&& flags.HasFlag(GitFeatureFlags.BuiltinFSMonitor)
245+
// but not on Linux yet
246+
&& !RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
235247
{
236248
// ":internal:" is a custom value to specify the builtin
237249
// FS Monitor feature.

Scalar.FunctionalTests/Tools/ScalarFunctionalTestEnlistment.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,11 @@ public string GetPackRoot(FileSystemRunner fileSystem)
157157

158158
public void DeleteEnlistment()
159159
{
160-
string watchmanLocation = ProcessHelper.GetProgramLocation("watchman");
161-
if (!string.IsNullOrEmpty(watchmanLocation))
160+
string envVar = Environment.GetEnvironmentVariable("SCALAR_FUNCTIONAL_TEST_EXPERIMENTAL");
161+
162+
if (bool.TryParse(envVar, out bool result) && result)
162163
{
163-
try
164-
{
165-
ProcessHelper.Run(Path.Combine(watchmanLocation, "watchman"), $"watch-del {this.RepoRoot}");
166-
}
167-
catch (Exception ex)
168-
{
169-
Console.WriteLine($"Failed to delete watch on {this.RepoRoot}. {ex.ToString()}");
170-
}
164+
GitProcess.InvokeProcess(this.RepoRoot, "fsmonitor--daemon --stop");
171165
}
172166

173167
TestResultsHelper.OutputScalarLogs(this);

Scalar.UnitTests/Common/GitVersionTests.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,29 @@ public void GetFeatureFlags_MaintenanceBuiltin()
7070
[TestCase]
7171
public void GetFeatureFlags_BuiltinFSMonitor()
7272
{
73-
GitVersion version = new GitVersion(2, 30, 0, "vfs", 0, 0);
74-
GitFeatureFlags gitFeatures = version.GetFeatures();
75-
gitFeatures.HasFlag(GitFeatureFlags.BuiltinFSMonitor).ShouldBeFalse($"Incorrect for version {version}");
73+
var notSupportedVerisons = new List<GitVersion>
74+
{
75+
new GitVersion(2, 31, 0),
76+
new GitVersion(2, 29, 0, "windows"),
77+
new GitVersion(2, 30, 0, "vfs", 0, 1),
78+
};
79+
80+
foreach (GitVersion version in notSupportedVerisons)
81+
{
82+
GitFeatureFlags gitGitFeatures = version.GetFeatures();
83+
gitGitFeatures.HasFlag(GitFeatureFlags.BuiltinFSMonitor).ShouldBeFalse($"Incorrect for version {version}");
84+
}
7685

77-
version.Features.Add("bogus");
78-
gitFeatures = version.GetFeatures();
79-
gitFeatures.HasFlag(GitFeatureFlags.BuiltinFSMonitor).ShouldBeFalse($"Incorrect for version {version}");
86+
var supportedVerisons = new List<GitVersion>
87+
{
88+
new GitVersion(2, 30, 0, "vfs", 0, 0, extra: "exp"),
89+
};
8090

81-
version.Features.Add("fsmonitor--daemon");
82-
gitFeatures = version.GetFeatures();
83-
gitFeatures.HasFlag(GitFeatureFlags.BuiltinFSMonitor).ShouldBeTrue($"Incorrect for version {version}");
91+
foreach (GitVersion version in supportedVerisons)
92+
{
93+
GitFeatureFlags gitGitFeatures = version.GetFeatures();
94+
gitGitFeatures.HasFlag(GitFeatureFlags.BuiltinFSMonitor).ShouldBeTrue($"Incorrect for version {version}");
95+
}
8496
}
8597

8698
[TestCase]

0 commit comments

Comments
 (0)