Debian Codegraph @

doc/howto/set-up-ci-with-package-management.md

raw symbols SCIP
1 # How to set up Continuous Integration with Package Management
2
3 For many projects published it can be useful to set up a [continuous
4 integration](https://en.wikipedia.org/wiki/Continuous_integration) (CI) system.
5 This allows checking whether the code builds on other computers, the tests pass
6 and helps to assess contributions from other people.
7
8 There are numerous CI systems available. In this document we will be using
9 GitHub Actions, as it is integrated in the commonly used GitHub platform and
10 free to use.
11
12 ## What are Actions
13
14 Projects on GitHub can set up [Actions](https://docs.github.com/en/actions),
15 that is workflows defined in YAML files. These definitions are placed in the
16 `.github/workflows/` folder in the Git repository.
17
18 These workflows consist of the execution of a sequence of actions, like running
19 shell commands. It is also possible to use pre-defined actions or even
20 user-submitted functionality.
21
22 ## `setup-dune`
23
24 [`setup-dune`](https://github.com/ocaml-dune/setup-dune) is one such custom
25 action maintained by the OCaml community to help with setting up builds with
26 Dune.
27
28 It installs Dune in the GitHub runner environment and will attempt to build the
29 source code using Dune package management.
30
31 ::::{dropdown} `.github/workflow/ci.yaml`
32 :icon: file-code
33
34 :::{literalinclude} set-up-ci-with-package-management/ci.yaml
35 :language: yaml
36 :emphasize-lines: 15-16
37 :::
38
39 We define a job called `build`, which will be run on Ubuntu and macOS (a [list
40 of possible
41 options](https://docs.github.com/en/actions/reference/runners/github-hosted-runners)
42 can be found in the GitHub documentation).
43
44 This job first checks out the projects' source code using an action maintained
45 by GitHub and then uses the `setup-dune` action to install Dune on the system
46 and build the project.
47
48 `setup-dune` will enable package management by default and attempt to build the
49 project with the current nightly version of Dune.
50
51 Additional configuration options can be found in the [documentation of
52 `setup-dune`](https://github.com/ocaml-dune/setup-dune/?tab=readme-ov-file),
53 which includes picking a fixed version of Dune, picking a specific OCaml
54 compiler etc.
55
56 ::::
57
58 This configuration file has to be added to the repository and pushed to GitHub.
59 Some configuration to enable actions in the repository might be required, check
60 out [the GitHub documentation on repository
61 settings](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository)
62 related to actions.
63
64 Once set up, this action will be run on the commit of every push to every
65 branch as well as on every pull request. The results of running the actions are
66 visible as a colored dot next to the relevant commits that were processed by
67 CI.
68
69 ::::{seealso}
70
71 [GitHub Actions documentation](https://docs.github.com/en/actions) for
72 information about the configuration format and usual workflows.
73
74 [GitHub Actions marketplace](https://github.com/marketplace?type=actions) for a
75 list of published actions.
76 ::::