Overview
Design of CI configuration
- Script
- Bourne shell script
- PowerShell script
Script should be source-able using the same script for every CI service (because generating multiple scripts means changing those scripts). Then the script in turn should do something different based on which CI is being used (detected using the environment variables).
Steps for CI should have information on how to retrieve modules/distributions. For example, inside a monorepo this is a directory.
Caching
- Caching inside of a single CI system: this can be used for artifacts that
are created internally to the build that can be rebuilt as long as inputs do
not change.
- e.g., for a given repo, the dependencies installed from CPAN
Caching outside of the CI system: some build artifacts can be stored outside of the CI caching mechanism so that they can be shared across repos.
- Given
- Projects { P_A, P_B }
- Tasks { Task₀, Task₁ }
- OS os and architecture arch (determined by what the workflow is running on); (ignoring APIs/ABIs for now)
- VersionString(P_A) = V_A, VersionString(P_B) = V_B
- e.g., using
git describe --always
- e.g., using
- Task₀(P_A) has output A_O₀{V_A, os,arch}.
- Where Task₁(P_B) running on {os,arch} depends on A_O₀{V_A,os,arch}
- V_A for P_B is determined by turning a project dependency such as
P_B has-runtime-dependency-on (P_A where P_A source is git:A @ master)
into a concrete dependency.
- V_A for P_B is determined by turning a project dependency such as
Specifically on GitHub:
- Workflow running on every push, pull request:
- We can store A_O₀{V_A,os,arch} as a GitHub
release under tag
continuous-build
when finished running Task₀(P_A) under the CI workflow for P_A for the default/release branch (e.g., master). - When running Task₁(P_B) under the CI workflow for P_B, retrieve A_O₀{V_A,os,arch} from GitHub releases if it exists. Otherwise build A_O₀{V_A,os,arch} inside of the CI workflow.
- We can store A_O₀{V_A,os,arch} as a GitHub
release under tag
- Workflow running on every tag creation:
- When running Task₀(P_A) under the CI workflow for P_A, delete all A_O₀{Version,Os,Arch} where Version < VersionString(P_A).
- Given
Multiple version testing
For example, say you want to test a binding library B that binds to library A (e.g., FFI-based binding).
- You can build and install all different versions of A in parallel into different folders.
- You only need to build the dependencies of library B once since they do not depend on library A.
- You build library B with a different path to test each version.
Examples
- Travis CI:
install: skip script: eval "$(curl .../bootstrap.sh)"
- AppVeyor:
build: off test_script: - ps: . { iwr -useb .../bootstrap.ps1 } | iex
-
GitHub Actions:
jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Run Orbital Transfer run: | eval "$(curl .../bootstrap.sh)"
Services
GitHub Actions
Reference: https://docs.github.com/en/free-pro-team@latest/actions/reference.
Events
- Installed software in each environment: https://github.com/actions/virtual-environments
- Storing artifacts inside of a workflow https://docs.github.com/en/free-pro-team@latest/actions/guides/storing-workflow-data-as-artifacts.
- Caching https://docs.github.com/en/free-pro-team@latest/actions/guides/caching-dependencies-to-speed-up-workflows.
- Container registry https://github.blog/2020-09-01-introducing-github-container-registry/
- Problem matcher https://github.com/actions/toolkit/blob/master/docs/problem-matchers.md
- Runner OS https://stackoverflow.com/questions/57946173/github-actions-run-step-on-specific-os
- Debugging with SSH https://github.com/marketplace/actions/debugging-with-tmate, https://github.com/mxschmitt/action-tmate
- Calling another action from within another action
- Examples
- https://github.com/msys2/setup-msys2/blob/master/main.js
- https://github.com/lukka/get-cmake
- See how the
INPUT_
variables are set before callingnode
on the script https://github.com/lukka/get-cmake/commit/446604d899e2d059c8fcabbe0ca667f4a2f3d6a6#diff-be68d96e830a24de59f0f45dc4992763e34ed200d15c8a5e3e3fd05a007169b8
- See how the
- https://github.com/marketplace/actions/run-vcpkg
- https://github.community/t/call-an-action-from-another-action/17524/2
- https://stackoverflow.com/questions/58860769/call-a-github-action-from-another-github-action
- https://stackoverflow.com/questions/58611841/how-can-i-reference-other-actions-from-my-github-actions-action-yml-file
- Examples
- Using conditionals with composite actions https://github.com/actions/runner/issues/834#issuecomment-909921245.
- Security: https://dev.to/gitguardian/github-actions-security-cheat-sheet-da9
Actions:
- MSYS2:
Examples:
- Perl
- https://perlmaven.com/github-actions-running-on-3-operating-systems
- https://github.com/tobyink/p5-app-ghaprove/blob/master/.github/workflows/ci.yml
- Note: this uses separate stages for authoring the distribution and installing distribution. This way it is only authored once.
- https://github.com/graphviz-perl/GraphViz2/blob/master/.github/workflows/ci.yml
- https://metacpan.org/pod/GitHub::Actions
Travis CI
- Build stages https://docs.travis-ci.com/user/build-stages/.
- Storing artifacts inside of stages https://docs.travis-ci.com/user/using-workspaces/.
- https://www.jeffgeerling.com/blog/2020/travis-cis-new-pricing-plan-threw-wrench-my-open-source-works
AppVeyor
- Environment variables - AppVeyor
- e.g., for build folder in PowerShell, use
$Env:APPVEYOR_BUILD_FOLDER
- e.g., for build folder in PowerShell, use
- Software pre-installed on Windows build VMs - AppVeyor
GitLab CI
- YAML syntax reference
- Cronjobs
- Reports
- https://docs.gitlab.com/ee/ci/yaml/artifacts_reports.html
- JUnit
- https://gitlab.com/gitlab-org/gitlab/-/issues/299086
- https://gitlab.com/gitlab-org/gitlab/-/issues/268035
- https://docs.gitlab.com/ee/ci/testing/unit_test_reports.html
- https://docs.gitlab.com/ee/ci/testing/unit_test_report_examples.html
- https://www.ibm.com/docs/en/developer-for-zos/14.1.0?topic=formats-junit-xml-format
- https://gitlab.com/gitlab-org/gitlab/-/issues/228950
- Env variables:
- Cacheing:
- Disabling jobs
- Shared runners
- https://gitlab.com/gitlab-org/gitlab/-/issues/359974
- Windows
- https://docs.gitlab.com/ee/development/windows.html#shared-windows-runners
- https://about.gitlab.com/blog/2020/01/21/windows-shared-runner-beta/
- https://gitlab.com/gitlab-org/ci-cd/shared-runners/images/gcp/windows-containers
- https://gitlab.com/gitlab-org/ci-cd/shared-runners/images/gcp/windows-containers/-/tree/main/cookbooks/preinstalled-software
- macOS
- https://gitlab.com/gitlab-org/ci-cd/shared-runners/images/macstadium/orka
- https://docs.gitlab.com/ee/ci/runners/saas/macos/environment.html#vm-images
- https://about.gitlab.com/blog/2021/08/23/build-cloud-for-macos-beta/
- https://gitlab.com/gitlab-com/runner-saas-macos-access-requests
- https://gitlab.com/gitlab-org/gitlab-runner/-/issues/6564
- https://gitlab.com/gitlab-org/gitlab/-/issues/224124
Cirrus CI
Common features
- Skipping commits by using directive in commit message:
- e.g.,
[skip ci]
,[ci skip]
. - GHA: https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/
- e.g.,
- CI environment information