Skip to content

Commit 4f83544

Browse files
committed
portable: CI: use GH and Cirrus
Try and implement CI across systems for better performance. Curently, a WIP.
1 parent 56dc167 commit 4f83544

File tree

3 files changed

+119
-6
lines changed

3 files changed

+119
-6
lines changed

.github/ci/before-install.sh

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,33 @@
11
#!/bin/sh
22

3-
if [ "$CIRRUS_OS" = "linux" ]; then
4-
apt-get update -qq && \
5-
apt-get --no-install-suggests --no-install-recommends -y install \
3+
set -xv
4+
SUDO="sudo"
5+
export SUDO
6+
7+
which_ci() {
8+
if [ -n "$RUNNER_OS" ]; then
9+
# GitHub Actions
10+
case "$RUNNER_OS" in
11+
Linux)
12+
unset SUDO
13+
echo "linux" ;;
14+
esac
15+
elif [ -n "$CIRRUS_OS" ]; then
16+
# Cirrus CI
17+
echo "$CIRRUS_OS"
18+
fi
19+
}
20+
21+
OS="$(which_ci)"
22+
23+
echo "CI_OS=$CI_OS"
24+
25+
if [ "$OS" = "linux" ]; then
26+
if [ "$CI_OS" == "alpine" ]; then
27+
apk add libevent-dev git build-base bsd-compat-headers bison automake make autoconf libbsd-dev util-linux-dev libressl-dev zlib-dev ncurses-dev openssh ed gcc clang
28+
else
29+
"$SUDO" apt-get update -qq && \
30+
"$SUDO" apt-get --no-install-suggests --no-install-recommends -y install \
631
athena-jot \
732
autoconf \
833
autoconf-archive \
@@ -11,6 +36,7 @@ if [ "$CIRRUS_OS" = "linux" ]; then
1136
bison \
1237
build-essential \
1338
ed \
39+
clang \
1440
git \
1541
libbsd-dev \
1642
libevent-dev \
@@ -22,9 +48,10 @@ if [ "$CIRRUS_OS" = "linux" ]; then
2248
pkg-config \
2349
uuid-dev \
2450
zlib1g-dev
51+
fi
2552
fi
2653

27-
if [ "$CIRRUS_OS" = "freebsd" ]; then
54+
if [ "$OS" = "freebsd" ]; then
2855
pkg install -y \
2956
automake \
3057
pkgconf \
@@ -35,7 +62,7 @@ if [ "$CIRRUS_OS" = "freebsd" ]; then
3562
p5-HTTP-Daemon-SSL
3663
fi
3764

38-
if [ "$CIRRUS_OS" = "darwin" ]; then
65+
if [ "$OS" = "darwin" ]; then
3966
brew install autoconf \
4067
automake \
4168
bison \

.github/ci/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
./autogen.sh || exit 1
44
./configure || exit 1
5-
exec make
5+
exec make -j4

.github/workflows/ci.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: GoT-portable CI
2+
3+
on:
4+
push:
5+
branches:
6+
- portable
7+
- ta/cirrus-updates
8+
9+
jobs:
10+
ubuntu-build:
11+
name: Ubuntu (${{ matrix.compiler }})
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
compiler: [gcc, clang]
16+
env:
17+
CI_OS: linux
18+
CI_COMPILER: ${{ matrix.compiler }}
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
- run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
23+
- name: Configure and Install Packages
24+
run: |
25+
.github/ci/before-install.sh
26+
- name: Build
27+
run: .github/ci/build.sh
28+
- name: Tests
29+
run: |
30+
sudo make install
31+
(umask 022; make tests GOT_TEST_QUIET=)
32+
33+
alpine-build:
34+
name: Alpine (${{ matrix.compiler }})
35+
runs-on: ubuntu-latest
36+
strategy:
37+
matrix:
38+
compiler: [gcc, clang]
39+
env:
40+
CI_OS: alpine
41+
CI_COMPILER: ${{ matrix.compiler }}
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@v4
45+
- run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
46+
- name: Setup latest Alpine Linux
47+
uses: jirutka/setup-alpine@v1
48+
- name: Configure and Install Packages
49+
run: |
50+
.github/ci/before-install.sh
51+
shell: alpine.sh --root {0}
52+
- name: Setup SSH (for tests)
53+
run: |
54+
set -xv
55+
echo "HOST *" > /etc/ssh/ssh_config
56+
echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config
57+
mkdir -p /var/run/sshd
58+
ssh-keygen -A
59+
ssh-keygen -t ed25519 -N '' -f "$GITHUB_WORKSPACE/ci_ssh_key"
60+
install -d -m 700 ~/.ssh
61+
cat "$GITHUB_WORKSPACE/ci_ssh_key.pub" >> /etc/ssh/authorized_keys
62+
chmod 600 /etc/ssh/authorized_keys
63+
printf '%s\n' \
64+
"AuthorizedKeysFile /etc/ssh/authorized_keys" \
65+
"PasswordAuthentication no" \
66+
"ChallengeResponseAuthentication no" \
67+
"PermitRootLogin yes" >> /etc/ssh/sshd_config
68+
touch /etc/ssh/ssh_known_hosts
69+
chmod 600 /etc/ssh/ssh_known_hosts
70+
/usr/sbin/sshd -D &
71+
shell: alpine.sh --root {0}
72+
- name: Run Tests
73+
shell: alpine.sh {0}
74+
run: |
75+
set -eux
76+
echo $(whoami)
77+
ssh -i "$GITHUB_WORKSPACE/ci_ssh_key" \
78+
-T \
79+
localhost "echo OK: $(uname -a)"
80+
- name: Build
81+
run: .github/ci/build.sh
82+
shell: alpine.sh {0}
83+
- name: Install
84+
run: |
85+
make install
86+
shell: alpine.sh --root {0}

0 commit comments

Comments
 (0)