| 1 |
# Azure Pipelines Continuous Integration |
| 2 |
|
| 3 |
rdma-core uses Azure Pipelines to run a variety of compile tests on every pull |
| 4 |
request. These tests are intended to run through a variety of distribution |
| 5 |
configurations with the goal to have rdma-core build and work on a wide range |
| 6 |
of distributions. |
| 7 |
|
| 8 |
The system consists of several components: |
| 9 |
- An Azure Container Registry |
| 10 |
- The script buildlib/cbuild to produce the container images representing the |
| 11 |
test scenarios |
| 12 |
- The instructions in buildlib/azure-pipelines.yml and related support scripts |
| 13 |
- An Azure Pipelines account linked to the rdma-core GitHub |
| 14 |
- A GitHub Check |
| 15 |
|
| 16 |
Things are arranged so that the cbuild script can run the same commands in the |
| 17 |
same containers on the local docker system, it does not rely on any special or |
| 18 |
unique capabilities of Azure Pipelines. |
| 19 |
|
| 20 |
# The Containers |
| 21 |
|
| 22 |
Containers are built with the cbuild script. Internally it generates a |
| 23 |
Dockerfile and builds a docker container. |
| 24 |
|
| 25 |
```sh |
| 26 |
$ buildlib/cbuild build-images centos7 |
| 27 |
``` |
| 28 |
|
| 29 |
cbuild has definitions for a wide range of platforms that are interesting to test. |
| 30 |
|
| 31 |
## Uploading Containers |
| 32 |
|
| 33 |
Containers that are used by Azure Pipelines are prefixed with |
| 34 |
ucfconsort.azurecr.io/rdma-core/ to indicate they are served from that docker |
| 35 |
registry (which is implemented as a Azure Container Registry service). |
| 36 |
|
| 37 |
Once built the container should be uploaded with: |
| 38 |
|
| 39 |
```sh |
| 40 |
# Needed onetime |
| 41 |
$ az login |
| 42 |
|
| 43 |
$ sudo az acr login --name ucfconsort |
| 44 |
$ sudo docker push ucfconsort.azurecr.io/rdma-core/centos7:latest |
| 45 |
``` |
| 46 |
|
| 47 |
The user will need to be authorized to access the private registry. |
| 48 |
|
| 49 |
## Testing containers locally |
| 50 |
|
| 51 |
cbuild has several modes for doing local testing on the container. |
| 52 |
|
| 53 |
The fastest is to use 'cbuild make' as a replacement for Ninja. It will run |
| 54 |
cmake and ninja commands inside the container, but using the local source |
| 55 |
tree unmodified. This is useful to test and resolve compilation problems. |
| 56 |
|
| 57 |
```sh |
| 58 |
$ buildlib/cbuild make centos7 |
| 59 |
``` |
| 60 |
|
| 61 |
Using 'make --run-shell' will perform all container setup but instead of |
| 62 |
running Ninja it will open a bash shell inside the same container |
| 63 |
environment. This is useful to test and debug the container contents. |
| 64 |
|
| 65 |
Package builds can be tested using 'cbuild pkg'. This automatically generates |
| 66 |
a source .tar.gz and then runs rpmbuild/etc within the container. This is |
| 67 |
useful for testing the package building scripts. Note that any changes must be |
| 68 |
checked in or they will not be included. |
| 69 |
|
| 70 |
package builds are some of the tests that Azure Pipelines runs. |
| 71 |
|
| 72 |
# Azure Pipelines |
| 73 |
|
| 74 |
The actions are controlled by the content of buildlib/azure-pipelines.yml. The |
| 75 |
process is fairly straightforward and consists of both running distribution |
| 76 |
package builds and a series of different compilers and analysis checks. |
| 77 |
|
| 78 |
The compiler checks are run in a special 'azure-pipelines' container that has |
| 79 |
several compilers, ARM64 cross compilation, and other things. |
| 80 |
|
| 81 |
cbuild is able to run an emulation of the pipelines commands using |
| 82 |
'buildlib/cbuild pkg azp' |
| 83 |
|
| 84 |
## Azure Pipelines Security |
| 85 |
|
| 86 |
Microsoft has a strange security model - by default they do not send any login |
| 87 |
secrets to the VM if the VM is triggered from a GitHub Pull Request. This is |
| 88 |
required as the VM runs code from the PR, and a hostile PR could ex-filtrate |
| 89 |
the secret data. |
| 90 |
|
| 91 |
However, since fetching the containers requires a security token it means PR |
| 92 |
cannot get the container, and are basically entirely useless. The only option |
| 93 |
Azure Pipelines has is to inject *all* security tokens, including the GitHub |
| 94 |
token, which is madness. |
| 95 |
|
| 96 |
The compromise is that when a non-team member user proposes a Pull Request a |
| 97 |
team member must review it and add "/azp run" to the comments to ack that the |
| 98 |
PR content is not hostile. |
| 99 |
|
| 100 |
See |
| 101 |
|
| 102 |
https://developercommunity.visualstudio.com/content/idea/392281/granular-permissions-on-secrets-for-github-fork-pu.html |