mirror of
https://github.com/mchernigin/libqbase.git
synced 2024-12-22 09:33:53 +03:00
build: add Dockerfile and ci
This commit is contained in:
parent
8a980e3317
commit
1d59ec20ed
42
.github/workflows/build-container.yml
vendored
Normal file
42
.github/workflows/build-container.yml
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
name: baselib-container
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
distr:
|
||||
description: "Linux distribution"
|
||||
type: string
|
||||
required: true
|
||||
architecture:
|
||||
description: "Architecture"
|
||||
type: string
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
baselib-build-container:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
if: github.ref == 'refs/heads/main'
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
if: github.ref == 'refs/heads/main'
|
||||
run: |
|
||||
docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.github_token }}
|
||||
|
||||
- name: Build container
|
||||
if: github.ref == 'refs/heads/main'
|
||||
run: |
|
||||
docker buildx build -t ghcr.io/${{ github.repository }}-${{ inputs.architecture }}:${{ github.run_number }} \
|
||||
-t ghcr.io/${{ github.repository }}-${{ inputs.architecture }}:latest \
|
||||
--cache-from type=gha,scope=$GITHUB_REF_NAME-${{ inputs.architecture }}-image \
|
||||
--cache-to type=gha,mode=max,scope=$GITHUB_REF_NAME-${{ inputs.architecture }}-image \
|
||||
--build-arg DISTR=${{ inputs.distr }} --build-arg ARCH=${{ inputs.architecture }} \
|
||||
--build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) --platform ${{ inputs.architecture }} .
|
||||
|
||||
- name: Push container
|
||||
if: github.ref == 'refs/heads/main'
|
||||
run: |
|
||||
docker push -a ghcr.io/${{ github.repository }}-${{ inputs.architecture }}
|
41
.github/workflows/build.yml
vendored
Normal file
41
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
name: baselib-build
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
artifact:
|
||||
description: "Artifact"
|
||||
type: string
|
||||
required: true
|
||||
architecture:
|
||||
description: "Architecture"
|
||||
type: string
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
baselib-build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Build baselib packages
|
||||
run: |
|
||||
docker pull --platform linux/${{ inputs.architecture }} \
|
||||
ghcr.io/${{ github.repository }}-${{ inputs.architecture }}:latest
|
||||
docker run --privileged=true --name baselib-build-${{ inputs.architecture }} -i --log-driver=none \
|
||||
-a stdin -a stdout -a stderr -v "$(pwd)":/app --platform linux/${{ inputs.architecture }} \
|
||||
ghcr.io/${{ github.repository }}-${{ inputs.architecture }}:latest
|
||||
|
||||
- name: Extract fresh packages
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
docker cp baselib-build-${{ inputs.architecture }}:/home/builder2/RPM/RPMS/ "$(pwd)/packages"
|
||||
|
||||
- name: Upload fresh RPM packages
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: baselib-${{ inputs.artifact }}-${{ inputs.architecture }}
|
||||
path: ${{ github.workspace }}/packages
|
39
.github/workflows/main.yml
vendored
Normal file
39
.github/workflows/main.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
name: baselib-ci
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
push:
|
||||
branches: [ "*" ]
|
||||
pull_request:
|
||||
types: [ opened, synchronize, ready_for_review ]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
baselib-build-container:
|
||||
uses: ./.github/workflows/build-container.yml
|
||||
secrets: inherit
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ { distr: "alt:sisyphus", artifact: "sisyphus" } ]
|
||||
architecture: [ amd64, i386 ]
|
||||
with:
|
||||
distr: ${{ matrix.os.distr }}
|
||||
architecture: ${{ matrix.architecture }}
|
||||
|
||||
baselib-build:
|
||||
uses: ./.github/workflows/build.yml
|
||||
needs: [ baselib-build-container ]
|
||||
secrets: inherit
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ { distr: "alt:sisyphus", artifact: "sisyphus" } ]
|
||||
architecture: [ amd64, i386 ]
|
||||
fail-fast: false
|
||||
with:
|
||||
artifact: ${{ matrix.os.artifact }}
|
||||
architecture: ${{ matrix.architecture }}
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
||||
.*
|
||||
!.gitignore
|
||||
!.github
|
||||
!.gear
|
||||
|
||||
build
|
||||
|
@ -6,6 +6,7 @@ project(baselib
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
|
72
Dockerfile
Normal file
72
Dockerfile
Normal file
@ -0,0 +1,72 @@
|
||||
ARG DISTR
|
||||
|
||||
# Container image that runs your code
|
||||
FROM $DISTR
|
||||
|
||||
ARG USER_ID
|
||||
ARG GROUP_ID
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y git \
|
||||
gear \
|
||||
hasher \
|
||||
hasher-priv \
|
||||
hasher-rich-chroot \
|
||||
hasher-rich-chroot-user-utils \
|
||||
rpm-utils \
|
||||
rpm-build \
|
||||
rpm-build-licenses \
|
||||
rpm-macros-cmake \
|
||||
rpm-macros-make \
|
||||
rpm-macros-generic-compat \
|
||||
apt-repo \
|
||||
apt-repo-tools \
|
||||
cmake \
|
||||
rpm-macros-cmake \
|
||||
cmake-modules \
|
||||
gcc-c++ \
|
||||
qt5-base-devel \
|
||||
qt5-declarative-devel \
|
||||
qt5-tools-devel \
|
||||
libsmbclient-devel \
|
||||
libsmbclient \
|
||||
qt5-base-common \
|
||||
doxygen \
|
||||
xorg-xvfb \
|
||||
xvfb-run \
|
||||
sudo \
|
||||
&& export CURRENT_PWD=`pwd` \
|
||||
&& if [ $(getent group $GROUP_ID) ]; then \
|
||||
echo "group $GROUP_ID exists."; \
|
||||
else \
|
||||
groupadd --gid $GROUP_ID builder2; \
|
||||
fi \
|
||||
&& useradd --uid $USER_ID --gid $GROUP_ID -ms /bin/bash builder2 \
|
||||
&& groupadd sudo \
|
||||
&& usermod -aG rpm builder2 \
|
||||
&& usermod -aG sudo root \
|
||||
&& usermod -aG sudo builder2 \
|
||||
&& echo "root ALL=(ALL) NOPASSWD:ALL" | tee -a /etc/sudoers \
|
||||
&& echo "builder2 ALL=(ALL) NOPASSWD:ALL" | tee -a /etc/sudoers \
|
||||
&& hasher-useradd builder2 || : \
|
||||
&& mkdir /app \
|
||||
&& chown $USER_ID:$GROUP_ID /app
|
||||
|
||||
# Copies your code file from your action repository to the filesystem path `/` of the container
|
||||
# COPY script/build.sh /build.sh
|
||||
|
||||
RUN echo -e "#!/bin/sh -ex\nchown -R builder2 /app/\ncd /app/ && gear-rpm -ba" \
|
||||
> /build.sh \
|
||||
&& chmod +x ./build.sh
|
||||
|
||||
ARG ARCH
|
||||
|
||||
RUN if [ "$ARCH" = "i386" ]; then \
|
||||
sed -i 's/gear-rpm -ba/gear-rpm -ba --target=i386/g' build.sh; \
|
||||
fi
|
||||
|
||||
USER builder2
|
||||
WORKDIR /home/builder2
|
||||
|
||||
# Code file to execute when the docker container starts up (`build.sh`)
|
||||
ENTRYPOINT ["/build.sh"]
|
@ -1 +1,20 @@
|
||||
# set compiler options
|
||||
if (CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "e2k")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undef -fvisibility=default -pedantic -Wall")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undef -fvisibility=hidden -fvisibility-inlines-hidden -pedantic -Wall\
|
||||
-Wextra -Wno-long-long -Weffc++ -Werror -Wall -Wextra -pedantic -Wcast-align -Wcast-qual -Wctor-dtor-privacy \
|
||||
-Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wnoexcept -Wold-style-cast \
|
||||
-Woverloaded-virtual -Wredundant-decls -Wshadow -Wstrict-null-sentinel -Wundef \
|
||||
-Wno-unused -Wno-variadic-macros -Wno-parentheses -fdiagnostics-show-option")
|
||||
if(CMAKE_SIZEOF_VOID_P LESS_EQUAL 4)
|
||||
CHECK_CXX_COMPILER_FLAG("-march=i586" COMPILER_SUPPORTS_MARCH_I586)
|
||||
if (${COMPILER_SUPPORTS_MARCH_I586})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i586")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(logger)
|
||||
|
Loading…
Reference in New Issue
Block a user