Your project is now on a source control system. This means that managing several versions of your software, monitoring changes, and integrating corrections or new features is much simpler now.
Why not also take advantage of continuous integration?
Starting with 4D v19, you can launch the compilation of your project with a command. As a result, you now have all the building blocks needed to automate your integration chain.
This blog post will give you an example of automation with the GitHub manager and GitHub Actions.
What is a GitHub Action?
GitHub actions allow you to automate tasks. They are triggered by events such as a code submission.
Why GitHub Actions?
Workflow automation is a requirement in today’s software development world. Development teams use CI/CD servers to automate the continuous integration and deployment (CI/CD) processes in their software life cycle.
GitHub Actions allow users to build, test, and deliver their code directly from GitHub without using an external server such as Jenkins or TeamCity. GitHub hosts virtual machines on Linux, Windows, and macOS operating systems.
How to use GitHub Actions?
You need to create a workflow. A workflow is an automated procedure that you add to your repository. In the action tab, you can pick one from the catalog of workflows or create your own.
In this example, we use the “simple workflow” proposed by Github:
This created a script in the “.github/workflows” folder of our repository. In this script, you can define:
- the trigger event: on push/pull/schedule
- the OS of the virtual machine: runs-on
For more details on syntaxes and possibilities, take a look at the GitHub documentation.
Next, we change the README.md file in our repository, which triggers the workflow. In the action tab, the modification is visible, the workflow is in a queue:
Voilà! The script has been executed.
We now have access to the OS information, and the virtual machine used, checking if it corresponds to the configuration we requested.
All the logs of our script are now visible:
Now that we have seen how to create and set up GitHub actions, here is a workflow created by Eric Marchand.
Eric is one of our 4D for iOS team developers. He has developed several git actions for his own use, used on a GitLab server for our private repositories and on GitHub for the public one.
Here is an example of how to compile a project and publish the release on GitHub:
First, we have a 4D project with shared code that compiles other projects passed in parameters during the launch (with a bash script on macOS runner). This project converts the compilation errors to GitHub log format. It is stored on a Github repository containing actions such as compiling, generating a release, etc. These actions can then be used in any other project.
Second, to run the project and thus call an action such as compiling, we need to run a 4D application. A 4D application is available for download on a server. It needs to be installed and run on GitHub servers. You’ll need to add the SERVER_URL key in your repository’s “Action Secret” parameter for each project.
Finally, you create workflows triggered by a pull request in your projects, which calls the “build” workflow of your “centralized action” repository.
Find the repository with the base and the different workflows and an example of its integration in a project.
Let us know what you think by joining the conversation on the 4D Forum!