Skip to content

Commit cbcdcb1

Browse files
authored
Merge pull request #371 from dscho/run-scalar-functional-tests-and-fix-built-in-fsmonitor
Fix the built-in FSMonitor, and run Scalar's Functional Tests as part of the automated builds
2 parents b39873a + 059c4b3 commit cbcdcb1

File tree

4 files changed

+221
-7
lines changed

4 files changed

+221
-7
lines changed
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
name: Scalar Functional Tests
2+
3+
env:
4+
SCALAR_REPOSITORY: dscho/scalar
5+
SCALAR_REF: vfs-2.32.0
6+
DEBUG_WITH_TMATE: false
7+
8+
on:
9+
push:
10+
branches: [ vfs-* ]
11+
pull_request:
12+
branches: [ vfs-* ]
13+
14+
jobs:
15+
scalar:
16+
name: "Scalar Functional Tests"
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
# Order by runtime (in descending order)
22+
os: [windows-2019, macos-10.15, ubuntu-16.04, ubuntu-18.04, ubuntu-20.04]
23+
features: [false, experimental]
24+
exclude:
25+
# The built-in FSMonitor is not (yet) supported on Linux
26+
- os: ubuntu-16.04
27+
features: experimental
28+
- os: ubuntu-18.04
29+
features: experimental
30+
- os: ubuntu-20.04
31+
features: experimental
32+
runs-on: ${{ matrix.os }}
33+
34+
env:
35+
BUILD_FRAGMENT: bin/Release/netcoreapp3.1
36+
37+
steps:
38+
- name: Check out Git's source code
39+
uses: actions/checkout@v2
40+
41+
- name: Setup build tools on Windows
42+
if: runner.os == 'Windows'
43+
uses: git-for-windows/setup-git-for-windows-sdk@v1
44+
45+
- name: Provide a minimal `install` on Windows
46+
if: runner.os == 'Windows'
47+
shell: bash
48+
run: |
49+
test -x /usr/bin/install ||
50+
tr % '\t' >/usr/bin/install <<-\EOF
51+
#!/bin/sh
52+
53+
cmd=cp
54+
while test $# != 0
55+
do
56+
%case "$1" in
57+
%-d) cmd="mkdir -p";;
58+
%-m) shift;; # ignore mode
59+
%*) break;;
60+
%esac
61+
%shift
62+
done
63+
64+
exec $cmd "$@"
65+
EOF
66+
67+
- name: Install build dependencies for Git (Linux)
68+
if: runner.os == 'Linux'
69+
run: |
70+
sudo apt-get update
71+
sudo apt-get -q -y install libssl-dev libcurl4-openssl-dev gettext
72+
73+
- name: Build and install Git
74+
shell: bash
75+
env:
76+
NO_TCLTK: Yup
77+
run: |
78+
# We do require a VFS version
79+
def_ver="$(sed -n 's/DEF_VER=\(.*vfs.*\)/\1/p' GIT-VERSION-GEN)"
80+
test -n "$def_ver"
81+
82+
# Ensure that `git version` reflects DEF_VER
83+
case "$(git describe --match "v[0-9]*vfs*" HEAD)" in
84+
${def_ver%%.vfs.*}.vfs.*) ;; # okay, we can use this
85+
*) git -c user.name=ci -c user.email=ci@github tag -m for-testing ${def_ver}.NNN.g$(git rev-parse --short HEAD);;
86+
esac
87+
88+
SUDO=
89+
extra=
90+
case "${{ runner.os }}" in
91+
Windows)
92+
extra=DESTDIR=/c/Progra~1/Git
93+
cygpath -aw "/c/Program Files/Git/cmd" >>$GITHUB_PATH
94+
;;
95+
Linux)
96+
SUDO=sudo
97+
extra=prefix=/usr
98+
;;
99+
macOS)
100+
SUDO=sudo
101+
extra=prefix=/usr/local
102+
;;
103+
esac
104+
105+
$SUDO make -j5 $extra install
106+
107+
- name: Ensure that we use the built Git (Windows)
108+
if: runner.os == 'Windows'
109+
shell: powershell
110+
run: |
111+
cmd /c where git
112+
git version
113+
if ((git version) -like "*.vfs.*") { echo Good } else { exit 1 }
114+
115+
- name: Check out Scalar's source code
116+
uses: actions/checkout@v2
117+
with:
118+
fetch-depth: 0 # Indicate full history so Nerdbank.GitVersioning works.
119+
path: scalar
120+
repository: ${{ env.SCALAR_REPOSITORY }}
121+
ref: ${{ env.SCALAR_REF }}
122+
123+
- name: Setup .NET Core
124+
uses: actions/setup-dotnet@v1
125+
with:
126+
dotnet-version: 3.1.302
127+
128+
- name: Install dependencies
129+
run: dotnet restore
130+
working-directory: scalar
131+
env:
132+
DOTNET_NOLOGO: 1
133+
134+
- name: Build
135+
working-directory: scalar
136+
run: dotnet build --configuration Release --no-restore -p:UseAppHost=true # Force generation of executable on macOS.
137+
138+
- name: Setup platform (Linux)
139+
if: runner.os == 'Linux'
140+
run: |
141+
echo "BUILD_PLATFORM=${{ runner.os }}" >>$GITHUB_ENV
142+
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.features }}" >>$GITHUB_ENV
143+
144+
- name: Setup platform (Mac)
145+
if: runner.os == 'macOS'
146+
run: |
147+
echo 'BUILD_PLATFORM=Mac' >>$GITHUB_ENV
148+
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.features }}" >>$GITHUB_ENV
149+
150+
- name: Setup platform (Windows)
151+
if: runner.os == 'Windows'
152+
run: |
153+
echo "BUILD_PLATFORM=${{ runner.os }}" >>$env:GITHUB_ENV
154+
echo 'BUILD_FILE_EXT=.exe' >>$env:GITHUB_ENV
155+
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.features }}" >>$env:GITHUB_ENV
156+
157+
- name: Configure feature.scalar
158+
run: git config --global feature.scalar ${{ matrix.features }}
159+
160+
- id: functional_test
161+
name: Functional test
162+
timeout-minutes: 60
163+
working-directory: scalar
164+
shell: bash
165+
run: |
166+
export GIT_TRACE2_EVENT="$PWD/$TRACE2_BASENAME/Event"
167+
export GIT_TRACE2_PERF="$PWD/$TRACE2_BASENAME/Perf"
168+
export GIT_TRACE2_EVENT_BRIEF=true
169+
export GIT_TRACE2_PERF_BRIEF=true
170+
mkdir -p "$TRACE2_BASENAME"
171+
mkdir -p "$TRACE2_BASENAME/Event"
172+
mkdir -p "$TRACE2_BASENAME/Perf"
173+
git version --build-options
174+
cd ../out
175+
PATH="$PWD/Scalar/$BUILD_FRAGMENT:$PWD/Scalar.Service/$BUILD_FRAGMENT:$PATH"
176+
Scalar.FunctionalTests/$BUILD_FRAGMENT/Scalar.FunctionalTests$BUILD_FILE_EXT --test-scalar-on-path --test-git-on-path --timeout=300000 --full-suite
177+
178+
- name: Force-stop FSMonitor daemons and Git processes (Windows)
179+
if: runner.os == 'Windows' && matrix.features == 'experimental' && (success() || failure())
180+
shell: bash
181+
run: |
182+
set -x
183+
wmic process get CommandLine,ExecutablePath,HandleCount,Name,ParentProcessID,ProcessID
184+
wmic process where "CommandLine Like '%fsmonitor--daemon %run'" delete
185+
wmic process where "ExecutablePath Like '%git.exe'" delete
186+
187+
- id: trace2_zip_unix
188+
if: runner.os != 'Windows' && ( success() || failure() ) && ( steps.functional_test.conclusion == 'success' || steps.functional_test.conclusion == 'failure' )
189+
name: Zip Trace2 Logs (Unix)
190+
shell: bash
191+
working-directory: scalar
192+
run: zip -q -r $TRACE2_BASENAME.zip $TRACE2_BASENAME/
193+
194+
- id: trace2_zip_windows
195+
if: runner.os == 'Windows' && ( success() || failure() ) && ( steps.functional_test.conclusion == 'success' || steps.functional_test.conclusion == 'failure' )
196+
name: Zip Trace2 Logs (Windows)
197+
working-directory: scalar
198+
run: Compress-Archive -DestinationPath ${{ env.TRACE2_BASENAME }}.zip -Path ${{ env.TRACE2_BASENAME }}
199+
200+
- name: Archive Trace2 Logs
201+
if: ( success() || failure() ) && ( steps.trace2_zip_unix.conclusion == 'success' || steps.trace2_zip_windows.conclusion == 'success' )
202+
uses: actions/upload-artifact@v2
203+
with:
204+
name: ${{ env.TRACE2_BASENAME }}.zip
205+
path: scalar/${{ env.TRACE2_BASENAME }}.zip
206+
retention-days: 3
207+
208+
# The GitHub Action `action-tmate` allows developers to connect to the running agent
209+
# using SSH (it will be a `tmux` session; on Windows agents it will be inside the MSYS2
210+
# environment in `C:\msys64`, therefore it can be slightly tricky to interact with
211+
# Git for Windows, which runs a slightly incompatible MSYS2 runtime).
212+
- name: action-tmate
213+
if: env.DEBUG_WITH_TMATE == 'true' && failure()
214+
uses: mxschmitt/action-tmate@v3
215+
with:
216+
limit-access-to-actor: true

builtin/fsmonitor--daemon.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,6 @@ static int do_handle_client(struct fsmonitor_daemon_state *state,
672672
*/
673673
do_flush = 1;
674674
do_trivial = 1;
675-
do_cookie = 1;
676675

677676
} else if (!skip_prefix(command, "builtin:", &p)) {
678677
/* assume V1 timestamp or garbage */
@@ -686,7 +685,6 @@ static int do_handle_client(struct fsmonitor_daemon_state *state,
686685
"fsmonitor: unsupported V1 protocol '%s'"),
687686
command);
688687
do_trivial = 1;
689-
do_cookie = 1;
690688

691689
} else {
692690
/* We have "builtin:*" */
@@ -696,7 +694,6 @@ static int do_handle_client(struct fsmonitor_daemon_state *state,
696694
"fsmonitor: invalid V2 protocol token '%s'",
697695
command);
698696
do_trivial = 1;
699-
do_cookie = 1;
700697

701698
} else {
702699
/*

fsmonitor-ipc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ int fsmonitor_ipc__send_query(const char *since_token,
4444
trace2_region_enter("fsm_client", "query", NULL);
4545

4646
trace2_data_string("fsm_client", NULL, "query/command",
47-
since_token ? since_token : "(null-token)");
47+
since_token);
4848

4949
try_again:
5050
state = ipc_client_try_connect(fsmonitor_ipc__get_path(), &options,
@@ -53,7 +53,7 @@ int fsmonitor_ipc__send_query(const char *since_token,
5353
switch (state) {
5454
case IPC_STATE__LISTENING:
5555
ret = ipc_client_send_command_to_connection(
56-
connection, since_token, since_token ? strlen(since_token) : 0, answer);
56+
connection, since_token, strlen(since_token), answer);
5757
ipc_client_close_connection(connection);
5858

5959
trace2_data_intmax("fsm_client", NULL,

fsmonitor.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,9 @@ void refresh_fsmonitor(struct index_state *istate)
290290
trace_printf_key(&trace_fsmonitor, "refresh fsmonitor");
291291

292292
if (r->settings.use_builtin_fsmonitor > 0) {
293-
query_success = !fsmonitor_ipc__send_query(
294-
istate->fsmonitor_last_update, &query_result);
293+
query_success = istate->fsmonitor_last_update &&
294+
!fsmonitor_ipc__send_query(istate->fsmonitor_last_update,
295+
&query_result);
295296
if (query_success) {
296297
/*
297298
* The response contains a series of nul terminated

0 commit comments

Comments
 (0)