From 3836d1480b3b9e9a773464d895ce4ffc2182537d Mon Sep 17 00:00:00 2001 From: Konstantin Lampalzer Date: Mon, 23 Sep 2024 13:34:34 +0200 Subject: [PATCH] ci: add packing job --- .dockerignore | 2 +- .github/workflows/ci.yaml | 38 ---------------------------------- .github/workflows/package.yaml | 29 ++++++++++++++++++++++++++ .github/workflows/test.yaml | 30 +++++++++++++++++++++++++++ ci/Dockerfile | 7 ++----- ci/entrypoint.sh | 10 +++++++++ 6 files changed, 72 insertions(+), 44 deletions(-) delete mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/package.yaml create mode 100644 .github/workflows/test.yaml create mode 100755 ci/entrypoint.sh diff --git a/.dockerignore b/.dockerignore index 7846b39..d71d4b3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,2 @@ .github -ci \ No newline at end of file +ci/Dockerfile \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index 7fb7d18..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,38 +0,0 @@ -name: Build and test - -on: - push: - branches: ['master'] - pull_request: - -env: - BUILD_TYPE: Release - -jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04, ubuntu-22.04] - - steps: - - name: Install dependencies - run: | - sudo apt install build-essential cmake git libboost-system-dev libboost-thread-dev - git clone https://github.com/google/googletest.git - cd googletest - cmake CMakeLists.txt - make - sudo make install - - - uses: actions/checkout@v2 - - - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_FLAGS="-Werror" - - - name: Build - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} - - - name: Test - working-directory: ${{github.workspace}}/build - run: ctest -C ${{env.BUILD_TYPE}} diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml new file mode 100644 index 0000000..bbc7e80 --- /dev/null +++ b/.github/workflows/package.yaml @@ -0,0 +1,29 @@ +name: Package + +on: + push: + +jobs: + package: + runs-on: ubuntu-24.04 + strategy: + matrix: + platform: [linux/arm64/v8] + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + platforms: linux/arm64 + + - name: Prepare container + run: docker buildx build -f ci/Dockerfile . -t libcreate --platform ${{ matrix.platform }} --load + - name: Build + run: docker run --platform ${{ matrix.platform }} -v ./output:/libcreate/_packages libcreate diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..986dc29 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,30 @@ +name: Build and test + +on: + push: + branches: ["master"] + pull_request: + +env: + BUILD_TYPE: Release + +jobs: + test: + runs-on: ubuntu-24.04 + + steps: + - name: Install dependencies + run: | + sudo apt install build-essential cmake git libboost-system-dev libboost-thread-dev file libgtest-dev googletest + + - uses: actions/checkout@v4 + + - name: Configure CMake + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_FLAGS="-Werror" + + - name: Build + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Test + working-directory: ${{github.workspace}}/build + run: ctest -C ${{env.BUILD_TYPE}} diff --git a/ci/Dockerfile b/ci/Dockerfile index c303ca9..6516bf9 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:24.04 RUN apt update && \ apt install -y \ - build-essential cmake file \ + build-essential cmake git file \ libboost-system-dev libboost-thread-dev \ libgtest-dev googletest && \ rm -rf /var/lib/apt/lists/* @@ -11,7 +11,4 @@ WORKDIR /libcreate COPY . . WORKDIR /libcreate/build -RUN cmake -B /libcreate/build -S /libcreate -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-Werror" && \ - cmake --build /libcreate/build --config Release && \ - ctest -C Release --output-on-failure && \ - cpack --build /libcreate/build -G DEB +ENTRYPOINT ["/bin/bash", "/libcreate/ci/entrypoint.sh"] diff --git a/ci/entrypoint.sh b/ci/entrypoint.sh new file mode 100755 index 0000000..c371918 --- /dev/null +++ b/ci/entrypoint.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + +cmake -B /libcreate/build -S /libcreate -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS='-Werror' +cmake --build /libcreate/build --config Release +ctest -C Release --output-on-failure +cpack --build /libcreate/build -G DEB \ No newline at end of file