Prerequisites: An AL-Go repository setup using one of the scenarios
When running the CI/CD workflow, the build job is by far the most time-consuming job. By adding your own GitHub Runner, which can cache the generic image, the build image and also the artifacts, the time for running the build job can become much faster.
GitHub runners can be registered for an organization (accessible for all repositories in the organization) or for a single repository.
- Navigate to https://github.com/organizations/{organization}/settings/actions/runners/new to create a self-hosted runner for your organization. Use https://github.com/{organization}/{repository}/settings/actions/runners to create a self-hosted runner for a single repository.
- Now, you can either Use the Azure VM Template to create your self-hosted runner or you can Create your self-hosted runner manually
- To create an Azure VM hosting x self-hosted runners, open a new tab and navigate to https://aka.ms/getbuildagent.
- Enter the Resource Group name, Region, VM Name, Admin Password of your choice.
- Enter the number of agents you want to create on the VM.
- Grab the token, the organization Url, and the Agent Url from the Create Self-Hosted runner page, and specify self-hosted in labels.
- Select Review and Create and then review the deployment and choose Create.
- Wait for the Azure VM creation to finalize, navigate back to see that the Runners have been registered and are ready to use.
- Go to Allow your repository access to your runners to continue the configuration.
- To create a self-hosted runner manually, choose Windows under Runner Image and x64 in architecture and follow the description on how to create a self-hosted runner manually
- Make sure that the following software is installed on the computer (the suggestion in parentheses explains the mechanism used in https://aka.ms/getbuildagent)
- Docker (getbuildagent use this script to install or update Docker Engine on the Azure VM)
- The AZ PowerShell module (getbuildagent use
Install-Module az -force
) - GIT (getbuildagent use
choco install git --force --params "/NoAutoCrlf"
after installing choco usinghttps://chocolatey.org/install.ps1
)) - 7zip (getbuildagent use
choco install 7zip
) - GitHub CLI (getbuildagent use
choco install gh
) - PowerShell 7.4.1 (getbuildagent use
choco install pwsh -y
) - Microsoft Visual C++ Redistributable for Visual Studio 2015-2022 14.36.32532 (getbuildagent use
choco install vcredist140 -y
) - Microsoft .NET (getbuildagent use
choco install dotnet -y
) - Microsoft .NET SDK (getbuildagent use
choco install dotnet-sdk -y
) - nuget.org added as dotnet nuget source (getbuildagent use
dotnet nuget add source https://api.nuget.org/v3/index.json --name nuget.org
)
Note
If the Deploy Reference Documentation job results in an error like this, then you need to check your GIT installation as described in the issue.
- On the list of Runners on GitHub, choose the runner group Default and allow public repositories if your repository is public.
- Now navigate to your repo settings file (.github/AL-Go-Settings.json) and set gitHubRunner to self-hosted.
- Note that you can use other tags than self-hosted to identify special runners for GitHub jobs, or you can set gitHubRunner to "self-hosted, Windows" to ensure that a Windows version is selected if you have self-hosted linux runners as well.
- Save and inspect your workflows performance increase on the second run.
- Inspect that one of the runners pick up the workflow.
- Clicking the runner reveals that the job it is running.
You might have noticed that there are two settings in the repository settings file controlling which runners are selected, GitHubRunner and Runs-On.
"runs-on"
is used for all jobs that don’t build/test your app, such as jobs that don’t require a lot of machine power or a docker container. AL-Go for GitHub supports using ubuntu-latest for runs-on, which is faster and cheaper than windows-latest (which is the default). Many jobs run in parallel using these runners, and we do not recommend using self-hosted runners for this type of job.
"githubRunner"
is used for build/test jobs, which require more memory and a container.
- Running 6 CI/CD workflows simultanously, causes 1 workflow to wait as I only had 5 runners.
- Connecting to the runner VM and looking at utilization indicates that the VM is pretty busy and probably over-allocated when starting 5+ builds at the same time. Every build was ~50% slower than when running only 1 build.
- Decreasing the number of runners to 4 causes the build performance to be similar to when running just 1 build.
- Turning off real-time protection on the self-hosted runner makes builds go ~25% faster.