Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build .deb packages on CI #2

Open
wants to merge 28 commits into
base: ferretdb
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
89a90d1
Build `.deb` packages on CI
AlekSi Jan 28, 2025
05b4b61
use ferretdb_packaging dir
chilagrow Feb 11, 2025
62e5919
update file name
chilagrow Feb 11, 2025
961e787
update more dir name
chilagrow Feb 11, 2025
a708917
set pre-release version with branch and commit
chilagrow Feb 12, 2025
e7320b9
test install on most recent package
chilagrow Feb 12, 2025
f42a401
build pre-release version from CI
chilagrow Feb 12, 2025
bc88162
copy tag check
chilagrow Feb 13, 2025
bd45078
tailor it to version check
chilagrow Feb 13, 2025
eeac45f
update workflow to get version from tags
chilagrow Feb 14, 2025
656ccab
add go tests to CI
chilagrow Feb 14, 2025
76badbc
change CI runner
chilagrow Feb 14, 2025
2ae4f93
update CI config
chilagrow Feb 14, 2025
7fb22bb
update go main file
chilagrow Feb 14, 2025
b225bda
set id on tag CI
chilagrow Feb 14, 2025
95d8829
debian version does not like -
chilagrow Feb 14, 2025
e7ce59f
only handle major minor patch for now
chilagrow Feb 14, 2025
5db2030
use tilde for PR names
chilagrow Feb 14, 2025
efd8ea2
cleanup
chilagrow Feb 14, 2025
ad66991
go code comment
chilagrow Feb 14, 2025
5306cf4
Merge branch 'ferretdb' into ci
AlekSi Feb 17, 2025
6d23ece
handle ferretdb targetted version
chilagrow Feb 18, 2025
a69efd3
dash not allowed use ~
chilagrow Feb 18, 2025
b9e6285
get defineversion change
chilagrow Feb 19, 2025
e499834
get go workflow
chilagrow Feb 19, 2025
fd151af
update check and helper
chilagrow Feb 19, 2025
5df5afe
update branch versioning
chilagrow Feb 19, 2025
30bc785
test uses python3
chilagrow Feb 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/ferretdb_go_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
name: Go
on:
pull_request:
types:
- unlabeled # if GitHub Actions stuck, add and remove "not ready" label to force rebuild
- opened
- reopened
- synchronize
push:
branches:
- main
- ferretdb
schedule:
- cron: "12 0 * * *"

env:
GOPATH: /home/runner/go
GOCACHE: /home/runner/go/cache
GOLANGCI_LINT_CACHE: /home/runner/go/cache/lint
GOMODCACHE: /home/runner/go/mod
GOPROXY: https://proxy.golang.org
GOTOOLCHAIN: local

jobs:
test:
name: Test

# CI cannot find ubicloud-standard-4 runner and displays the following message:
# `Waiting for a runner to pick up this job...`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't get runs-on: ubicloud-standard-4 to start job, it was waiting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be resolved now, let's use Ubicloud

#
# https://www.ubicloud.com/docs/about/pricing#github-actions
# https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#per-minute-rates-for-larger-runners
# runs-on: ubicloud-standard-4

runs-on: ubuntu-24.04

timeout-minutes: 15

# Do not run this job in parallel for any PR change or branch push.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

if: github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'not ready')

steps:
# TODO https://github.com/FerretDB/github-actions/issues/211
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: FerretDB/github-actions/setup-go@main

- name: Run tests
run: |
cd ferretdb_packaging
go mod tidy
go mod verify
go test ./...

- name: Check dirty
if: always()
run: |
git status --untracked-files --ignored
git status
git diff --exit-code
94 changes: 94 additions & 0 deletions .github/workflows/ferretdb_packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
name: Packages
on:
pull_request:
types:
- unlabeled # if GitHub Actions stuck, add and remove "not ready" label to force rebuild
- opened
- reopened
- synchronize
push:
branches:
- main
- ferretdb
tags:
- "*"
schedule:
- cron: "10 8 * * 1"

env:
GOPATH: /home/runner/go
GOCACHE: /home/runner/go/cache
GOLANGCI_LINT_CACHE: /home/runner/go/cache/lint
GOMODCACHE: /home/runner/go/mod
GOPROXY: https://proxy.golang.org
GOTOOLCHAIN: local

# Do not run this workflow in parallel for any PR change or branch/tag push
# to save some resources.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: false

jobs:
build:
name: Build .debs (${{ matrix.os }}, Pg${{ matrix.pg }})

# CI cannot find ubicloud-standard-4 runner and displays the following message:
# `Waiting for a runner to pick up this job...`
#
# https://www.ubicloud.com/docs/about/pricing#github-actions
# https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#per-minute-rates-for-larger-runners
# runs-on: ubicloud-standard-4

runs-on: ubuntu-24.04

timeout-minutes: 40

if: >
github.event_name != 'pull_request' ||
(
!contains(github.event.pull_request.labels.*.name, 'not ready') &&
contains(github.event.pull_request.labels.*.name, 'packages')
)

strategy:
fail-fast: false
matrix:
os: [deb11, deb12, ubuntu20.04, ubuntu22.04, ubuntu24.04]
pg: [15, 16]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: FerretDB/github-actions/setup-go@main

- name: Define package tag version
id: tag
run: |
cd ferretdb_packaging
go mod tidy
go mod verify
go build -v -o=bin/ ./defineversion
bin/defineversion --control-file ../pg_documentdb_core/documentdb_core.control

- name: Build ${{ steps.tag.outputs.version }}
if: steps.tag.outputs.version != ''
run: ./ferretdb_packaging/build_packages.sh --os ${{ matrix.os }} --pg ${{ matrix.pg }} --version ${{ steps.tag.outputs.version }} --test-clean-install

- name: Upload
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.pg }}-debs
path: packaging/*.deb
retention-days: 1
if-no-files-found: error
compression-level: 0
overwrite: false
Copy link
Member Author

@chilagrow chilagrow Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example one built on CI.

$ dpkg-deb -I ~/Downloads/postgresql-16-documentdb_0.101.0~pr~ci_amd64.deb 
 new Debian package, version 2.0.
 size 3829360 bytes: control archive=5076 bytes.
     368 bytes,    10 lines      control              
   18925 bytes,   164 lines      md5sums              
 Package: postgresql-16-documentdb
 Source: documentdb
 Version: 0.101.0~pr~ci
 Architecture: amd64
 Maintainer: FerretDB Packages <[email protected]>
 Installed-Size: 10457
 Depends: libc6 (>= 2.34), libpq5, postgresql-16, postgresql-16-cron, postgresql-16-pgvector, postgresql-16-postgis-3, postgresql-16-rum
 Section: database
 Priority: optional
 Description: DOCUMENTDB


- name: Check dirty
run: |
git status
git diff --exit-code
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
*.idb
*.pdb

# FerretDB packaging
!*go.mod
*.deb
/bin

# Kernel Module Compile Results
*.mod*
*.cmd
Expand Down
79 changes: 79 additions & 0 deletions ferretdb_packaging/Dockerfile_build_deb_packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
ARG BASE_IMAGE=debian:bookworm
FROM --platform=linux/amd64 ${BASE_IMAGE}
ARG DEBIAN_FRONTEND=noninteractive

ARG POSTGRES_VERSION=16
ARG DOCUMENTDB_VERSION=''

RUN apt-get update

RUN apt-get install -y --no-install-recommends \
wget \
gnupg2 \
lsb-release \
ca-certificates \
locales

RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
locale-gen en_US.UTF-8

ENV LC_ALL=en_US.UTF-8
ENV LANGUAGE=en_US
ENV LC_COLLATE=en_US.UTF-8
ENV LC_CTYPE=en_US.UTF-8
ENV LANG=en_US.UTF-8

RUN echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main ${POSTGRES_VERSION}" > /etc/apt/sources.list.d/pgdg.list && \
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -

RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
tzdata \
build-essential \
pkg-config \
cmake \
git \
postgresql-${POSTGRES_VERSION} \
postgresql-server-dev-${POSTGRES_VERSION} \
libpq-dev \
libicu-dev \
libkrb5-dev \
postgresql-${POSTGRES_VERSION}-cron \
postgresql-${POSTGRES_VERSION}-pgvector \
postgresql-${POSTGRES_VERSION}-postgis-3 \
postgresql-${POSTGRES_VERSION}-rum \
devscripts \
debhelper \
dpkg-dev \
&& rm -rf /var/lib/apt/lists/*

COPY scripts /tmp/install_setup

RUN CLEAN_SETUP=1 INSTALL_DEPENDENCIES_ROOT=/tmp/install_setup /tmp/install_setup/install_setup_pcre2.sh
RUN CLEAN_SETUP=1 INSTALL_DEPENDENCIES_ROOT=/tmp/install_setup /tmp/install_setup/install_setup_intel_decimal_math_lib.sh
RUN CLEAN_SETUP=1 INSTALL_DEPENDENCIES_ROOT=/tmp/install_setup /tmp/install_setup/install_citus_indent.sh

RUN export CLEAN_SETUP=1 && \
export INSTALL_DEPENDENCIES_ROOT=/tmp/install_setup && \
MAKE_PROGRAM=cmake /tmp/install_setup/install_setup_libbson.sh && \
/tmp/install_setup/install_setup_pcre2.sh && \
/tmp/install_setup/install_setup_intel_decimal_math_lib.sh && \
/tmp/install_setup/install_citus_indent.sh

# Set the working directory inside the container
WORKDIR /build

# Copy the source code into the container
COPY . /build

RUN test -n "$DOCUMENTDB_VERSION" || (echo "DOCUMENTDB_VERSION not set" && false)

# Setup the debian packaging
COPY ferretdb_packaging/debian_files /build/debian
RUN sed -i "s/POSTGRES_VERSION/${POSTGRES_VERSION}/g" /build/debian/control
RUN sed -i "s/DOCUMENTDB_VERSION/${DOCUMENTDB_VERSION}/g" /build/debian/changelog

COPY ferretdb_packaging/packaging-entrypoint.sh /usr/local/bin/packaging-entrypoint.sh

# Set the entrypoint
ENTRYPOINT ["packaging-entrypoint.sh"]
10 changes: 10 additions & 0 deletions ferretdb_packaging/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# To Build Your Own Debian Packages With Docker
Run `./ferretdb_packaging/build_packages.sh -h` and follow the instructions.
E.g. to build for Debian 12 and PostgreSQL 16 for 0.100.0 version, run:
```
./ferretdb_packaging/build_packages.sh --os deb12 --pg 16 --version 0.100.0
```

Packages can be found at the `packages` directory by default, but that can be configured with the `--output-dir` option.

**Note:** The packages do not include pg_documentdb_distributed in the `internal` directory.
Loading
Loading