| 1 | Information for external library / Rocq plugin authors |
| 2 | ----------------------------------------------------- |
| 3 | |
| 4 | You are encouraged to consider submitting your project for addition to |
| 5 | Rocq's CI. This means that: |
| 6 | |
| 7 | - Any time that a proposed change is breaking your project, Rocq |
| 8 | developers and contributors will send you patches to adapt it |
| 9 | (systematically only for plugins) or |
| 10 | will explain how to adapt it and work with you to ensure that you |
| 11 | manage to do it. |
| 12 | |
| 13 | On the condition that: |
| 14 | |
| 15 | - At the time of the submission, your project works with Rocq's |
| 16 | `master` branch. |
| 17 | |
| 18 | - Your project is publicly available in a git repository and we can easily |
| 19 | send patches to you (e.g. through pull / merge requests). |
| 20 | |
| 21 | - You react in a timely manner to adapt to the few requested changes |
| 22 | required by Rocq developers or to integrate their patches (in a 7 days timeframe, |
| 23 | extensions can be requested for exceptionally complex changes). |
| 24 | |
| 25 | - You do not push, to the branch that we test, commits that haven't been |
| 26 | first tested to compile with the corresponding branch of Rocq. |
| 27 | |
| 28 | For that, we recommend setting a CI system for you project, see for instance |
| 29 | [supported CI images for Rocq](#supported-ci-images-for-rocq) below. |
| 30 | |
| 31 | - You maintain a reasonable build time for your project, or you provide |
| 32 | a "lite" target that we can use. |
| 33 | |
| 34 | - You keep points of contact up to date. |
| 35 | |
| 36 | In case you forget to comply with these last four conditions, we would reach |
| 37 | out to you and give you a 30-day grace period during which your project |
| 38 | would be moved into our "allow failure" category. At the end of the grace |
| 39 | period, in the absence of progress, the project would be removed from our |
| 40 | CI. |
| 41 | |
| 42 | Due to a lack of computing resources, submitted libraries which do not |
| 43 | clearly expand what Rocq's CI covers might not be integrated. You are |
| 44 | encouraged to discuss the addition of your project on [Rocq's |
| 45 | Zulip](https://coq.zulipchat.com/). You are also encouraged to test |
| 46 | your project with Rocq master and report any issues you find (not just |
| 47 | bugs) even if it is not in Rocq's CI; if your project repeatedly finds |
| 48 | issues they will be evidence that it would expand the CI's coverage. |
| 49 | |
| 50 | There is no such requirement for plugins: developers may reduce the |
| 51 | cost of working with Rocq's unstable OCaml API by adding |
| 52 | their plugin to Rocq's CI and getting it fixed when the API changes (as long |
| 53 | as fixing the plugin doesn't put an undue burden on Rocq developers). |
| 54 | |
| 55 | ### Timely merging of overlays |
| 56 | |
| 57 | A pitfall of the current CI setup is that when a breaking change is |
| 58 | merged in Rocq upstream, CI for your contrib will be broken until you |
| 59 | merge the corresponding pull request with the fix for your contribution. |
| 60 | |
| 61 | As of today, you have to worry about synchronizing with Rocq upstream |
| 62 | every once in a while; a workaround is to give merge permissions to |
| 63 | someone from the Rocq team as to help with these kind of merges. |
| 64 | |
| 65 | ### OCaml and plugin-specific considerations |
| 66 | |
| 67 | Projects that link against Rocq's OCaml API [most of them are known |
| 68 | as "plugins"] do have some special requirements: |
| 69 | |
| 70 | - Rocq's OCaml API is not stable. We hope to improve this in the future |
| 71 | but as of today you should expect to have to merge a fair amount of |
| 72 | "overlays", usually in the form of Pull Requests from Rocq developers |
| 73 | in order to keep your plugin compatible with Rocq master. |
| 74 | |
| 75 | In order to alleviate the load, you can delegate the merging of such |
| 76 | compatibility pull requests to Rocq developers themselves, by |
| 77 | granting access to the plugin repository or by using `bots` such as |
| 78 | [Bors](https://github.com/apps/bors) that allow for automatic |
| 79 | management of Pull Requests. |
| 80 | |
| 81 | ### Add your project by submitting a pull request |
| 82 | |
| 83 | Add a new `ci-mydev.sh` script to [`dev/ci/scripts`](scripts); set the corresponding |
| 84 | variables in [`ci-basic-overlay.sh`](ci-basic-overlay.sh); add the |
| 85 | corresponding target to [`Makefile.ci`](../../Makefile.ci) and a new job to |
| 86 | [`.gitlab-ci.yml`](../../.gitlab-ci.yml) so that this new target is run. |
| 87 | Have a look at [#17241](https://github.com/rocq-prover/rocq/pull/17241/files) for an |
| 88 | example. **Do not hesitate to submit an incomplete pull request if you need |
| 89 | help to finish it.** |
| 90 | |
| 91 | Some important points: |
| 92 | |
| 93 | - Mention one or a few points of contact in |
| 94 | [`ci-basic-overlay.sh`](ci-basic-overlay.sh). |
| 95 | |
| 96 | - Let `$job` be the name of the new job as used for the name of |
| 97 | the added script file `dev/ci/scripts/ci-$job.sh`. Then the added target |
| 98 | in `Makefile.ci` must be named `ci-$job` and the added job in |
| 99 | `.gitlab-ci.yml` must be named `library:$job` or |
| 100 | `plugin:$job`. `$job` must be a valid shell variable name, |
| 101 | typically this means replacing dashs (`-`) with underscores (`_`). |
| 102 | |
| 103 | - Let `$project` be the name of your project as used for the first |
| 104 | argument to `project` in `ci-basic-overlay.sh`. Usually this is the |
| 105 | same as `$job` in the above bullet. It must also be a valid |
| 106 | shell variable name. In some cases a script will handle multiple |
| 107 | source repositories and so will need multiple `$project`, see for |
| 108 | instance script `verdi_raft`. |
| 109 | |
| 110 | - If you wish to run a test suite for your project which takes |
| 111 | non-negligible time, it may be useful to run the test suite in a |
| 112 | separate `Makefile.ci` target and GitLab job, using a separate shell |
| 113 | script. In terms of the above bullet points this means a `$project` |
| 114 | used in multiple `$job`s. See for instance `mathcomp` and `mathcomp_test`. |
| 115 | |
| 116 | - When declaring the job in `.gitlab-ci.yml` you must choose the opam |
| 117 | switch by using `extends: .ci-template` or `extends: .ci-template-flambda`. |
| 118 | |
| 119 | The first one uses the minimum version of OCaml supported by Rocq. |
| 120 | The second one uses the highest version of OCaml supported by Rocq, |
| 121 | with flambda enabled (currently it actually uses OCaml 4.14.1 as 5.0 |
| 122 | has significant performance issues). See also the corresponding |
| 123 | [`Dockerfiles`](docker/) to find out what |
| 124 | specific packages are available in each switch. |
| 125 | |
| 126 | If your job depends on other jobs, you must use the same opam |
| 127 | switch. If you wish to depend on jobs currently declared in separate |
| 128 | switches, please open a draft pull request and the Rocq developers |
| 129 | will decide which jobs should change switches. If you need an |
| 130 | exception to this rule for some other reason, please discuss with |
| 131 | the Rocq developers. |
| 132 | |
| 133 | - Job dependencies are declared in 2 places: `Makefile.ci` using the |
| 134 | usual Makefile syntax, and `.gitlab-ci.yml` using `needs`. If you |
| 135 | only depend on Rocq itself the implicit `needs` from the template |
| 136 | suffices. Otherwise the `needs` list must include all transitive |
| 137 | dependencies. See for instance the declaration for |
| 138 | `library:ci-analysis`. |
| 139 | |
| 140 | - If you depend on more than Rocq itself you must specify the `stage`: |
| 141 | `build-2` if all your dependencies depend only on Rocq itself, |
| 142 | otherwise `build-3+` (the number is the max depth of the dependency |
| 143 | chain, with Rocq itself at 0 and the default from the template at 1). |
| 144 | |
| 145 | - If needed you can disable native compilation by doing `export |
| 146 | COQEXTRAFLAGS='-native-compiler no'` before the build commands in |
| 147 | the script file. If any of your dependencies disable native |
| 148 | compilation you must do the same. |
| 149 | |
| 150 | You may also be interested in having your project tested in our |
| 151 | performance benchmark. Currently this is done by providing a `.dev` OPAM package |
| 152 | in https://github.com/coq/opam-coq-archive and opening an issue at |
| 153 | https://github.com/rocq-prover/rocq/issues. |
| 154 | |
| 155 | ### Recommended branching policy. |
| 156 | |
| 157 | It is sometimes the case that you will need to maintain a branch of |
| 158 | your project for particular Rocq versions. This is in fact very likely |
| 159 | if your project includes a Rocq ML plugin. |
| 160 | |
| 161 | For such projects, we recommend a branching convention that mirrors |
| 162 | Rocq's branching policy. Then, you would have a `master` branch that |
| 163 | follows Rocq's `master`, a `v9.0` branch that works with Rocq's `v9.0` |
| 164 | branch and so on. |
| 165 | |
| 166 | This convention will be supported by tools in the future to make some |
| 167 | developer commands work more seamlessly. |
| 168 | |
| 169 | ### Supported CI images for Rocq |
| 170 | |
| 171 | The Rocq developers and contributors provide official Docker and Nix |
| 172 | images for testing against Rocq master. Using these images is highly |
| 173 | recommended: |
| 174 | |
| 175 | - For Docker, see: https://github.com/coq-community/docker-coq |
| 176 | |
| 177 | The https://github.com/coq-community/docker-coq/wiki/CI-setup wiki |
| 178 | page contains additional information and templates to help setting |
| 179 | Docker-based CI up for your Rocq project |
| 180 | |
| 181 | - For Nix, see the setup at |
| 182 | https://github.com/coq-community/manifesto/wiki/Continuous-Integration-with-Nix |