Skip to content

Commit

Permalink
Merge pull request #486: [EXP] Use Git with builtin FS Monitor
Browse files Browse the repository at this point in the history
This also adjusts the true/false part of the CI builds to correspond to the FS Monitor builtin instead of Watchman.
  • Loading branch information
derrickstolee authored Feb 9, 2021
2 parents f0e862e + 56e66af commit 389c228
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 59 deletions.
45 changes: 8 additions & 37 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-16.04, ubuntu-18.04, ubuntu-20.04, windows-2019, macos-10.15]
watchman: [false, true]
experimental: [false, true]

env:
BUILD_FRAGMENT: bin/Release/netcoreapp3.1
Expand Down Expand Up @@ -45,20 +45,20 @@ jobs:
if: runner.os == 'Linux'
run: |
echo "BUILD_PLATFORM=${{ runner.os }}" >>$GITHUB_ENV
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.watchman }}" >>$GITHUB_ENV
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.experimental }}" >>$GITHUB_ENV
- name: Setup platform (Mac)
if: runner.os == 'macOS'
run: |
echo 'BUILD_PLATFORM=Mac' >>$GITHUB_ENV
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.watchman }}" >>$GITHUB_ENV
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.experimental }}" >>$GITHUB_ENV
- name: Setup platform (Windows)
if: runner.os == 'Windows'
run: |
echo "BUILD_PLATFORM=${{ runner.os }}" >>$env:GITHUB_ENV
echo 'BUILD_FILE_EXT=.exe' >>$env:GITHUB_ENV
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.watchman }}" >>$env:GITHUB_ENV
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.experimental }}" >>$env:GITHUB_ENV
- name: Setup Git installer
shell: bash
Expand Down Expand Up @@ -98,39 +98,9 @@ jobs:
Wait-Process $files[0].Basename
Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\GitForWindows'
- name: Install Watchman (Linux)
if: runner.os == 'Linux' && matrix.watchman
run: |
cd ..
git clone https://github.com/facebook/watchman.git -b v4.9.0 --depth 1
cd watchman
./autogen.sh
GCC_VERSION=$(gcc -dumpversion | cut -d. -f1)
if [ "$GCC_VERSION" -ge 7 ]; then CPPFLAGS="-Wno-error=format-truncation"; fi
if [ "$GCC_VERSION" -ge 8 ]; then CPPFLAGS="$CPPFLAGS -Wno-error=class-memaccess"; fi
export CPPFLAGS
./configure --without-python
make
sudo make install
- name: Install Watchman (Mac)
if: runner.os == 'macOS' && matrix.watchman
run: brew install watchman

- name: Install Watchman (Windows)
if: runner.os == 'Windows' && matrix.watchman
run: |
Write-Host 'Downloading Watchman ...'
$Uri = (Select-Xml -Path Directory.Build.props -XPath /Project/PropertyGroup/WatchmanPackageUrl).Node.'#text'
Set-Location -Path ..
Invoke-WebRequest -Uri $Uri -OutFile watchman.zip
Expand-Archive watchman.zip
Write-Host 'Installing Watchman ...'
New-Item -Path 'C:\Program Files' -Name Watchman -ItemType Directory | Out-Null
Copy-Item -Path 'watchman\watchman-*-windows\bin\*' -Destination 'C:\Program Files\Watchman'
$ENV:PATH="$ENV:PATH;C:\Program Files\Watchman"
& watchman --version
echo "PATH=$ENV:PATH" >>$env:GITHUB_ENV
- name: Configure Experimental
if: matrix.experimental
run: git config --global feature.scalar experimental

- id: functional_test
name: Functional test
Expand All @@ -140,6 +110,7 @@ jobs:
export GIT_TRACE2_PERF="$PWD/$TRACE2_BASENAME/Perf"
export GIT_TRACE2_EVENT_BRIEF=true
export GIT_TRACE2_PERF_BRIEF=true
export SCALAR_FUNCTIONAL_TEST_EXPERIMENTAL=${{ matrix.experimental }}
mkdir -p "$TRACE2_BASENAME"
mkdir -p "$TRACE2_BASENAME/Event"
mkdir -p "$TRACE2_BASENAME/Perf"
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
VFS for Git (which is less flexible). Only update that version if we rely upon a
new command-line interface in Git or if there is a truly broken interaction.
-->
<GitPackageVersion>2.20210114.2</GitPackageVersion>
<GitPackageVersion>2.20210208.1-exp</GitPackageVersion>
<MinimumGitVersion>v2.25.0.vfs.1.1</MinimumGitVersion>

<WatchmanPackageUrl>https://github.com/facebook/watchman/releases/download/v2020.08.03.00/watchman-v2020.08.03.00-windows.zip</WatchmanPackageUrl>
Expand Down
2 changes: 1 addition & 1 deletion Scalar.Common/Git/GitVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public GitFeatureFlags GetFeatures()
flags |= GitFeatureFlags.MaintenanceBuiltin;
}

if (this.Features.Contains("fsmonitor--daemon"))
if (this.Extra?.Equals("exp") == true)
{
flags |= GitFeatureFlags.BuiltinFSMonitor;
}
Expand Down
14 changes: 13 additions & 1 deletion Scalar.Common/Maintenance/ConfigStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@ public bool TrySetConfig(out string error)
);
GitFeatureFlags flags = GitVersion.GetAvailableGitFeatures(this.Context.Tracer);
config.TryParseAsString(out string scalar, out error, defaultValue: "true");
this.Context.Tracer.RelatedInfo($"feature.scalar={scalar}");

string envVar = Environment.GetEnvironmentVariable("SCALAR_FUNCTIONAL_TEST_EXPERIMENTAL");

if (bool.TryParse(envVar, out bool result) && result)
{
scalar = "experimental";
}

this.Context.Tracer.RelatedInfo($"feature.scalar={scalar}, SCALAR_FUNCTIONAL_TEST_EXPERIMENTAL={envVar}");

if (StringComparer.OrdinalIgnoreCase.Equals(scalar, "false"))
{
Expand All @@ -231,7 +241,9 @@ public bool TrySetConfig(out string error)
}
else if (StringComparer.OrdinalIgnoreCase.Equals(scalar, "experimental")
// Make sure Git supports builtin FS Monitor
&& flags.HasFlag(GitFeatureFlags.BuiltinFSMonitor))
&& flags.HasFlag(GitFeatureFlags.BuiltinFSMonitor)
// but not on Linux yet
&& !RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
// ":internal:" is a custom value to specify the builtin
// FS Monitor feature.
Expand Down
14 changes: 4 additions & 10 deletions Scalar.FunctionalTests/Tools/ScalarFunctionalTestEnlistment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,11 @@ public string GetPackRoot(FileSystemRunner fileSystem)

public void DeleteEnlistment()
{
string watchmanLocation = ProcessHelper.GetProgramLocation("watchman");
if (!string.IsNullOrEmpty(watchmanLocation))
string envVar = Environment.GetEnvironmentVariable("SCALAR_FUNCTIONAL_TEST_EXPERIMENTAL");

if (bool.TryParse(envVar, out bool result) && result)
{
try
{
ProcessHelper.Run(Path.Combine(watchmanLocation, "watchman"), $"watch-del {this.RepoRoot}");
}
catch (Exception ex)
{
Console.WriteLine($"Failed to delete watch on {this.RepoRoot}. {ex.ToString()}");
}
GitProcess.InvokeProcess(this.RepoRoot, "fsmonitor--daemon --stop");
}

TestResultsHelper.OutputScalarLogs(this);
Expand Down
30 changes: 21 additions & 9 deletions Scalar.UnitTests/Common/GitVersionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,29 @@ public void GetFeatureFlags_MaintenanceBuiltin()
[TestCase]
public void GetFeatureFlags_BuiltinFSMonitor()
{
GitVersion version = new GitVersion(2, 30, 0, "vfs", 0, 0);
GitFeatureFlags gitFeatures = version.GetFeatures();
gitFeatures.HasFlag(GitFeatureFlags.BuiltinFSMonitor).ShouldBeFalse($"Incorrect for version {version}");
var notSupportedVerisons = new List<GitVersion>
{
new GitVersion(2, 31, 0),
new GitVersion(2, 29, 0, "windows"),
new GitVersion(2, 30, 0, "vfs", 0, 1),
};

foreach (GitVersion version in notSupportedVerisons)
{
GitFeatureFlags gitGitFeatures = version.GetFeatures();
gitGitFeatures.HasFlag(GitFeatureFlags.BuiltinFSMonitor).ShouldBeFalse($"Incorrect for version {version}");
}

version.Features.Add("bogus");
gitFeatures = version.GetFeatures();
gitFeatures.HasFlag(GitFeatureFlags.BuiltinFSMonitor).ShouldBeFalse($"Incorrect for version {version}");
var supportedVerisons = new List<GitVersion>
{
new GitVersion(2, 30, 0, "vfs", 0, 0, extra: "exp"),
};

version.Features.Add("fsmonitor--daemon");
gitFeatures = version.GetFeatures();
gitFeatures.HasFlag(GitFeatureFlags.BuiltinFSMonitor).ShouldBeTrue($"Incorrect for version {version}");
foreach (GitVersion version in supportedVerisons)
{
GitFeatureFlags gitGitFeatures = version.GetFeatures();
gitGitFeatures.HasFlag(GitFeatureFlags.BuiltinFSMonitor).ShouldBeTrue($"Incorrect for version {version}");
}
}

[TestCase]
Expand Down

0 comments on commit 389c228

Please sign in to comment.