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

Add CI for macos and containers #16

Merged
merged 27 commits into from
Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e19ded5
add CI for macos and containers
Congyuwang Jul 8, 2023
b5acf38
Set up Homebrew
Congyuwang Jul 8, 2023
6768aed
remove installing llvm & clang from ubuntu container build
Congyuwang Jul 8, 2023
427f4b9
skip error in macos brew install llvm@16
Congyuwang Jul 8, 2023
727a815
rename CI name
Congyuwang Jul 8, 2023
8b5d2cb
add HOME env in dockerfile
Congyuwang Jul 8, 2023
f065b0e
update docker image also on PR
Congyuwang Jul 8, 2023
02fa5b7
remove chsh
Congyuwang Jul 8, 2023
848db05
add Rust_COMPILER since HOME is changed
Congyuwang Jul 8, 2023
eef4956
use container env
Congyuwang Jul 8, 2023
c1a833b
attempt workaround $HOME
Congyuwang Jul 8, 2023
64e8437
add cargo bin to PATH
Congyuwang Jul 8, 2023
bad9b7a
remove the unhelpful workaround
Congyuwang Jul 8, 2023
1904575
fix invalid yml format in action
Congyuwang Jul 8, 2023
905d4ee
fix invalid action yml
Congyuwang Jul 8, 2023
da8c018
Use circle-ci to build in container
Congyuwang Jul 8, 2023
0d452e9
Install Homebrew in MacOS
Congyuwang Jul 8, 2023
45d6741
merge with remote
Congyuwang Jul 8, 2023
4b77ad4
attempt to use bash to get brew env var
Congyuwang Jul 8, 2023
f50982b
Run brew shellenv before cmake
Congyuwang Jul 8, 2023
8f79103
Amend previous commit
Congyuwang Jul 8, 2023
6a422a9
Use bash c to run brew shellenv
Congyuwang Jul 8, 2023
99d4583
Use eval in stead of bash c
Congyuwang Jul 8, 2023
f61c88e
Fix macOS linking test cmake
Congyuwang Jul 8, 2023
870b54b
Fix
Congyuwang Jul 8, 2023
3c7e7fa
Fix sleep order in linking test
Congyuwang Jul 8, 2023
f59c818
Add Container Build Test in Circle CI (#17)
Congyuwang Jul 8, 2023
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 .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"]
Loading