Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Watchman-enabled functional tests to GitHub Actions CI #436

Merged
merged 5 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +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]

env:
BUILD_FRAGMENT: bin/Release/netcoreapp3.1
Expand Down Expand Up @@ -92,6 +93,40 @@ 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 "::add-path::C:\Program Files\Watchman"

- name: Functional test
shell: bash
run: |
Expand Down
15 changes: 14 additions & 1 deletion Scalar.FunctionalTests/FileSystemRunners/SystemIORunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,20 @@ public override bool FileExists(string path)

public override string MoveFile(string sourcePath, string targetPath)
{
File.Move(sourcePath, targetPath);
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
File.Move(sourcePath, targetPath);
}
else
{
// Use rename(2) on POSIX instead of separate link(2)/unlink(2)
// calls, which File.Move() uses to avoid overwriting the
// target file should it exist. However, using link(2)
// results in unexpected missed event notifications from
// Watchman to Git's fsmonitor hook on some macOS versions,
// which in turn results in test failures for Scalar.
Rename(sourcePath, targetPath);
}
return string.Empty;
}

Expand Down
4 changes: 2 additions & 2 deletions Scalar.FunctionalTests/Tools/GitHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public static void ValidateGitCommand(
ProcessResult expectedResult = GitProcess.InvokeProcess(controlRepoRoot, command, environmentVariables);
ProcessResult actualResult = GitHelpers.InvokeGitAgainstScalarRepo(scalarRepoRoot, command, environmentVariables);

LinesShouldMatch(command + " Errors Lines", actualResult.Errors, expectedResult.Errors);
LinesShouldMatch(command + " Output Lines", actualResult.Output, expectedResult.Output);
LinesShouldMatch(command + " Errors Lines", expectedResult.Errors, actualResult.Errors);
LinesShouldMatch(command + " Output Lines", expectedResult.Output, actualResult.Output);

if (command != "status")
{
Expand Down
4 changes: 2 additions & 2 deletions Scalar/CommandLine/CloneVerb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ private Result TryInitRepo()
GitProcess.Result initResult = GitProcess.Init(this.enlistment);
if (initResult.ExitCodeIsFailure)
{
string error = string.Format("Could not init repo at to {0}: {1}", repoPath, initResult.Errors);
string error = string.Format("Could not init repo at {0}: {1}", repoPath, initResult.Errors);
this.tracer.RelatedError(error);
return new Result(error);
}
Expand All @@ -694,7 +694,7 @@ private Result TryInitRepo()
GitProcess.Result sparseCheckoutResult = GitProcess.SparseCheckoutInit(this.enlistment);
if (sparseCheckoutResult.ExitCodeIsFailure)
{
string error = string.Format("Could not init sparse-checkout at to {0}: {1}", repoPath, sparseCheckoutResult.Errors);
string error = string.Format("Could not init sparse-checkout at {0}: {1}", repoPath, sparseCheckoutResult.Errors);
this.tracer.RelatedError(error);
return new Result(error);
}
Expand Down
15 changes: 14 additions & 1 deletion Scripts/Mac/RunFunctionalTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@ if [ -z $CONFIGURATION ]; then
CONFIGURATION=Debug
fi

TESTS_EXEC=$SCALAR_OUTPUTDIR/Scalar.FunctionalTests/bin/$CONFIGURATION/netcoreapp3.1/osx-x64/publish/Scalar.FunctionalTests
PUBLISH_FRAGMENT="bin/$CONFIGURATION/netcoreapp3.1/osx-x64/publish"
FUNCTIONAL_TESTS_DIR="$SCALAR_OUTPUTDIR/Scalar.FunctionalTests/$PUBLISH_FRAGMENT"

if [ "$2" = "--test-scalar-on-path" ]; then
echo "PATH:"
echo "$PATH"
echo "Scalar location:"
where scalar
else
# Copy most recently build Scalar binaries
rsync -r "$SCALAR_OUTPUTDIR/Scalar/$PUBLISH_FRAGMENT/" "$FUNCTIONAL_TESTS_DIR"
fi

TESTS_EXEC="$FUNCTIONAL_TESTS_DIR/Scalar.FunctionalTests"

mkdir ~/Scalar.FT

Expand Down