In the world of software development, a new concept has appeared in recent years called “Continuous Integration.” The definition we see or hear everywhere is :
“CI is a process that automates the compilation, testing, and delivery of an application on a regular and frequent basis.”
Having understood this definition, which expresses an interesting and promising process, what do I need to do to implement it in 4D? If you search the Internet, you’ll find that there are many CI tools and frameworks available.
However, there are several prerequisites before using these CI tools.
Step 1: Convert a 4D application into a project
To implement CI in 4D, you first need to convert your 4D application into a project. This involves migrating to project mode if your application is currently in binary mode. During conversion, the “.4DB” binary file is split into several large text files, which can then be placed on source control.
You can find a whole blog series explaining the concepts of project mode:
- Project databases: From binary to text-based
- Project databases: Architecture
- Project databases: Post conversion
Or follow these 4D training:
Step 2: Utilize a source control system
Managing your code with a version control system like Git is essential for successful CI implementation.
As a first step, if you want to test and experiment with a source control system, you can try GitHub. Simply create an account on GitHub, and you can create your own private or public repository free of charge. Then, depending on your needs, you can invest in a source control server like Git Lab hosted by your organization.
To get started with Git and 4D, explore these blog posts:
- How to share your 4D code via GitHub
- Project databases: Git. Commit. Pull. Push & more
- gitignore and 4D: a useful feature for Git users
- Saving project source code without tokens
A very detailed guide explains the different ways you can work with 4D and source control, either as part of a team or on your own:
We also recommend checking out the keynote and breakout session from 4D Summit 2020:
Depending on your chosen source control system, you can easily find training courses adapted to your preferred tool.
Step 3: Compile or Build applications without an interface
A method or function must be designed to compile and build your application without an interface and without user intervention. You can write your methods using the Compile project or Build application commands.
Alternatively, you can simply use the Build4D component. This component lets you build a compiled structure, a component, a standalone application, or a Client/Server application. The component and its source code are available on GitHub under the MIT license. This means you can use it for free, make a fork on GitHub to modify it as you wish if you have particular needs, and use it on your installations without constraint.
Here’s a series of blog posts on the Build4D component:
- Build your Compiled Structure or Component with Build4D
- Create a standalone application with the Build4D component
- Create a Client/Server Application with the Build4D tool
Step 4: use the command line to execute
Once you’ve written the script to compile and build the application, all you have to do is run the script from the command line.
You can pass several parameters via the command line, such as the path to 4D, the project, etc. You can also pass information specific to your code with the “–user-param” parameter.
Valuable resources for command line execution:
And for logging actions or errors:
Step 5: Automate processes for each commit
The final step is to launch your script for each commit on the source control server. If you’ve chosen Git as your source control, you can simply use the Git action. You can use the classic 4D Developer Edition or the new “tool4D” tool to automate your script.
tool4D is a specialized tool, designed for CLI execution in headless mode and optimized for automating CI processes. tool4D runs automatically in headless mode. Some features are unavailable, such as an application server, Web server, SQL server, and 4D Write Pro and 4D View Pro components. No license is required to run tool4D, so you can easily automate compilation or build without having to install a license in the virtual machine.
To learn more about utilizing Git actions and tool4D, refer to these blog posts:
- How to take advantage of GitHub actions with 4D
- A Tool for 4D Code Execution in CLI
- tool4D documentation
And follow this 4D training:
To resume
In conclusion, implementing CI with 4D can significantly enhance your development workflow. Begin by converting to the project. Then, familiarize yourself with the concepts of a version control system. Write the scripts to compile and build your application. Finally, automate the process with each commit.
You can see all these steps in detail in this 90-minute training course available on 4D.
By following these steps, you’re ready to dive into the exciting world of continuous integration!