forked from OCEAN-xyz/datum_gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (134 loc) · 5.75 KB
/
build.yaml
File metadata and controls
142 lines (134 loc) · 5.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Build DATUM Gateway
on:
schedule:
- cron: '0 0 1 * *'
push:
pull_request:
jobs:
build:
strategy:
matrix:
os:
- ubuntu:latest
- ubuntu:22.04
- debian:latest
- debian:stable
- debian:oldstable
- almalinux:latest
- amazonlinux:latest
- fedora:latest
- oraclelinux:9
- alpine:latest
- archlinux:latest
- clearlinux:latest
config:
- cmake_args: "-DENABLE_API=ON -DCMAKE_C_COMPILER=gcc"
id: "gcc"
- cmake_args: "-DENABLE_API=ON -DCMAKE_C_COMPILER=clang"
id: "clang"
- cmake_args: "-DENABLE_API=OFF"
id: "no_api"
exclude:
# Clang configured for C11 rejects our C23 usage
- os: debian:oldstable
config:
cmake_args: "-DENABLE_API=ON -DCMAKE_C_COMPILER=clang"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Load package cache
uses: actions/cache/restore@v4
with:
path: pkg-cache
key: ${{ matrix.os }}-pkg-cache-${{ github.event_name == 'pull_request' && github.head_ref || 'main' }}-${{ matrix.config.id }}-${{ github.sha }}
restore-keys: |
${{ matrix.os }}-pkg-cache-${{ github.event_name == 'pull_request' && github.head_ref || 'main' }}-${{ matrix.config.id }}-
${{ matrix.os }}-pkg-cache-${{ github.event_name == 'pull_request' && github.head_ref || 'main' }}-
${{ matrix.os }}-pkg-cache-main-
- name: Initialise Docker image
run: |
if [ -e pkg-cache/docker.tar ]; then
docker load -i pkg-cache/docker.tar
else
docker pull "${{ matrix.os }}"
mkdir -p pkg-cache
docker save -o pkg-cache/docker.tar "${{ matrix.os }}"
fi
find pkg-cache
- name: Build inside Docker
run: |
PACKAGES_CLANG='clang'
PACKAGES_GCC='gcc'
case "${{ matrix.os }}" in
debian:*|ubuntu:*)
PKG_CACHE_DIR="/var/cache/apt"
INSTALL_CMD="apt update && apt -o APT::Clean-Installed=0 install -y"
PACKAGES="git libc6-dev cmake libcurl4-openssl-dev libjansson-dev libsodium-dev pkgconf"
PACKAGES_API="libmicrohttpd-dev"
CLEANUP_CACHE_CMD="rm -rfv ${PKG_CACHE_DIR}/archives/{partial,lock}"
;;
almalinux:*|amazonlinux:*|fedora:*|oraclelinux:*)
PKG_CACHE_DIR="/var/cache/dnf"
DNF_INSTALL="dnf --setopt=keepcache=True install -y"
INSTALL_CMD="$DNF_INSTALL"
[[ "${{ matrix.os }}" =~ ^almalinux: ]] && INSTALL_CMD="$DNF_INSTALL dnf-plugins-core && dnf config-manager --set-enabled crb && $INSTALL_CMD"
[[ "${{ matrix.os }}" =~ ^oraclelinux: ]] && INSTALL_CMD="$DNF_INSTALL dnf-plugins-core && dnf config-manager --set-enabled ol9_codeready_builder && $INSTALL_CMD"
[[ "${{ matrix.os }}" =~ ^(alma|oracle)linux: ]] && INSTALL_CMD="$DNF_INSTALL epel-release && $INSTALL_CMD"
PACKAGES="git cmake libcurl-devel jansson-devel libsodium-devel pkgconf"
PACKAGES_API="libmicrohttpd-devel"
[[ "${{ matrix.config.cmake_args }}" =~ clang|gcc ]] || PACKAGES="$PACKAGES gcc"
;;
alpine:*)
PKG_CACHE_DIR="/var/cache/apk"
INSTALL_CMD="ln -s /var/cache/apk /etc/apk/cache && apk add"
PACKAGES="git build-base cmake argp-standalone curl-dev jansson-dev libsodium-dev"
PACKAGES_API="libmicrohttpd-dev"
;;
archlinux:*)
PKG_CACHE_DIR="/var/cache/pacman"
INSTALL_CMD="pacman -Syu --noconfirm"
PACKAGES="git base-devel cmake curl jansson libsodium"
PACKAGES_API="libmicrohttpd"
;;
clearlinux:*)
PKG_CACHE_DIR="/var/cache/swupd"
INSTALL_CMD="swupd bundle-add"
PACKAGES="git c-basic devpkg-curl devpkg-jansson devpkg-libsodium"
PACKAGES_API="devpkg-libmicrohttpd"
PACKAGES_CLANG="llvm"
PACKAGES_GCC='' # included in c-basic
;;
esac
PACKAGES="$PACKAGES ${{ matrix.config.extra_deps }}"
if [[ "${{ matrix.config.cmake_args }}" =~ ENABLE_API=ON ]]; then
PACKAGES="$PACKAGES $PACKAGES_API"
fi
if [[ "${{ matrix.config.cmake_args }}" =~ CMAKE_C_COMPILER=gcc ]]; then
PACKAGES="$PACKAGES $PACKAGES_GCC"
elif [[ "${{ matrix.config.cmake_args }}" =~ CMAKE_C_COMPILER=clang ]]; then
PACKAGES="$PACKAGES $PACKAGES_CLANG"
fi
CMD="set -ex
find "${PKG_CACHE_DIR}" || ls -d "${PKG_CACHE_DIR}"/* || true
${INSTALL_CMD} ${PACKAGES}
${CLEANUP_CACHE_CMD}
chmod a+rX -R "${PKG_CACHE_DIR}"
find "${PKG_CACHE_DIR}" || ls -d "${PKG_CACHE_DIR}"/* || true
git config --global --add safe.directory /workspace
mkdir -p build
cd build
cmake /workspace -DCMAKE_C_FLAGS='-Wall -Werror' ${{ matrix.config.cmake_args }}
make -j\$(nproc)
"
docker run \
-v ./pkg-cache:"${PKG_CACHE_DIR}" \
-v "${{ github.workspace }}:/workspace":ro \
"${{ matrix.os }}" \
/bin/sh -c "${CMD}"
- name: Save package cache
if: always()
uses: actions/cache/save@v4
with:
path: pkg-cache
key: ${{ matrix.os }}-pkg-cache-${{ github.event_name == 'pull_request' && github.head_ref || 'main' }}-${{ matrix.config.id }}-${{ github.sha }}