Skip to content

Commit dfcbc5a

Browse files
committed
Problem: no way to use Github Actions workflow
Solution: generate config file
1 parent 1487ad4 commit dfcbc5a

File tree

7 files changed

+241
-0
lines changed

7 files changed

+241
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ zproject's `project.xml` contains an extensive description of the available conf
197197
qt Qt binding
198198
redhat Packaging for RedHat
199199
ruby Ruby binding
200+
gh_actions Github Actions configuration (same options as travis)
200201
travis Travis CI scripts
201202
<option name="dist" value="trusty" /> Select a Linux distribution to use by default on Travis CI, also impacts the OBS-served repository of ZMQ-family packages to use (if not building from source all the time per use_pkg_deps_prereqs_source below). By default it would be "xenial" as of now.
202203
<option name="distcheck" value="0" /> "0" will disable run of make distcheck in Travis CI, "2" will enable it as a special testcase allowed to fail (default: 1 to enable and require to pass)
@@ -590,6 +591,7 @@ zproject's `project.xml` contains an extensive description of the available conf
590591
<bin name = "zproject_debian.gsl" />
591592
<bin name = "zproject_delphi.gsl" />
592593
<bin name = "zproject_docker.gsl" />
594+
<bin name = "zproject_gh_actions.gsl" />
593595
<bin name = "zproject_gyp.gsl" />
594596
<bin name = "zproject_java.gsl" />
595597
<bin name = "zproject_java_lib.gsl" />

packaging/debian/zproject.install

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ usr/bin/zproject_cygwin.gsl
1414
usr/bin/zproject_debian.gsl
1515
usr/bin/zproject_delphi.gsl
1616
usr/bin/zproject_docker.gsl
17+
usr/bin/zproject_gh_actions.gsl
1718
usr/bin/zproject_gyp.gsl
1819
usr/bin/zproject_java.gsl
1920
usr/bin/zproject_java_lib.gsl

packaging/redhat/zproject.spec

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ find %{buildroot} -name '*.la' | xargs rm -f
8282
%{_bindir}/zproject_debian.gsl
8383
%{_bindir}/zproject_delphi.gsl
8484
%{_bindir}/zproject_docker.gsl
85+
%{_bindir}/zproject_gh_actions.gsl
8586
%{_bindir}/zproject_gyp.gsl
8687
%{_bindir}/zproject_java.gsl
8788
%{_bindir}/zproject_java_lib.gsl

project.xml

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
qt Qt binding
2121
redhat Packaging for RedHat
2222
ruby Ruby binding
23+
gh_actions Github Actions configuration (same options as travis)
2324
travis Travis CI scripts
2425
<option name="dist" value="trusty" /> Select a Linux distribution to use by default on Travis CI, also impacts the OBS-served repository of ZMQ-family packages to use (if not building from source all the time per use_pkg_deps_prereqs_source below). By default it would be "xenial" as of now.
2526
<option name="distcheck" value="0" /> "0" will disable run of make distcheck in Travis CI, "2" will enable it as a special testcase allowed to fail (default: 1 to enable and require to pass)
@@ -413,6 +414,7 @@
413414
<bin name = "zproject_debian.gsl" />
414415
<bin name = "zproject_delphi.gsl" />
415416
<bin name = "zproject_docker.gsl" />
417+
<bin name = "zproject_gh_actions.gsl" />
416418
<bin name = "zproject_gyp.gsl" />
417419
<bin name = "zproject_java.gsl" />
418420
<bin name = "zproject_java_lib.gsl" />

src/Makemodule.am

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ dist_bin_SCRIPTS = \
2727
zproject_debian.gsl \
2828
zproject_delphi.gsl \
2929
zproject_docker.gsl \
30+
zproject_gh_actions.gsl \
3031
zproject_gyp.gsl \
3132
zproject_java.gsl \
3233
zproject_java_lib.gsl \
@@ -53,6 +54,7 @@ dist_bin_SCRIPTS = \
5354
zproject_known_projects.xml
5455

5556

57+
if ENABLE_ZPROJECT_SELFTEST
5658
# Directories with test fixtures optionally provided by the project,
5759
# and with volatile RW data possibly created by a selftest program.
5860
# It is up to the project authors to populate the RO directory with
@@ -193,6 +195,7 @@ coverage: src/zproject_selftest
193195
@echo "call make clean && configure --with-gcov to enable code coverage"
194196
@exit 1
195197
endif
198+
endif #ENABLE_ZPROJECT_SELFTEST
196199

197200
bindings: python-bindings
198201

@@ -350,10 +353,12 @@ check-gitignore:
350353
echo "SKIP: $@ (no git)"; exit 0 ; \
351354
fi )
352355

356+
if ENABLE_ZPROJECT_SELFTEST
353357
# This calls the recipe above after building the project products and
354358
# the selftest binary, and preparing the workspace for self-testing:
355359
check-gitignore-all: all src/zproject_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO)
356360
$@$(MAKE) check-gitignore
361+
endif #ENABLE_ZPROJECT_SELFTEST
357362

358363

359364
################################################################################

zproject.gsl

+1
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ gsl from "zproject_cygwin.gsl"
326326
gsl from "zproject_debian.gsl"
327327
gsl from "zproject_delphi.gsl"
328328
gsl from "zproject_docker.gsl"
329+
gsl from "zproject_gh_actions.gsl"
329330
gsl from "zproject_gyp.gsl"
330331
gsl from "zproject_java.gsl"
331332
gsl from "zproject_java_msvc.gsl"

zproject_gh_actions.gsl

+229
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
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

Comments
 (0)