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

Bugfix/enable Windows CI unit tests and test coverage #4609

Merged
merged 1 commit into from
Jun 10, 2022
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
85 changes: 85 additions & 0 deletions .github/workflows/windows-build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Build and Test
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: windows-2019
env:
CRAFT_TARGET: windows-msvc2019_64-cl
COBERTURA_COVERAGE_FILE: ${{ github.workspace }}\cobertura_coverage\coverage.xml
CRAFT_MASTER_LOCATION: ${{ github.workspace }}\CraftMaster
CRAFT_MASTER_CONFIG: ${{ github.workspace }}\craftmaster.ini
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Install Craft Master with Nextcloud Client Deps
shell: pwsh
run: |
& cmd /C "git clone -q --depth=1 https://invent.kde.org/packaging/craftmaster.git ${{ env.CRAFT_MASTER_LOCATION }} 2>&1"
function craft() {
python "${{ env.CRAFT_MASTER_LOCATION }}\CraftMaster.py" --config "${{ env.CRAFT_MASTER_CONFIG }}" --target ${{ env.CRAFT_TARGET }} -c $args
if($LASTEXITCODE -ne 0) {exit $LASTEXITCODE}
}
craft --add-blueprint-repository [git]https://github.com/nextcloud/desktop-client-blueprints.git
craft craft
craft --install-deps nextcloud-client
- name: Cache Install OpenCppCoverage
id: cache-install-opencppcoverage
uses: actions/cache@v3
with:
path: C:\Program Files\OpenCppCoverage
key: ${{ runner.os }}-cache-install-opencppcoverage

- name: Install OpenCppCoverage
if: steps.cache-install-opencppcoverage.outputs.cache-hit != 'true'
shell: pwsh
run: |
choco install opencppcoverage
- name: Setup PATH
shell: pwsh
run: |
echo "C:\Program Files\OpenCppCoverage" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "${{ github.workspace }}\${{ env.CRAFT_TARGET }}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Compile
shell: pwsh
run: |
function craft() {
python "${{ env.CRAFT_MASTER_LOCATION }}\CraftMaster.py" --config "${{ env.CRAFT_MASTER_CONFIG }}" --target ${{ env.CRAFT_TARGET }} -c $args
if($LASTEXITCODE -ne 0) {exit $LASTEXITCODE}
}
craft --src-dir ${{ github.workspace }} nextcloud-client
- name: Run tests
shell: pwsh
run: |
function runTestsAndCreateCoverage() {
$buildFolder = "${{ github.workspace }}\${{ env.CRAFT_TARGET }}\build\nextcloud-client\work\build"
cd $buildFolder
$binFolder = "$buildFolder\bin"
& OpenCppCoverage.exe --quiet --sources ${{ github.workspace }} --modules $binFolder\*.dll* --export_type cobertura:${{ env.COBERTURA_COVERAGE_FILE }} --cover_children -- ctest --output-on-failure --timeout 300 -j (Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors
}
runTestsAndCreateCoverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ${{ github.workspace }}\cobertura_coverage
fail_ci_if_error: true
42 changes: 0 additions & 42 deletions appveyor.yml

This file was deleted.

25 changes: 25 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
codecov:
branch: master
ci:
- "!drone.nextcloud.com"
- "!appveyor"

coverage:
precision: 2
round: down
range: "70...100"
status:
project:
default:
threshold: 0.5

comment:
layout: "header, diff, changes, uncovered, tree"
behavior: default

github_checks:
annotations: false

ignore:
- "src/3rdparty"

3 changes: 1 addition & 2 deletions appveyor.ini → craftmaster.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ Compile/UseNinja = True

Paths/downloaddir = ${Variables:Root}\downloads
ShortPath/Enabled = False
ShortPath/EnableJunctions = True
ShortPath/JunctionDir = C:\CM-SP\
ShortPath/EnableJunctions = False

; Packager/RepositoryUrl = https://files.kde.org/craft/
Packager/PackageType = NullsoftInstallerPackager
Expand Down
14 changes: 10 additions & 4 deletions src/libsync/vfs/cfapi/hydrationjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,23 @@ void OCC::HydrationJob::cancel()
_job->cancel();
}

_signalSocket->write("cancelled");
_signalSocket->close();
_transferDataSocket->close();
if (_signalSocket) {
_signalSocket->write("cancelled");
_signalSocket->close();
}

if (_transferDataSocket) {
_transferDataSocket->close();
}
emitFinished(Cancelled);
}

void OCC::HydrationJob::emitFinished(Status status)
{
_status = status;
_signalSocket->close();
if (_signalSocket) {
_signalSocket->close();
}

if (status == Success) {
connect(_transferDataSocket, &QLocalSocket::disconnected, this, [=] {
Expand Down
1 change: 1 addition & 0 deletions test/testchunkingng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ private slots:
}

void testPercentEncoding() {
QTextCodec::codecForLocale()->setCodecForLocale(QTextCodec::codecForName("UTF-8"));
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
fakeFolder.syncEngine().account()->setCapabilities({ { "dav", QVariantMap{ {"chunking", "1.0"} } } });
const int size = 5 * 1000 * 1000;
Expand Down
8 changes: 6 additions & 2 deletions test/testexcludedfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ private slots:
QCOMPARE(check_file_full("latex/songbook/my_manuscript.tex.tmp"), CSYNC_FILE_EXCLUDE_LIST);

#ifdef _WIN32
QCOMPARE(check_file_full("file_trailing_space "), CSYNC_FILE_EXCLUDE_TRAILING_SPACE);
QCOMPARE(check_file_full(" file_leading_space"), CSYNC_NOT_EXCLUDED);
QCOMPARE(check_file_full("file_trailing_space "), CSYNC_NOT_EXCLUDED);
QCOMPARE(check_file_full(" file_leading_and_trailing_space "), CSYNC_NOT_EXCLUDED);
QCOMPARE(check_file_full("file_trailing_dot."), CSYNC_FILE_EXCLUDE_INVALID_CHAR);
QCOMPARE(check_file_full("AUX"), CSYNC_FILE_EXCLUDE_INVALID_CHAR);
QCOMPARE(check_file_full("file_invalid_char<"), CSYNC_FILE_EXCLUDE_INVALID_CHAR);
Expand Down Expand Up @@ -346,7 +348,9 @@ private slots:
QCOMPARE(check_file_traversal("latex/songbook/my_manuscript.tex.tmp"), CSYNC_FILE_EXCLUDE_LIST);

#ifdef _WIN32
QCOMPARE(check_file_traversal("file_trailing_space "), CSYNC_FILE_EXCLUDE_TRAILING_SPACE);
QCOMPARE(check_file_traversal(" file_leading_space"), CSYNC_NOT_EXCLUDED);
QCOMPARE(check_file_traversal("file_trailing_space "), CSYNC_NOT_EXCLUDED);
QCOMPARE(check_file_traversal(" file_leading_and_trailing_space "), CSYNC_NOT_EXCLUDED);
QCOMPARE(check_file_traversal("file_trailing_dot."), CSYNC_FILE_EXCLUDE_INVALID_CHAR);
QCOMPARE(check_file_traversal("AUX"), CSYNC_FILE_EXCLUDE_INVALID_CHAR);
QCOMPARE(check_file_traversal("file_invalid_char<"), CSYNC_FILE_EXCLUDE_INVALID_CHAR);
Expand Down
7 changes: 5 additions & 2 deletions test/testpushnotifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,18 @@ private slots:
{
FakeWebSocketServer fakeServer;
auto account = FakeWebSocketServer::createAccount();
account->setPushNotificationsReconnectInterval(0);

// Let if fail a few times
QVERIFY(failThreeAuthenticationAttempts(fakeServer, account));
account->pushNotifications()->setup();
QVERIFY(failThreeAuthenticationAttempts(fakeServer, account));

account->setPushNotificationsReconnectInterval(0);

// Push notifications should try to reconnect
QVERIFY(fakeServer.authenticateAccount(account));

account->setPushNotificationsReconnectInterval(1000 * 60 * 2);
}

void testSetup_correctCredentials_authenticateAndEmitReady()
Expand Down Expand Up @@ -250,7 +254,6 @@ private slots:
{
FakeWebSocketServer fakeServer;
auto account = FakeWebSocketServer::createAccount();
account->setPushNotificationsReconnectInterval(0);
QSignalSpy pushNotificationsDisabledSpy(account.data(), &OCC::Account::pushNotificationsDisabled);
QVERIFY(pushNotificationsDisabledSpy.isValid());

Expand Down
Loading