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

CI: Use Docker for CI #46

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Build directory

builddir/

# Irrelevant files

.github/
.clang-format
.gitignore
LICENSE
*/*/*.md

# Dockerfiles

*/*/*Dockerfile
*/*/*Dockerfile.in
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test

on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
cfg:
- { id: ubuntu-gcc, platform: ubuntu, cc: gcc, cpp: g++, setup_options: ""}
- { id: ubuntu-gcc-sanitize, platform: ubuntu, cc: gcc, cpp: g++, setup_options: "-Db_sanitize=address,undefined"}
- { id: ubuntu-clang, platform: ubuntu, cc: clang, cpp: clang++, setup_options: ""}
- { id: rockylinux-gcc, platform: ubuntu, cc: gcc, cpp: g++, setup_options: ""}
- { id: rockylinux-gcc-sanitize, platform: ubuntu, cc: gcc, cpp: g++, setup_options: "-Db_sanitize=address,undefined"}
- { id: rockylinux-clang, platform: ubuntu, cc: clang, cpp: clang++, setup_options: ""}

steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: false
load: true
tags: ${{ matrix.cfg.id }}
file: tests/docker/${{ matrix.cfg.platform }}.Dockerfile
build-args: |
cc=${{ matrix.cfg.cc }}
cxx=${{ matrix.cfg.cpp }}
setup_options=${{ matrix.cfg.setup_options }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run tests
run: |
docker run ${{ matrix.cfg.id }} ninja -C builddir test
49 changes: 0 additions & 49 deletions .github/workflows/ubuntu.yml

This file was deleted.

40 changes: 40 additions & 0 deletions tests/docker/rockylinux.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM rockylinux:9

# Enable EPEL
RUN dnf update -y
RUN dnf install -y 'dnf-command(config-manager)'
RUN dnf config-manager --set-enabled crb -y
RUN dnf install epel-release -y

# Install dependencies
RUN dnf install -y \
python3.11 \
python3-pip \
ccache \
clang \
g++ \
ninja-build \
cmake \
jsoncpp-devel \
expected-devel \
gtest-devel \
fmt-devel \
cxxopts-devel
RUN dnf clean all
RUN update-alternatives --install /usr/local/bin/python python /usr/bin/python3.11 10
# Install meson from pip
RUN python3 -m pip install -U meson

# Copy code
WORKDIR /workarea
COPY ./ ./

ARG cc=gcc
ARG cxx=g++
ARG setup_options=

# Build cps-config and tests
ENV CC="ccache $cc" CXX="ccache $cxx"
ENV CCACHE_DIR=/ccache
RUN meson setup builddir $setup_options
RUN --mount=type=cache,target=/ccache/ ninja -C builddir
35 changes: 35 additions & 0 deletions tests/docker/ubuntu.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM ubuntu:22.04

# Install dependencies
RUN apt-get update
RUN apt-get install -y \
python3.11 \
python3-pip \
ccache \
clang \
g++ \
ninja-build \
cmake \
libjsoncpp-dev \
libexpected-dev \
libgtest-dev \
libfmt-dev \
libcxxopts-dev
RUN apt-get clean
RUN update-alternatives --install /usr/local/bin/python python /usr/bin/python3.11 10
# Install meson from pip
RUN python3 -m pip install -U meson

# Copy code
WORKDIR /workarea
COPY ./ ./

ARG cc=gcc
ARG cxx=g++
ARG setup_options=

# Build cps-config and tests
ENV CC="ccache $cc" CXX="ccache $cxx"
ENV CCACHE_DIR=/ccache
RUN meson setup builddir $setup_options
RUN --mount=type=cache,target=/ccache/ ninja -C builddir
Loading