|
| 1 | +# Generate continuous integration test files |
| 2 | +# |
| 3 | +# This is a code generator built using the iMatix GSL code generation |
| 4 | +# language. See https://github.com/zeromq/gsl for details. |
| 5 | +# |
| 6 | +# Copyright (c) the Contributors as noted in the AUTHORS file. |
| 7 | +# This file is part of zproject. |
| 8 | +# |
| 9 | +# This Source Code Form is subject to the terms of the Mozilla Public |
| 10 | +# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 11 | +# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 12 | + |
| 13 | +register_target ("gh_actions", "Github Actions scripts") |
| 14 | + |
| 15 | +.macro target_gh_actions |
| 16 | +.if !file.exists (".github/workflows/CI.yaml") |
| 17 | +. echo "Generating skeleton .github/workflows/CI.yaml script" |
| 18 | +. directory.create ('.github/workflows') |
| 19 | +. output ".github/workflows/CI.yaml" |
| 20 | +# Github Actions CI script |
| 21 | +# This is a skeleton created by zproject. |
| 22 | +# You can add hand-written code here. |
| 23 | + |
| 24 | +name: CI |
| 25 | +on: |
| 26 | + push: |
| 27 | + pull_request: |
| 28 | +. |
| 29 | +.- Prerequisite packages provided by OS distro and used "as is" |
| 30 | +. packages = "git" |
| 31 | +. packages_brew = "" |
| 32 | +. for use |
| 33 | +. if ! defined (use.repository) & ! defined (use.tarball) |
| 34 | +. if defined (use.debian_name) |
| 35 | +. if !(use.debian_name = '') |
| 36 | +. packages += " " + use.debian_name |
| 37 | +. else |
| 38 | +. echo "WARNING: debian_name=='' for $(use.project) - not added to .github/workflows/CI.yml" |
| 39 | +. endif |
| 40 | +. elsif defined (use.libname) |
| 41 | +. packages += " " + string.replace (use.libname, "_|-") + "-dev" |
| 42 | +. else |
| 43 | +. packages += " " + string.replace (use.project, "_|-") + "-dev" |
| 44 | +. endif |
| 45 | +. if defined (use.brew_name) |
| 46 | +. packages_brew += " " + use.brew_name |
| 47 | +. endif |
| 48 | +. endif |
| 49 | +. endfor |
| 50 | + |
| 51 | +.- Prerequisite packages that may be built from source or used from |
| 52 | +.- prebuilt packages of that source (usually not from an OS distro) |
| 53 | +.if project.gh_actions_use_pkg_deps_prereqs_source ?= 0 |
| 54 | +. echo "NOTE: Our forks are checked out and built without pkg dependencies in use" |
| 55 | +.else |
| 56 | +. for use |
| 57 | +. if defined (use.repository) | defined (use.tarball) |
| 58 | +. if defined (use.debian_name) |
| 59 | +. if !(use.debian_name = '') |
| 60 | +. packages += " " + use.debian_name |
| 61 | +. else |
| 62 | +. echo "WARNING: debian_name=='' for $(use.project) - not added to .github/workflows/CI.yml" |
| 63 | +. endif |
| 64 | +. elsif defined (use.libname) |
| 65 | +. packages += " " + string.replace (use.libname, "_|-") + "-dev" |
| 66 | +. else |
| 67 | +. packages += " " + string.replace (use.project, "_|-") + "-dev" |
| 68 | +. endif |
| 69 | +. if defined (use.brew_name) |
| 70 | +. packages_brew += " " + use.brew_name |
| 71 | +. endif |
| 72 | +. endif |
| 73 | +. endfor |
| 74 | +.endif |
| 75 | +. |
| 76 | +.if defined(project.gh_actions_check_zproject) & !(project.gh_actions_check_zproject ?= 0) |
| 77 | +.- NOTE: Currently the shell script does support use of packages or checkout |
| 78 | +.- of latest github code for these tools - but only from zeromq org repos, |
| 79 | +.- no forks/branches. |
| 80 | +. packages_zproject = "generator-scripting-language zproject" |
| 81 | +.else |
| 82 | +. packages_zproject = "" |
| 83 | +.endif |
| 84 | +.packages_doctools = "asciidoc xmlto" |
| 85 | + |
| 86 | +jobs: |
| 87 | + build: |
| 88 | + runs-on: ${{ matrix.os }} |
| 89 | + strategy: |
| 90 | + fail-fast: false |
| 91 | + matrix: |
| 92 | + include: |
| 93 | + - os: ubuntu-latest |
| 94 | + BUILD_TYPE: default |
| 95 | + DRAFT: enabled |
| 96 | + CLANG_FORMAT: clang-format-11 |
| 97 | + PACKAGES: automake autoconf clang-format-11 $(packages) $(packages_doctools) |
| 98 | + - os: ubuntu-latest |
| 99 | + BUILD_TYPE: default |
| 100 | + DRAFT: disabled |
| 101 | + CLANG_FORMAT: clang-format-11 |
| 102 | + PACKAGES: automake autoconf clang-format-11 $(packages) |
| 103 | + - os: ubuntu-latest |
| 104 | + BUILD_TYPE: valgrind |
| 105 | + DRAFT: enabled |
| 106 | + PACKAGES: automake autoconf valgrind $(packages) |
| 107 | + - os: ubuntu-latest |
| 108 | + BUILD_TYPE: cmake |
| 109 | + DRAFT: enabled |
| 110 | + PACKAGES: cmake $(packages) |
| 111 | + - os: macos-latest |
| 112 | + BUILD_TYPE: default |
| 113 | + PACKAGES: automake autoconf $(packages_brew) |
| 114 | + DRAFT: enabled |
| 115 | + - os: macos-latest |
| 116 | + BUILD_TYPE: default |
| 117 | + DRAFT: disabled |
| 118 | + PACKAGES: automake autoconf $(packages_brew) |
| 119 | +.if project.gh_actions_clangformat_implem ?= "autotools" | ( !defined(project.gh_actions_clangformat_implem) & project.gh_actions_use_cmake ?= 0 ) |
| 120 | +. echo "GHA: CLANG-FORMAT: implementation: autotools" |
| 121 | +### Note: we don't use CMake |
| 122 | + - os: ubuntu-latest |
| 123 | + BUILD_TYPE: cmake |
| 124 | + DO_CLANG_FORMAT_CHECK: 1 |
| 125 | + CLANG_FORMAT: clang-format-11 |
| 126 | + PACKAGES: cmake clang-format-11 $(packages) |
| 127 | +.endif |
| 128 | +# For non-cmake users, there is an autotools solution with a bit more overhead |
| 129 | +# to have dependencies ready and pass configure script before making this check). |
| 130 | +# Note that the autotools variant will also require dependencies preinstalled to |
| 131 | +# pass its configure script: |
| 132 | +.if project.gh_actions_clangformat_implem ?= "cmake" | ( !defined(project.gh_actions_clangformat_implem) & ( project.gh_actions_use_cmake ?= 1 | !defined(project.gh_actions_use_cmake) ) ) |
| 133 | +. echo "GHA: CLANG-FORMAT: implementation: cmake" |
| 134 | + - os: ubuntu-latest |
| 135 | + BUILD_TYPE: cmake |
| 136 | + DO_CLANG_FORMAT_CHECK: 1 |
| 137 | + CLANG_FORMAT: clang-format-11 |
| 138 | + PACKAGES: cmake clang-format-11 $(packages) |
| 139 | +.endif |
| 140 | +.if project.gh_actions_check_abi_compliance ?= 1 |
| 141 | +. if project.exports_classes |
| 142 | +# Note: the ABI compliance checker script currently assumes that: |
| 143 | +# 1) Your project sources have a "latest_release" branch or tag |
| 144 | +# to check out and compare the current commit's ABI to; |
| 145 | +# 2) Prerequisites are available as packages - no custom rebuilds. |
| 146 | + - os: ubuntu-latest |
| 147 | + BUILD_TYPE: abi-compliance-checker |
| 148 | + PACKAGES: universal-ctags abi-dumper abi-compliance-checker $(packages) |
| 149 | +. endif |
| 150 | +.endif |
| 151 | +.if defined(project.gh_actions_check_zproject) & !(project.gh_actions_check_zproject ?= 0) |
| 152 | + - os: ubuntu-latest |
| 153 | + BUILD_TYPE: check_zproject |
| 154 | + PACKAGES: $(packages) $(packages_zproject) |
| 155 | +.endif |
| 156 | + env: |
| 157 | +# Set CI_TIME: true to enable build-step profiling |
| 158 | +# Set CI_TRACE: true to enable shell script tracing |
| 159 | +# Set CI_CONFIG_QUIET: true to enable "configure --quiet" (only report stderr) |
| 160 | +# Set CI_REQUIRE_GOOD_GITIGNORE: false to NOT fail if "git status -s" is not clean |
| 161 | +# Set CI_REQUIRE_GOOD_CLANG_FORMAT: true to fail if "clang-format" check is not clean |
| 162 | + CI_TIME: false |
| 163 | + CI_TRACE: false |
| 164 | + CI_CONFIG_QUIET: true |
| 165 | + CI_REQUIRE_GOOD_GITIGNORE: \ |
| 166 | +.if project.gh_actions_require_gitignore ?= 1 |
| 167 | +true |
| 168 | +.else |
| 169 | +false |
| 170 | +.endif |
| 171 | + CI_REQUIRE_GOOD_CLANG_FORMAT: \ |
| 172 | +.if defined(project.gh_actions_clangformat_require_good) |
| 173 | +. echo "GHA: CLANG-FORMAT: require-good: " + project.gh_actions_clangformat_require_good |
| 174 | +. if project.gh_actions_clangformat_require_good ?= 1 |
| 175 | +true |
| 176 | +. else |
| 177 | +false |
| 178 | +. endif |
| 179 | +.else |
| 180 | +. if project.gh_actions_clangformat_allow_failures ?= 1 |
| 181 | +. echo "GHA: CLANG-FORMAT: require-good: " + 1 + " (default from allow_failed)" |
| 182 | +true |
| 183 | +. else |
| 184 | +. echo "GHA: CLANG-FORMAT: require-good: " + 0 + " (default from allow_failed)" |
| 185 | +false |
| 186 | +. endif |
| 187 | +.endif |
| 188 | + CI_TEST_DISTCHECK: \ |
| 189 | +.if !defined(project.gh_actions_distcheck) | project.gh_actions_distcheck ?= 1 |
| 190 | +.# 1 = required, is default if nothing is set |
| 191 | +true |
| 192 | +.else |
| 193 | +.# 0 = skip, 2 = allowed fail (in a special test case, skip in others) |
| 194 | +false |
| 195 | +.endif |
| 196 | + platform: ${{ matrix.platform }} |
| 197 | + configuration: ${{ matrix.configuration }} |
| 198 | + ENABLE_DRAFTS: ${{ matrix.ENABLE_DRAFTS }} |
| 199 | + BUILD_TYPE: ${{ matrix.BUILD_TYPE }} |
| 200 | + DRAFT: ${{ matrix.DRAFT }} |
| 201 | + DO_CLANG_FORMAT_CHECK: ${{ matrix.DO_CLANG_FORMAT_CHECK }} |
| 202 | + CLANG_FORMAT: ${{ matrix.CLANG_FORMAT }} |
| 203 | + CI_SELFTEST: ${{ matrix.CI_SELFTEST }} |
| 204 | + steps: |
| 205 | + - name: Add debian packages |
| 206 | + if: matrix.os == 'ubuntu-latest' |
| 207 | + uses: myci-actions/add-deb-repo@10 |
| 208 | + with: |
| 209 | + repo-name: obs |
| 210 | + repo: deb http://download.opensuse.org/repositories/network:/messaging:/zeromq:/git-stable/xUbuntu_20.04/ ./ |
| 211 | + keys-asc: https://download.opensuse.org/repositories/network:/messaging:/zeromq:/git-stable/xUbuntu_20.04/Release.key |
| 212 | + install: ${{ matrix.PACKAGES }} |
| 213 | + - name: Add brew packages |
| 214 | + if: matrix.os == 'macos-latest' |
| 215 | + shell: bash |
| 216 | + run: brew install ${{ matrix.PACKAGES }} |
| 217 | + - uses: actions/checkout@v2 |
| 218 | + with: |
| 219 | + path: $(project.name) |
| 220 | + - name: build |
| 221 | + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' |
| 222 | + shell: bash |
| 223 | + working-directory: $(project.name) |
| 224 | + run: ./ci_build.sh |
| 225 | +. close |
| 226 | +.else |
| 227 | +. echo "NOT regenerating an existing .github/workflows/CI.yaml file; you might want to move yours out of the way and re-generate the project again to get updated settings" |
| 228 | +.endif |
| 229 | +.endmacro |
0 commit comments