-
Notifications
You must be signed in to change notification settings - Fork 4
Development
We using SPM (Swift Package Manager) in all modules.
To open the project, you can use Sparkans or just double click on the Package.swift file.
The only exception is on the spark-ios repository. You need to run xcodegen to generate the xcodeproj and launch the project.
Note 1 : Unfortunately there is no header management in SPM project. You need to add it by yourself.
//
// ___FileName___.swift
// Spark___ModuleName___
//
// Created by ___YourName___ on ___CurrentDate___.
// Copyright © 2024 Adevinta. All rights reserved.
//
Note 2 : It is not possible to have two same projects open at the same time. For example, if you have the spark-ios-theming open and you to open the spark-ios-component-badge (and on the Package.swift, use the local spark-ios-theming dependencies), the project will not compile. You need to close both projects then reopen the spark-ios-component-badge.
An Xcode project that injects one or more SPM should automatically update the version of all SPM dependencies (depends of the defined rules).
Unfortunately, sometime, it doesn't work. In this case you can go :
- On Xcode, go to File on top menu -> Packages -> Update to Latest Package Version.
- You can also try the two others buttons: Reset Package Caches and Resolve Package Versions.
If it still not working or you have this kind of message:
Revision 082ff44996679d28a63bb620ef21753950b9c2c for spark-ios-component-radio-button remoteSourceControl https:// github.com/adevinta/spark-ios-component-radio-button.git version 0.1.0 does not match previously recorded value
caaffc07c552d126f02243c8bcOa260a20da8547
You can run theses two command lines
rm -rf ~/Library/Caches/org.swift.swiftpm
rm -rf ~/Library/org.swift.swiftpm
Spark using sourcery to generate mock and the generated mock is never push on github.
The complexity with a multi-repo solution is : if a module (A) need to have access to the mock from the module (B), sourcery must be run on the module A and B. But if the module B is an external dependency, the sourcery should be executed from the derived data folder.
Solution : run sourcery with Sparkans ! It will automatically run sourcery for the current component and also on all external dependencies. After run sourcery with Sparkans, you must reload the xcode project and clean it.
Spark using swiftlint to enforce Swift style and conventions.
You can run swiftlint with Sparkans application.
Please, run the swiftlint before push your code. If some errors are found in the CI and not in local, try to update the swiftlint version on your mac.
brew upgrade swiftlint
Spark using xcodegen to generate the xcodeproj for two repositories :
- spark-ios
- spark-ios-configuration.
You can run xcodegen with Sparkans application.
- Create a ticket on the board.
- Make your modification on the module and on spark-ios (optional).
- code
- unit tests
- snapshot testings
- Create a Pull Request with the ticket number in the module and on spark-ios (optional).
- On your ticket, on the right panel, add development branch with the PullRequest link.
- Check if the CI succeed: linter, build and tests on the module. (note 1.1)
- Move the ticket on Ready for review column.
- When the Pull Request is Approved, you can generate the demo app so that someone tests your modification. Check the CI / Packages section on this page to run the action.
- Move the ticket on the Testing column.
- If the tester validates the modification, you can merge your modification.
- Move the ticket to Ready for Production.
- Relaunch the CI on spark-ios if it previously failed and merge the Pull Request.
- Create the new release of you repository.
- Move the ticket on the Done column.
Note 1.1 : The CI on spark-ios will failed because it uses the main branch of all modules. When your module code will be approved, testing and merged, you will be able to restart the CI on spark-ios.
You must use the Sparkans mac application to create a new component repository.
You can read more information about it in the ReadMe page.
To add a new component in the spark project you need to :
- Close all your spark projects open on Xcode.
- Run xcodegen from Sparkans or with command line.
- Open the Package.swift file and add the new module. You must respect the same syntax as the other dependencies. Please respect the alphabetic order.
.package(
url: "https://github.com/adevinta/spark-ios-component-text-field.git",
// path: "../spark-ios-component-text-field"
/*version*/ "0.0.1"..."999.999.999"
),
- Import the component in the Core.swift file. Please use the @_exported annotation.
@_exported import SparkTextField
- Add the new component info on the README.md.
- You can now add your demo code for the component on the .Demo folder.
- Automatic Actions :
On SPM repositories, there is three possible Github Action. Two are automatic and launched when you create a Pull Request:
- linter / linter : run swiftlint and check if there is no syntax error.
- buildAndTest / Build : check if the build of your package (example: SparkButton-Packages) compile or not.
- buildAndTest / Unit and Snapshot Test : check if the build of your package (example: SparkButton-Packages) compile or not. If the tests failed, you can download the xcresult
- Manual Actions
The last action is build-demo-app. It is used to build the demo app with your current package modification.
To launch it, you just need to add a comment on the PullRequest that begins by
/buildDemo
. If the updated code in the demo app isn't in the main branch, you must add the name of the spark-io branch that contains your modification like this :/buildDemo >myBranchInSparkIos
.If the action succeed, a github-actions bot will add a comment on the Pull Request that contains the link of the DemoApp.
See example here.
On spark-ios repositories, there is two Github Action. They are automatically launched when you create a Pull Request:
- linter / linter : run swiftlint and check if there is no syntax error.
- buildDemo / Build : check if the build of the demo compile or not.
If you want to see more details about the error, warning, succeed, ... :
- Open the Github repository page.
- Tap on Actions
- Select the line associated with your Pull Request.
- The expected information are in the the Annotation part (warning or error from the linter, xcresult, ...).
Because there is many repositories, some configurations are optimized to avoid duplicate code.
Each packages have a .sourcery.yml
file but the templates come from the spark-ios-common local repository.
The stencil files are located on the .sourcery/
folder in spark-ios-common repository.
If you want to add/update a template, you just need to update the related stencil in spark-ios-common repository.
Each packages have a .swiftlint.yml
file but it contains only a parent_config
link (except spark-ios-common).
The parent config is located on the spark-ios-common repository.
If you want to modify a rule, you just need to update the .swiftlint.yml
in spark-ios-common repository.
Each packages have two action files : action.yml
and buildDemoApp.yml
in .github/workflows folder. Theses yml files contains only links to the jobs located on spark-ios-common repository.
The jobs config are located on the spark-ios-common repository.
If you want to modify a job, you just need to update the XYZ.yml
file in .github/workflows in spark-ios-common repository.
Note : If you create a Pull Request, then update a job on spark-ios-common, you must close and recreate the Pull Request because when an action is launched one time in Github, even if the action is updated/removed, Github keep in memory this action and will reuse it.