IT HAS NO OFFICIAL APPROVAL FROM THE CORE DEVELOPERS!
The code: https://gitlab.com/PrzemoF/FreeCAD/-/tree/gitlab-v3/ci
Merged into master: https://gitlab.com/freecad/FreeCAD/-/tree/master/ci
Remote builds managed by gitlab.com. Should replace travis-ci for pull requests.
The system is being tested. If you want to help - let me know.
An example of build and test: https://gitlab.com/PrzemoF/FreeCAD/-/pi ... /345028404
WHAT WORKS:
1. Remote control and build with docker images on external hardware
2. Local debugging of the builds/tests with "docker run -it freecadci/runner /bin/bash"
3. FreeCAD testing
4. ccache - on my laptop average build & test + downloads/uploads takes 7-8 minutes
5. Semi automated migration of open pull requests from github - tested on 100+ pull requests
WHAT DOESN'T WORK:
1. Please let me know if you find something
WHAT NEEDS DISCUSSION:
1. To my understanding of the system using non-trusted builders is safe as long as we do build & test only. That opens opportunity to ask FreeCAD users to donate time on their machines. The details need to be tested. Obviously if we go into Continuous Deployment the builds have to be from a trusted builder. With non-trusted builds there is a slim possibility of injecting code, but the produced binary are only available as job artifacts, so chances of using FreeCAD as attack vector are close to zero.
TODO:
0. Explore: https://gitlab.com/inkscape/inkscape/bl ... lab-ci.yml <- Inkscape has windows and macos builds!
They use appveyor, I'm no specialist - help required to get windows/macos builds
1. ccache shared storage (low priority)
https://stackoverflow.com/questions/457 ... cker-cloud
More options:
https://cinaq.com/blog/2020/05/10/speed ... ubernetes/
Example:
https://gould.cx/ted/blog/2017/06/10/cc ... Gitlab-CI/
2. How to mark PR to skip the CI? E.g. for typos in documentation
3. Ask gitlab for free licence for an open source project
4. Transferring open PRs from github to gitlab, the dirty way. Beware of server request limits! The cods is proof of concept, but works.
Code: Select all
#!/bin/bash
# Uncomment this section to get PRs from github. Use your user name,
#curl -u PrzemoF "https://api.github.com/repos/FreeCAD/FreeCAD/pulls?state=open&page=1&per_page=100" > page_1
#cat page_1 | grep '"html_url": "https://github.com/FreeCAD/FreeCAD/pull/' > page_1_filtered
#curl -u PrzemoF "https://api.github.com/repos/FreeCAD/FreeCAD/pulls?state=open&page=2&per_page=100" > page_2
#cat page_2 | grep '"html_url": "https://github.com/FreeCAD/FreeCAD/pull/' > page_2_filtered
#touch prs
#cat page_1_filtered >> prs
#cat page_2_filtered >> prs
# !!!!!!!! Edit produced prs file to convert links to PR numbers only, one number per line. Save as pr_numbers
# That section pull from github, creates local branch and pushes to gitlab
# In case pull request doesn't rebase on top of gitlab-v3 the branch gets renamed for future investigation
# the pull-requests-from-github-short should contain pull request drawing numbers, one per line
while IFS= read -r pr_number; do
printf '%s\n' "$line"
git fetch origin pull/"$pr_number"/head:gh-pr-"$pr_number"
git checkout gh-pr-"$pr_number"
if ! git rebase master ; then <-- edit to match the latest branch with gitlab-CI code
git rebase --abort
git branch -m gh-pr-$pr_number-rebase-aborted
git checkout master
else
git push gl <-- edit to match your repo, I call gitlab gl. Use --force if doing refresh of existing branches.
fi
done < pr_numbers
#DANGER ZONE - mass remove all branches with gh-pr
#git branch | grep 'gh-pr-' | xargs git branch -D
https://docs.docker.com/docker-hub/builds/
6. [optimisation] when test is executed it uses only 1 core (FreeCAD dictates it). Can another build be triggered in the same time?
Some links:
What is Dockerfile, docker image and docker container:
https://blog.iron.io/what-is-a-docker-image/
gitlab CI explained:
https://www.lambdatest.com/blog/automat ... -selenium/
What is docker volume:
https://docs.docker.com/storage/volumes/
Compliling FreeCAD on Docker
https://wiki.freecadweb.org/Compile_on_Docker
docker image for gitlab remote CI:
https://hub.docker.com/repository/docke ... dci/runner
The docker container can be build with:
Code: Select all
docker build -t yourusername/repository-name .
Registering a runner:
https://docs.gitlab.com/runner/register/
Run your CI/CD jobs in Docker containers
https://docs.gitlab.com/ee/ci/docker/us ... containers
Best practices for building docker images with GitLab CI
https://blog.callr.tech/building-docker ... practices/
Info about making docker image as workaround for missing apt-add-repository:
https://stackoverflow.com/questions/473 ... egrationci
How to make docker image:
https://cylab.be/blog/8/using-custom-do ... ith-gitlab
Best practices for docker images:
https://blog.callr.tech/building-docker ... practices/
(FEDORA) Selinux can cause access problems manifesting with "ERROR: Job failed (system failure): Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock:". The workaround:
https://github.com/dpw/selinux-dockersock
The same error might be caused by this:
https://stackoverflow.com/questions/526 ... -run-docke
Running docker build/run might not work without sudo or adding user to "docker" group:
https://www.tutorialspoint.com/running- ... -root-user
Checking logs on runner on local machine:
Code: Select all
docker logs gitlab-runne
Code: Select all
sudo usermod -aG docker my-uesr-name
Debugging:
- downloading job artifacts allows local testing of the build
- run interactive session in docker container to debug problems:
Code: Select all
docker run -it freecadci/runner /bin/bash