Skip to content

Commit

Permalink
Add CI for macos and containers (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Congyuwang authored Jul 8, 2023
1 parent 62bcaae commit 3950798
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 123 deletions.
67 changes: 67 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/configuration-reference
version: 2.1

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/configuration-reference/#jobs
jobs:
build:
parameters:
os:
type: string
shared:
type: string
# Specify the execution environment. You can specify an image from Docker Hub or use one of our convenience images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/configuration-reference/#executor-job
docker:
- image: congyuwang/socket-manager-dev:<< parameters.os >>
# Add steps to the job
# See: https://circleci.com/docs/configuration-reference/#steps
steps:
- checkout
- run:
name: "Submodule"
command: git submodule update --init
- run:
name: "Configure CMake"
command: cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=<< parameters.shared >>
- run:
name: "Build"
command: cmake --build build --config Release --verbose
- run:
name: "Test"
command: cd build && ctest -C Release --output-on-failure && cd ..
environment:
SOCKET_LOG: debug
- run:
name: "Install"
command: cmake --install build --config Release
- run:
name: "Test Linking"
command: |
cd tests/test_find_package
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
cd build
./helloworld_server &
# Give the server time to start
sleep 1
rsp=$(curl http://127.0.0.1:49999)
if [[ "$rsp" == "Hello, world" ]]; then
echo "Test passed"
exit 0
else
echo "Test failed"
exit 1
fi
# Orchestrate jobs using workflows
# See: https://circleci.com/docs/configuration-reference/#workflows
workflows:
build-container:
jobs:
- build:
matrix:
parameters:
os: ["jammy", "focal"]
shared: ["ON", "OFF"]
57 changes: 0 additions & 57 deletions .github/workflows/Build-Dev-Container.yml

This file was deleted.

177 changes: 118 additions & 59 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,69 +11,128 @@ env:
BUILD_TYPE: Release

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
build-macos:
runs-on: macos-latest

strategy:
matrix:
shared: ["ON", "OFF"]

steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Install LLVM and Clang
run: brew install llvm@16

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
default: true

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: |
eval "$(brew shellenv)"
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_SHARED_LIBS=${{ matrix.shared }}
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --verbose

- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure
env:
SOCKET_LOG: debug

- name: Install
run: sudo cmake --install build --config Release

- name: Test Linking
working-directory: ${{github.workspace}}/tests/test_find_package
run: |
eval "$(brew shellenv)"
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
cd build
./helloworld_server &
# Give the server time to start
sleep 1
rsp=$(curl http://127.0.0.1:49999)
if [[ "$rsp" == "Hello, world" ]]; then
echo "Test passed"
exit 0
else
echo "Test failed"
exit 1
fi
build-linux:
runs-on: ubuntu-latest

strategy:
matrix:
shared: ["ON", "OFF"]

steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Install LLVM and Clang
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 16 all
chmod +x update-alternatives-clang.sh
sudo ./update-alternatives-clang.sh 16 9999
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
default: true

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_SHARED_LIBS=${{ matrix.shared }}

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --verbose

- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure
env:
SOCKET_LOG: debug

- name: Install
run: sudo cmake --install build --config Release

- name: Test Linking
working-directory: ${{github.workspace}}/tests/test_find_package
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
cd build
./helloworld_server &
rsp=$(curl http://127.0.0.1:49999)
# Give the server time to start
sleep 1
if [[ "$rsp" == "Hello, world" ]]; then
echo "Test passed"
exit 0
else
echo "Test failed"
exit 1
fi
- uses: actions/checkout@v3
with:
submodules: true

- name: Install LLVM and Clang
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 16 all
chmod +x update-alternatives-clang.sh
sudo ./update-alternatives-clang.sh 16 9999
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
default: true

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_SHARED_LIBS=${{ matrix.shared }}

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --verbose

- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure
env:
SOCKET_LOG: debug

- name: Install
run: sudo cmake --install build --config Release

- name: Test Linking
working-directory: ${{github.workspace}}/tests/test_find_package
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
cd build
./helloworld_server &
# Give the server time to start
rsp=$(curl http://127.0.0.1:49999)
sleep 1
if [[ "$rsp" == "Hello, world" ]]; then
echo "Test passed"
exit 0
else
echo "Test failed"
exit 1
fi
6 changes: 5 additions & 1 deletion .github/workflows/Push-Dev-Container.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Push Dev Container

on:
push:
paths:
- dockerfile/**
branches: [ "main" ]
pull_request:
paths:
- dockerfile/**
Expand Down Expand Up @@ -50,7 +54,7 @@ jobs:
with:
context: .
file: ./dockerfile/dev-containers/jammy/Dockerfile
push: false
push: true
tags: congyuwang/socket-manager-dev:jammy
cache-from: type=registry,ref=congyuwang/socket-manager-dev:jammy
cache-to: type=inline
4 changes: 1 addition & 3 deletions dockerfile/dev-containers/focal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ RUN rm update-alternatives-clang.sh
#ARG RUSTUP_UPDATE_ROOT="https://mirrors.ustc.edu.cn/rust-static/rustup"
#ARG RUSTUP_DIST_SERVER="https://mirrors.tuna.tsinghua.edu.cn/rustup"
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly

# default sh to bash
RUN chsh -s /bin/bash
ENV PATH="/root/.cargo/bin:${PATH}"

ENTRYPOINT ["/bin/bash"]
4 changes: 1 addition & 3 deletions dockerfile/dev-containers/jammy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ RUN rm update-alternatives-clang.sh
#ARG RUSTUP_UPDATE_ROOT="https://mirrors.ustc.edu.cn/rust-static/rustup"
#ARG RUSTUP_DIST_SERVER="https://mirrors.tuna.tsinghua.edu.cn/rustup"
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly

# default sh to bash
RUN chsh -s /bin/bash
ENV PATH="/root/.cargo/bin:${PATH}"

ENTRYPOINT ["/bin/bash"]

0 comments on commit 3950798

Please sign in to comment.