-
Notifications
You must be signed in to change notification settings - Fork 2
204 lines (196 loc) · 6.96 KB
/
package.yaml
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# Copyright (C) 2023 Sutou Kouhei <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
name: Package
on:
push:
pull_request:
schedule:
- cron: |
0 0 * * *
concurrency:
group: ${{ github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
source:
if: >-
github.event_name != 'schedule' ||
(github.event_name == 'schedule' &&
github.repository_owner == 'groonga')
name: Source
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Build archive
run: |
rake dist
# Artifact
- uses: actions/upload-artifact@v4
with:
name: source
path: |
groonga-nginx-*.tar.gz
# Release
- name: Upload to release
if: |
startsWith(github.ref, 'refs/tags/')
run: |
ruby \
-e 'print("## groonga-nginx "); \
puts(ARGF.read.split(/^## /)[1]. \
gsub(/ {.+?}/, ""). \
gsub(/\[(.+?)\]\[.+?\]/) {$1})' \
NEWS.md > release-note.md
title="$(head -n1 release-note.md | sed -e 's/^## //')"
tail -n +2 release-note.md > release-note-without-version.md
gh release create ${GITHUB_REF_NAME} \
--discussion-category Announcements \
--notes-file release-note-without-version.md \
--title "${title}" \
groonga-nginx-*.tar.gz
env:
GH_TOKEN: ${{ github.token }}
build:
name: Build
needs: source
strategy:
fail-fast: false
matrix:
include:
- id: debian-bookworm-amd64
task-namespace: apt
test-image: "images:debian/12"
# We can't use Incus for different architecture.
# - id: debian-bookworm-arm64
# task-namespace: apt
# test-image: "images:debian/12/arm64"
runs-on: ubuntu-latest
timeout-minutes: 20
env:
APACHE_ARROW_REPOSITORY: ${{ github.workspace }}/apache-arrow
GROONGA_REPOSITORY: ${{ github.workspace }}/groonga
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
path: apache-arrow
repository: apache/arrow
- uses: actions/checkout@v4
with:
repository: groonga/groonga
path: groonga
submodules: recursive
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y -V \
devscripts \
qemu-user-static \
ruby
- uses: actions/download-artifact@v4
with:
name: source
- name: Update version
if: |
!startsWith(github.ref, 'refs/tags/')
run: |
cd packages
rake version:update RELEASE_DATE=$(date +%Y-%m-%d)
- name: Login to GitHub Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Cache ccache
uses: actions/cache@v4
with:
path: packages/${{ matrix.task-namespace }}/build/${{ matrix.id }}/ccache
key: package-${{ matrix.id }}-ccache-${{ hashFiles('*.c') }}
restore-keys: package-${{ matrix.id }}-ccache-
- name: Prepare target
run: |
target=$(echo ${{ matrix.id }} | sed -e 's/-amd64$//g')
echo "APT_TARGETS=${target}" >> $GITHUB_ENV
echo "YUM_TARGETS=${target}" >> $GITHUB_ENV
- name: Build with docker
run: |
cd packages
rake docker:pull || :
rake ${{ matrix.task-namespace }}:build BUILD_DIR=build
- name: Push the built Docker image
continue-on-error: true
run: |
cd packages
rake docker:push
# Artifact
- uses: actions/upload-artifact@v4
with:
name: packages-${{ matrix.id }}
path: packages/${{ matrix.task-namespace }}/repositories/
# Release
- name: Create assets
if: |
startsWith(github.ref, 'refs/tags/')
run: |
tar czf ${{ matrix.id }}.tar.gz packages/${{ matrix.task-namespace }}/repositories/
- name: Upload to release
if: |
startsWith(github.ref, 'refs/tags/')
run: |
gh release upload ${GITHUB_REF_NAME} \
${{ matrix.id }}.tar.gz
env:
GH_TOKEN: ${{ github.token }}
# Test
- name: Install test dependencies
run: |
# We can use the official Ubuntu APT repository when
# ubuntu-latest is Ubuntu 24.04.
sudo curl -fsSL https://pkgs.zabbly.com/key.asc -o /etc/apt/keyrings/zabbly.asc
cat <<SOURCES | sudo tee /etc/apt/sources.list.d/zabbly-incus-stable.sources
Enabled: yes
Types: deb
URIs: https://pkgs.zabbly.com/incus/stable
Suites: $(. /etc/os-release && echo ${VERSION_CODENAME})
Components: main
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/zabbly.asc
SOURCES
sudo apt update
sudo apt install -y -V incus
- name: Allow egress network traffic flows for Incus
# https://linuxcontainers.org/incus/docs/main/howto/network_bridge_firewalld/#prevent-connectivity-issues-with-incus-and-docker
run: |
sudo iptables -I DOCKER-USER -i incusbr0 -j ACCEPT
sudo iptables -I DOCKER-USER -o incusbr0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
- name: Test
run: |
sudo incus admin init --auto
sudo incus launch ${{ matrix.test-image }} target
sudo incus config device add target host disk source=$PWD path=/host
sudo incus exec target -- adduser --uid 10000 groonga-nginx
sudo incus exec target -- \
sh -c "echo 'groonga-nginx ALL=(ALL:ALL) NOPASSWD:ALL' | \
EDITOR='tee -a' visudo -f /etc/sudoers.d/groonga-nginx-nopasswd"
sudo incus exec target \
--cwd /home/groonga-nginx \
--user 10000 \
--group 10000 \
-- \
/host/packages/${{ matrix.task-namespace }}/test.sh
sudo incus stop target
sudo incus delete target