|
| 1 | +This note describes the setup of our GitHub/GitLab integration. The main |
| 2 | +AMReX repo is hosted at https://github.com/AMReX-Codes/amrex, with a mirror |
| 3 | +at https://gitlab.spack.io/amrex/amrex. The GitLab mirror runs CI tests on |
| 4 | +runners hosted at |
| 5 | +https://systems.nic.uoregon.edu/internal-wiki/index.php?title=Category:Servers. We |
| 6 | +run three types of tests: nightly tests using the development branch, tests |
| 7 | +triggerd when new commits are pushed to the GitLab mirror (either through |
| 8 | +GitLab's regular pulling of the latest development branch from GitHub or by |
| 9 | +the developers directly), and tests triggered by a special comment from |
| 10 | +maintainers. |
| 11 | + |
| 12 | +Instructions for creating a pull mirror can be found at |
| 13 | +https://docs.gitlab.com/user/project/repository/mirror/pull/. You can choose |
| 14 | +to pull selected branches or all branches. For AMReX, this choice does not |
| 15 | +matter since we only have one active branch. However, for repoositories with |
| 16 | +many active branches, pulling all branches may trigger CI jobs on every |
| 17 | +activity. |
| 18 | + |
| 19 | +Instructions for creating schedules pipelines can be found at |
| 20 | +https://docs.gitlab.com/ci/pipelines/schedules/. By default, GitLab uses |
| 21 | +`.gitlab-ci.yml` at the repository root for pipeline configurations, but |
| 22 | +this can be changed. AMReX's GitLab CI file is in the `.gitlab` |
| 23 | +directory. To change the configuration file location, select `Settings -> |
| 24 | +CI/CD -> General pipelines` and update `CI/CD configuration file`. |
| 25 | + |
| 26 | +CI/CD jobs triggered by push require no special setup. They can also be |
| 27 | +disabled. |
| 28 | + |
| 29 | +For GitHub PR triggered jobs, we choose not to run automatically. Instead |
| 30 | +they need to be triggered by a `/run-hpsf-gitlab-ci` comment from authorized |
| 31 | +maintainers, which starts the `run-hpsf-gitlab-ci` workflow defined in |
| 32 | +`.github/workflows/trigger-hpsf-gitlab-ci.yml`. This workflow uses GitLab's |
| 33 | +REST API to start a pipeline job on GitLab. The PR comment triggered |
| 34 | +pipeline job uses the same configuration file shared with the scheduled |
| 35 | +pipeline: `.gitlab/hpsf-gitlab-ci.yml`. The PR comment triggered job pulls |
| 36 | +the PR branch from GitHub first before running tests. For this approach to |
| 37 | +work, we store a pipeline trigger (obtained from GitLab's `Settings -> CI/CD |
| 38 | +-> Pipeline trigger tokens`) as a secret at GitHub's `Settings -> Secrets |
| 39 | +and variables -> Actions -> Repository secrets`. The GitHub workflow waits |
| 40 | +for the result of the GitLab pipeline result and posts the final status and |
| 41 | +a link to the result as a comment. |
| 42 | + |
| 43 | +There is one complication with this approach. The GitHub PR triggered |
| 44 | +pipeline appears on GitLab under the title of the latest commit of the |
| 45 | +default branch (i.e., development), which can be confusing. To address this, |
| 46 | +we add a step in the GitHub workflow to change the GitLab pipeline's name to |
| 47 | +the PR's title. This step requires an API token, which diffs from the |
| 48 | +pipeline trigger token. A project API token can be created from the |
| 49 | +project's `Settings -> Access tokens`. It needs `api` scopes and the |
| 50 | +`Maintainer` role. The token will expire in one year. After creating a key, |
| 51 | +you must copy and store it on GitHub before leaving the page, as it will |
| 52 | +become invisible afterward. |
0 commit comments