From 506af3932d5e0efc311df0e03124c0a2f5f1c698 Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Mon, 7 Sep 2020 14:55:10 +0200 Subject: [PATCH] gitlab: add examples and README --- README.md | 14 ++++ gitlab/.gitlab-ci.yml.example-full | 114 +++++++++++++++++++++++++++++ gitlab/.gitlab-ci.yml.example-mini | 36 +++++++++ gitlab/README.md | 64 ++++++++++++++++ 4 files changed, 228 insertions(+) create mode 100644 gitlab/.gitlab-ci.yml.example-full create mode 100644 gitlab/.gitlab-ci.yml.example-mini create mode 100644 gitlab/README.md diff --git a/README.md b/README.md index 603343d..a62ece8 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,20 @@ See specific **[ci-scripts on GitHub Actions README](github-actions/README.md)** for more details. +### [GitLab CI/CD](https://gitlab.com/) + + - Docker-based runners on Linux (one VM instance per job) + - Can use any Docker image from Dockerhub (the examples use + `ubuntu:bionic`) + - Compile natively using different compilers (gcc, clang) + - Cross-compile for Windows 32bit and 64bit using MinGW and WINE + - Cross-compile for RTEMS 4.9 and 4.10 (Base >= 3.15) + - Built dependencies are cached (for faster builds). + +See specific +**[ci-scripts on GitLab CI/CD README](gitlab/README.md)** +for more details. + ## How to Use the CI-Scripts 1. Get an account on a supported CI service provider platform diff --git a/gitlab/.gitlab-ci.yml.example-full b/gitlab/.gitlab-ci.yml.example-full new file mode 100644 index 0000000..25c19ca --- /dev/null +++ b/gitlab/.gitlab-ci.yml.example-full @@ -0,0 +1,114 @@ +# .gitlab-ci.yml for testing EPICS Base ci-scripts +# (see: https://github.com/epics-base/ci-scripts) + +# This is YAML - indentation levels are crucial + +# GitLab runner can use any Docker container, we're using this one +# to be comparable with the other CI services +image: ubuntu:bionic + +cache: + key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" + paths: + - .cache/ + +variables: + GIT_SUBMODULE_STRATEGY: "recursive" + SETUP_PATH: ".ci-local:.ci" + BASE_RECURSIVE: "NO" + # Additional packages needed for + # | EPICS |clang| Windows cross builds |RTEMS testing |sequencer + APT: "libreadline6-dev libncurses5-dev perl clang g++-mingw-w64-i686 g++-mingw-w64-x86-64 qemu-system-x86 re2c" + CMP: "gcc" + BGFC: "default" + +# Template for build jobs (hidden) +.build: + stage: build + before_script: + - apt-get update -qq && apt-get install -y -qq build-essential git python curl p7zip-full + - python .ci/cue.py prepare + script: + - python .ci/cue.py build + - python .ci/cue.py test + - python .ci/cue.py test-results + +# If you need to do more during install and build, +# add a local directory to your module and do e.g. +# - ./.ci-local/travis/install-extras.sh + +# Define build jobs + +# Well-known variables to use +# SET source setup file +# ADD_MODULES extra modules (for a specific job) +# BCFG build configuration (static/debug/static-debug; +# default: shared-optimized) +# TEST set to NO to skip running the tests (default: YES) +# VV set to make build scripts verbose (default: unset) +# EXTRA content will be added to make command line +# EXTRA1..5 more additional arguments for the make command +# (one argument per variable) + +# Usually from setup files, but may be specified or overridden +# on a job line +# MODULES list of dependency modules +# BASE branch or release tag name of the EPICS Base to use +# branch or release tag for a specific module +# ... see README for setup file syntax description + +# Different configurations of gcc and clang +gcc_default: + extends: .build + variables: + BASE: "7.0" + +gcc_static: + extends: .build + variables: + BASE: "7.0" + BCFG: "static" + +clang_default: + extends: .build + variables: + BASE: "7.0" + CMP: "clang" + +clang_static_c++11: + extends: .build + variables: + BASE: "7.0" + CMP: "clang" + BCFG: "static" + EXTRA: "CMD_CXXFLAGS=-std=c++11" + +# Cross-compilations to Windows using gcc/MinGW and WINE +wine32_default: + extends: .build + variables: + BASE: "3.15" + BCFG: "static" + WINE: "32" + TEST: "NO" + +wine64_debug: + extends: .build + variables: + BASE: "7.0" + BCFG: "debug" + WINE: "64" + +# Cross-builds to RTEMS 4.9 and 4.10 +rtems4.9_default: + extends: .build + variables: + RTEMS: "4.9" + BASE: "3.15" + +rtems4.10_debug: + extends: .build + variables: + RTEMS: "4.10" + BASE: "7.0" + BCFG: "debug" diff --git a/gitlab/.gitlab-ci.yml.example-mini b/gitlab/.gitlab-ci.yml.example-mini new file mode 100644 index 0000000..de1d63b --- /dev/null +++ b/gitlab/.gitlab-ci.yml.example-mini @@ -0,0 +1,36 @@ +# .gitlab-ci.yml for testing EPICS Base ci-scripts +# (see: https://github.com/epics-base/ci-scripts) + +image: ubuntu:bionic + +variables: + GIT_SUBMODULE_STRATEGY: "recursive" + SETUP_PATH: ".ci-local:.ci" + BASE_RECURSIVE: "NO" + # Minimal set of packages needed to compile EPICS Base + APT: "libreadline6-dev libncurses5-dev perl" + CMP: "gcc" + BGFC: "default" + +# Template for build jobs (hidden) +.build: + stage: build + before_script: + - apt-get update -qq && apt-get install -y -qq build-essential git python curl p7zip-full + - python .ci/cue.py prepare + script: + - python .ci/cue.py build + - python .ci/cue.py test + - python .ci/cue.py test-results + +# Build on Linux using default gcc for Base branches 7.0 and 3.15 + +gcc_7_0: + extends: .build + variables: + BASE: "7.0" + +gcc_3_15: + extends: .build + variables: + BASE: "3.15" diff --git a/gitlab/README.md b/gitlab/README.md new file mode 100644 index 0000000..aa07b71 --- /dev/null +++ b/gitlab/README.md @@ -0,0 +1,64 @@ +# GitLab CI/CD Scripts for EPICS Modules + +## Features + + - Docker-based runners on Linux (one VM instance per job) + - Can use any Docker image from Dockerhub (the examples use + `ubuntu:bionic`) + - Compile natively using different compilers (gcc, clang) + - Cross-compile for Windows 32bit and 64bit using MinGW and WINE + - Cross-compile for RTEMS 4.9 and 4.10 (Base >= 3.15) + - Built dependencies are cached (for faster builds). + +## How to Use these Scripts + + 1. Get an account on [GitLab](https://gitlab.com/), create a project + for your support module and have it mirror your upstream GitHub + repository. For more details, please refer to the + [GitLab CI/CD documentation](https://docs.gitlab.com/ee/README.html). + + 2. Add the ci-scripts respository as a Git Submodule + (see [README](../README.md) one level above). + + 3. Add settings files defining which dependencies in which versions + you want to build against + (see [README](../README.md) one level above). + + 4. Create a GitLab configuration by copying one of the examples into + the root directory of your module. + ``` + $ cp .ci/gitlab/.gitlab-ci.yml.example-full .gitlab-ci.yml + ``` + + 5. Edit the `.gitlab-ci.yml` configuration to include the jobs you want + GitLab CI/CD to run. + + Build jobs are declared in the list at the end of the file. + Each element (starting with the un-indented line) defines the + settings for one build job. `extends:` specifies a template to use as + a default structure, `variables:` controls the setting of environment + variables (overwriting settings from the template). + Also see the comments in the examples for more hints, and the + [GitLab CI/CD documentation](https://docs.gitlab.com/ee/README.html) + for more options and details. + + 6. Push your changes to GitHub, wait for the synchronization (every 5min) + and check [GitLab](https://gitlab.com/) for your build results. + +## Caches + +GitLab is configured to keep the caches separate for different jobs. + +However, changing the job description (in the `.gitlab-ci.yml` +configuration file) or its environment settings or changing a value +inside a setup file will _not_ invalidate the cache - you will +have to manually delete the caches through the GitLab web interface. + +Caches are automatically removed after approx. four weeks. +Your jobs will have to rebuild them once in a while. + +## Miscellanea + +To use the feature to extract `.zip`/`.7z` archives by setting +`*_HOOK` variables, the Linux and MacOS runners need the APT package +`p7zip-full` resp. the Homebrew package `p7zip` installed.