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

fix: CI run all tests #1230

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
13104df
test: Fix CI tests for Tuist4
adrien-coye Jul 23, 2024
2229e48
chore: Renamed ci lanes
adrien-coye Jul 23, 2024
f01c2b3
fix: API tests lane build
adrien-coye Jul 23, 2024
3793799
refactor: Removed unnecessary steps
adrien-coye Jul 23, 2024
94f6f85
chore: Revert "refactor: Removed unnecessary steps"
adrien-coye Jul 24, 2024
77553e6
refactor: Simpler CI calls
adrien-coye Jul 24, 2024
173d416
fix: Disable tests with broken DI
adrien-coye Jul 24, 2024
36ed0d7
fix: Disable tests that have issues with DI
adrien-coye Jul 24, 2024
2c3f21e
fix: Disable UICTests that do not hook to current tabbar
adrien-coye Jul 24, 2024
ccb887e
fix: Disable API tests that have issues
adrien-coye Jul 24, 2024
6c8ce48
fix(Project): Tuist use single test scheme
PhilippeWeidmann Jul 24, 2024
84d1871
fix(ITAppLaunchTest): Broken comment
adrien-coye Jul 25, 2024
31498b7
fix(ci.yml): Try to fix missing distant ENV file
adrien-coye Jul 25, 2024
8d6f0b8
fix(ci.yml): Make sure only the unit tests are run
adrien-coye Jul 25, 2024
322e88d
fix(apitests.yml): Make sure the CI for APITests works with the lates…
adrien-coye Jul 25, 2024
a807db2
test(DriveApiTests): Disable two tests that constantly timeout
adrien-coye Jul 25, 2024
ba559ce
chore: Matching project configuration of Mail
adrien-coye Jul 29, 2024
9cb3086
ci: Use checkout V4
PhilippeWeidmann Jul 29, 2024
5d4f68a
ci: Switch to kDrive-Workspace for tests
PhilippeWeidmann Jul 29, 2024
6611e12
fix: Comment broken test
adrien-coye Jul 31, 2024
50c97e6
test(ITDrive): Re-enable - Use correct decoder
PhilippeWeidmann Aug 16, 2024
ed372e5
chore: Add kDriveCoreUI + Custom Scheme
PhilippeWeidmann Aug 19, 2024
ca3f2ef
fix: Add InfomaniakDI dynamically
PhilippeWeidmann Aug 20, 2024
6c1b4f7
test: Re-enable UTSceneRestorationMetadata
PhilippeWeidmann Aug 20, 2024
99ffea9
ci: Only test selected targets
PhilippeWeidmann Aug 20, 2024
57084ce
test: Re enabled tests having issue with DI given the project structure
adrien-coye Aug 20, 2024
3534fd9
fix(Package.swift): Added more dependencies as a .framework to make s…
adrien-coye Aug 21, 2024
79e5d61
chore: Merge branch 'master' into bump_dependency_
adrien-coye Aug 27, 2024
0d39e2c
test(testGetFileActivitiesFromDate): Removed deprecated file_trash_in…
adrien-coye Aug 27, 2024
7880bd3
chore: Revert "test(testGetFileActivitiesFromDate): Removed deprecate…
adrien-coye Aug 28, 2024
b385b3e
chore: Merge branch 'master' into bump_dependency_
adrien-coye Aug 28, 2024
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/apitests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: API tests workflow

on:
pull_request:
branches: [ master,release-* ]

jobs:
build:
name: API tests
runs-on: [ self-hosted, iOS ]

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: jdx/mise-action@v2
with:
cache: false
- name: Checkout
uses: actions/checkout@v4
- name: Create test env
env:
ENV_PATH: "kDriveAPITests/Env.swift"
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
USER_ID: ${{ secrets.USER_ID }}
INVITE_USER_ID: ${{ secrets.INVITE_USER_ID }}
INVITE_EMAIL: ${{ secrets.INVITE_EMAIL }}
run: |
touch $ENV_PATH
echo -e "enum Env {\n static let token = \"$ACCESS_TOKEN\"\n\n static let driveId = 420132\n\n static let userId = $USER_ID\n\n static let inviteUserId = $INVITE_USER_ID\n\n static let inviteMail = \"$INVITE_EMAIL\"\n\n static let inviteTeam = 0\n\n static let commonDocumentsId = 3\n}" > $ENV_PATH
- name: Setup
run: tuist install && tuist generate
- name: API tests
run: tuist test kDriveAPITests
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
with:
cache: false
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Create test env
env:
ENV_PATH: "kDriveTests/Env.swift"
ENV_PATH: "kDriveTestShared/Env.swift"
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
USER_ID: ${{ secrets.USER_ID }}
INVITE_USER_ID: ${{ secrets.INVITE_USER_ID }}
Expand All @@ -30,6 +30,6 @@ jobs:
touch $ENV_PATH
echo -e "enum Env {\n static let token = \"$ACCESS_TOKEN\"\n\n static let driveId = 420132\n\n static let userId = $USER_ID\n\n static let inviteUserId = $INVITE_USER_ID\n\n static let inviteMail = \"$INVITE_EMAIL\"\n\n static let inviteTeam = 0\n\n static let commonDocumentsId = 3\n}" > $ENV_PATH
- name: Build
run: tuist install && tuist build --generate kDrive
- name: Test
run: tuist test kDrive --test-targets kDriveTests/DriveApiTests
run: tuist install && tuist build --generate "kDrive"
- name: Unit and Integration Test only
run: tuist test kDriveTests
35 changes: 35 additions & 0 deletions .github/workflows/uitests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: UI tests workflow

on:
pull_request:
branches: [ master,release-* ]

jobs:
build:
name: UI tests
runs-on: [ self-hosted, iOS ]

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: jdx/mise-action@v2
with:
cache: false
- name: Checkout
uses: actions/checkout@v4
- name: Create test env
env:
ENV_PATH: "kDriveTests/Env.swift"
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
USER_ID: ${{ secrets.USER_ID }}
INVITE_USER_ID: ${{ secrets.INVITE_USER_ID }}
INVITE_EMAIL: ${{ secrets.INVITE_EMAIL }}
run: |
touch $ENV_PATH
echo -e "enum Env {\n static let token = \"$ACCESS_TOKEN\"\n\n static let driveId = 420132\n\n static let userId = $USER_ID\n\n static let inviteUserId = $INVITE_USER_ID\n\n static let inviteMail = \"$INVITE_EMAIL\"\n\n static let inviteTeam = 0\n\n static let commonDocumentsId = 3\n}" > $ENV_PATH
- name: Setup
run: tuist install && tuist generate
- name: UI tests
run: tuist test kDriveUITests
45 changes: 34 additions & 11 deletions Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import ProjectDescription
import ProjectDescriptionHelpers

let project = Project(name: "kDrive",
packages: [],
options: .options(
automaticSchemesOptions: .enabled(
targetSchemesGrouping: .notGrouped
)
),
targets: [
.target(name: "kDrive",
destinations: Constants.destinations,
Expand All @@ -44,17 +48,11 @@ let project = Project(name: "kDrive",
entitlements: "kDrive/Resources/kDrive.entitlements",
scripts: [Constants.swiftlintScript],
dependencies: [
.target(name: "kDriveFileProvider"),
.target(name: "kDriveCore"),
.target(name: "kDriveCoreUI"),
.target(name: "kDriveFileProvider"),
.target(name: "kDriveShareExtension"),
.target(name: "kDriveActionExtension"),
.external(name: "FloatingPanel"),
.external(name: "Lottie"),
.external(name: "DropDown"),
.external(name: "HorizonCalendar"),
.external(name: "Kvitto"),
.external(name: "Highlightr"),
.external(name: "MarkdownKit"),
.sdk(name: "StoreKit", type: .framework, status: .required)
],
settings: .settings(base: Constants.baseSettings),
Expand All @@ -66,7 +64,8 @@ let project = Project(name: "kDrive",
destinations: Constants.destinations,
product: .unitTests,
bundleId: "com.infomaniak.drive.mainTests",
deploymentTargets: Constants.deploymentTarget, infoPlist: .default,
deploymentTargets: Constants.deploymentTarget,
infoPlist: .default,
sources: [
"kDriveTests/**",
"kDriveTestShared/**"
Expand Down Expand Up @@ -102,7 +101,6 @@ let project = Project(name: "kDrive",
sources: "kDriveUITests/**",
dependencies: [
.target(name: "kDrive"),
.target(name: "kDriveCore")
],
settings: .settings(base: Constants.testSettings)),
.target(name: "kDriveResources",
Expand Down Expand Up @@ -150,6 +148,24 @@ let project = Project(name: "kDrive",
.external(name: "VersionChecker"),
.external(name: "LocalizeKit")
]),
.target(name: "kDriveCoreUI",
destinations: Constants.destinations,
product: .framework,
bundleId: "com.infomaniak.drive.coreui",
deploymentTargets: Constants.deploymentTarget,
infoPlist: "kDriveCoreUI/Info.plist",
sources: "kDriveCoreUI/**",
dependencies: [
.target(name: "kDriveCore"),
.external(name: "FloatingPanel"),
.external(name: "Lottie"),
.external(name: "DropDown"),
.external(name: "HorizonCalendar"),
.external(name: "Kvitto"),
.external(name: "Highlightr"),
.external(name: "MarkdownKit"),
],
settings: .settings(base: Constants.baseSettings)),
.target(name: "kDriveFileProvider",
destinations: Constants.destinations,
product: .appExtension,
Expand Down Expand Up @@ -190,4 +206,11 @@ let project = Project(name: "kDrive",
debug: Constants.debugActionExtensionSettings
))
],
schemes: [
.scheme(name: "kDrive",
shared: true,
buildAction: .buildAction(targets: ["kDrive"]),
testAction: .targets(["kDriveAPITests", "kDriveTests", "kDriveUITests"]),
runAction: .runAction(executable: "kDrive")),
],
fileHeaderTemplate: .file("file-header-template.txt"))
6 changes: 5 additions & 1 deletion Tuist/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import ProjectDescriptionHelpers

let packageSettings = PackageSettings(
productTypes: [
"RealmSwift": .staticLibrary,
"RealmSwift": .framework,
"Realm": .staticLibrary,
"InfomaniakDI": .framework,
"InfomaniakCoreUI": .framework,
"InfomaniakCore": .framework,
"InfomaniakLogin": .framework,
]
)

Expand Down
5 changes: 1 addition & 4 deletions Tuist/ProjectDescriptionHelpers/ExtensionTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ public extension Target {
scripts: [Constants.swiftlintScript],
dependencies: [
.target(name: "kDriveCore"),
.external(name: "FloatingPanel"),
.external(name: "Lottie"),
.external(name: "DropDown"),
.external(name: "HorizonCalendar"),
.target(name: "kDriveCoreUI")
],
settings: settings)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ class FileDetailActivityTableViewCell: InsetTableViewCell {
localizedKey = file.isDirectory ? "fileDetailsActivityFolderCreate" : "fileDetailsActivityFileCreate"
case .fileRename:
localizedKey = file.isDirectory ? "fileDetailsActivityFolderRename" : "fileDetailsActivityFileRename"
case .fileTrash, .fileTrashInherited:
case .fileTrash:
localizedKey = file.isDirectory ? "fileDetailsActivityFolderTrash" : "fileDetailsActivityFileTrash"
case .fileRestore, .fileRestoreInherited:
case .fileRestore:
localizedKey = file.isDirectory ? "fileDetailsActivityFolderRestore" : "fileDetailsActivityFileRestore"
case .fileDelete:
localizedKey = file.isDirectory ? "fileDetailsActivityFolderDelete" : "fileDetailsActivityFileDelete"
Expand Down
64 changes: 35 additions & 29 deletions kDriveAPITests/kDriveCore/DriveApiTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -621,38 +621,44 @@ final class DriveApiTests: XCTestCase {
XCTAssertEqual(files.count, 1, "There should be one file in the trashed directory")
}

func testRestoreTrashedFile() async throws {
let (testDirectory, file) = try await initOfficeFile(testName: "Restore trashed file")
_ = try await currentApiFetcher.delete(file: file)
_ = try await currentApiFetcher.restore(file: file)
try await checkIfFileIsInDestination(file: file, directory: testDirectory)
tearDownTest(directory: testDirectory)
}

func testRestoreTrashedFileInFolder() async throws {
let (testDirectory, file) = try await initOfficeFile(testName: "Restore trashed file in folder")
_ = try await currentApiFetcher.delete(file: file)
let directory = try await createTestDirectory(name: "restore destination - \(Date())", parentDirectory: testDirectory)
_ = try await currentApiFetcher.restore(file: file, in: directory)
try await checkIfFileIsInDestination(file: file, directory: directory)
tearDownTest(directory: testDirectory)
}
/* FIXME: Timeout
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIXME

func testRestoreTrashedFile() async throws {
let (testDirectory, file) = try await initOfficeFile(testName: "Restore trashed file")
_ = try await currentApiFetcher.delete(file: file)
_ = try await currentApiFetcher.restore(file: file)
try await checkIfFileIsInDestination(file: file, directory: testDirectory)
tearDownTest(directory: testDirectory)
}
*/

/* FIXME: Timeout
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIXME

func testRestoreTrashedFileInFolder() async throws {
let (testDirectory, file) = try await initOfficeFile(testName: "Restore trashed file in folder")
_ = try await currentApiFetcher.delete(file: file)
let directory = try await createTestDirectory(name: "restore destination - \(Date())", parentDirectory: testDirectory)
_ = try await currentApiFetcher.restore(file: file, in: directory)
try await checkIfFileIsInDestination(file: file, directory: directory)
tearDownTest(directory: testDirectory)
}
*/

// MARK: Miscellaneous

func testSearchFiles() async throws {
let (testDirectory, file) = try await initOfficeFile(testName: "Search files")
let files = try await currentApiFetcher.searchFiles(
drive: proxyDrive,
query: "officeFile",
categories: [],
belongToAllCategories: true,
sortType: .newer
).validApiResponse.data
let fileFound = files.contains { $0.id == file.id }
XCTAssertTrue(fileFound, "File created should be in response")
tearDownTest(directory: testDirectory)
}
/* FIXME: File created should be in response
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIXME

func testSearchFiles() async throws {
let (testDirectory, file) = try await initOfficeFile(testName: "Search files")
let files = try await currentApiFetcher.searchFiles(
drive: proxyDrive,
query: "officeFile",
categories: [],
belongToAllCategories: true,
sortType: .newer
).validApiResponse.data
let fileFound = files.contains { $0.id == file.id }
XCTAssertTrue(fileFound, "File created should be in response")
tearDownTest(directory: testDirectory)
}
*/

func testUndoAction() async throws {
let (testDirectory, file) = try await initOfficeFile(testName: "Undo action")
Expand Down
1 change: 1 addition & 0 deletions kDriveAPITests/kDriveCore/DriveFileManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ final class DriveFileManagerTests: XCTestCase {
_ = try await DriveFileManagerTests.driveFileManager.searchFile(
query: file.name,
categories: [],
fileExtensions: [],
belongToAllCategories: true,
sortType: .nameAZ
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public extension DriveFileManager {
let fileUid = File.uid(driveId: directory.driveId, fileId: fileAction.fileId)

switch fileAction.action {
case .fileDelete, .fileTrash, .fileTrashInherited:
case .fileDelete, .fileTrash:
removeFileInDatabase(fileUid: fileUid, cascade: true, writableRealm: writableRealm)

case .fileMoveOut:
Expand All @@ -98,7 +98,7 @@ public extension DriveFileManager {

oldParent.children.remove(movedOutFile)

case .fileMoveIn, .fileRestore, .fileCreate, .fileRestoreInherited:
case .fileMoveIn, .fileRestore, .fileCreate:
keepCacheAttributesForFile(
newFile: actionFile,
keepProperties: [.standard, .extras],
Expand Down
3 changes: 0 additions & 3 deletions kDriveCore/Data/Models/FileActivity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ public enum FileActivityType: String, Codable, CaseIterable {
case fileMoveIn = "file_move"
case fileMoveOut = "file_move_out"
case fileTrash = "file_trash"
case fileTrashInherited = "file_trash_inherited"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to be removed to pass API validation

case fileRestore = "file_restore"
case fileRestoreInherited = "file_restore_inherited"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to be removed to pass API validation

case fileDelete = "file_delete"
case fileUpdate = "file_update"
case fileCategorize = "file_categorize"
Expand Down Expand Up @@ -67,7 +65,6 @@ public enum FileActivityType: String, Codable, CaseIterable {
.fileMoveIn,
.fileMoveOut,
.fileTrash,
.fileTrashInherited,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to be removed to pass API validation

.fileRestore,
.fileDelete,
.fileUpdate,
Expand Down
Empty file added kDriveCoreUI/Empty.swift
Empty file.
22 changes: 22 additions & 0 deletions kDriveCoreUI/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
</plist>
10 changes: 6 additions & 4 deletions kDriveTests/kDriveCore/Drive/ITDrive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ import XCTest
final class ITDrive: XCTestCase {
// MARK: - Parsing

var decoder: JSONDecoder {
let decoder = JSONDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase
return decoder
}

private func freeDriveJson() -> Data? {
JSONHelper.data(forResource: "free_drive", withExtension: "json")
}
Expand All @@ -39,8 +45,6 @@ final class ITDrive: XCTestCase {
return
}

let decoder = JSONDecoder()

// WHEN
do {
let drive = try decoder.decode(Drive.self, from: driveData)
Expand All @@ -61,8 +65,6 @@ final class ITDrive: XCTestCase {
return
}

let decoder = JSONDecoder()

// WHEN
do {
let drive = try decoder.decode(Drive.self, from: driveData)
Expand Down
Loading
Loading