From 49851c09af8a9e592011dc1105c05b19b7e868ec Mon Sep 17 00:00:00 2001 From: Nicolas Vanhoren Date: Wed, 1 Dec 2021 22:20:07 +0100 Subject: [PATCH 1/3] Replaced Drone CI configuration by Github Actions. Added multiple different build targets. Adjusted configuration. --- .drone.yml | 54 ---------------- .github/workflows/build.yml | 119 ++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 2 +- README.md | 46 +++++++------- 4 files changed, 145 insertions(+), 76 deletions(-) delete mode 100644 .drone.yml create mode 100644 .github/workflows/build.yml diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index c2aba4f..0000000 --- a/.drone.yml +++ /dev/null @@ -1,54 +0,0 @@ -kind: pipeline -name: default - -steps: -- name: musl - image: alpine:latest - volumes: - - name: dist - path: /dist - commands: - - apk update - - apk add bats gcc make musl-dev cmake - - mkdir -p build - - cmake . - - cmake --build . - - bats tests.bats - - tar czvf /dist/multirun-musl-${DRONE_TAG:-not_tagged}.tar.gz multirun - -- name: glibc - image: gcc - volumes: - - name: dist - path: /dist - commands: - - apt-get update - - apt-get install -y bats cmake - - echo "check if there is anything left" - - mkdir -p build - - cmake . - - cmake --build . - - bats tests.bats - - tar czvf /dist/multirun-glibc-${DRONE_TAG:-not_tagged}.tar.gz multirun - -- name: publish - image: plugins/github-release - volumes: - - name: dist - path: /dist - settings: - api_key: - from_secret: github_token - files: /dist/*.tar.gz - checksum: - - sha256 - - sha512 - - adler32 - - crc32 - when: - event: - - tag - -volumes: -- name: dist - temp: {} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..2c4ae0a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,119 @@ +name: Build + +on: + push: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Install and configure dependencies + run: | + sudo apt-get install -qq bats + - uses: actions/checkout@v2 + - name: Build + run: | + cmake . + cmake --build . + - name: Test + run: bats tests.bats + + build: + strategy: + fail-fast: false + matrix: + include: + - TARGET: x86_64-linux-gnu # the native build, tested in a container on a mac + OS: ubuntu-latest + CC: cc + - TARGET: x86_64-linux-musl # tested in an alpine container on a mac + OS: ubuntu-latest + CC: x86_64-linux-musl-gcc + - TARGET: aarch64-linux-gnu # tested on aws t4g.nano + OS: ubuntu-latest + CC: aarch64-linux-gnu-gcc + - TARGET: aarch64-linux-musl # tested in an alpine container on aws t4g.nano + OS: ubuntu-latest + CC: aarch64-linux-musl-gcc + - TARGET: arm-linux-gnueabihf # tested on a Raspberry Pi 400 + OS: ubuntu-latest + CC: arm-linux-gnueabihf-gcc + - TARGET: arm-linux-musl # tested in an alphine container on a Raspberry Pi 400 + OS: ubuntu-latest + CC: arm-linux-musleabihf-gcc + - TARGET: x86_64-apple-darwin # tested on a mac, is not properly signed so there are security warnings + OS: macos-latest + CC: cc + needs: test + runs-on: ${{ matrix.OS }} + env: + NAME: multirun + TARGET: ${{ matrix.TARGET }} + OS: ${{ matrix.OS }} + CC: ${{ matrix.CC }} + steps: + - name: Musl compilers cache + uses: actions/cache@v2 + with: + path: | + ~/musl-compilers + key: build-musl-compilers-dir + - name: Install and configure dependencies + run: | + # dependencies are only needed on ubuntu as that's the only place where + # we make cross-compilation + if [[ $OS =~ ^ubuntu.*$ ]]; then + sudo apt-get install -qq crossbuild-essential-arm64 crossbuild-essential-armhf + fi + # download musl compilers + mkdir -p $HOME/musl-compilers + pushd $HOME/musl-compilers + if [[ ! -d x86_64-linux-musl-cross ]]; then + wget -q -c http://musl.cc/x86_64-linux-musl-cross.tgz -O - | tar -xz + fi + if [[ ! -d aarch64-linux-musl-cross ]]; then + wget -q -c http://musl.cc/aarch64-linux-musl-cross.tgz -O - | tar -xz + fi + if [[ ! -d arm-linux-musleabihf-cross ]]; then + wget -q -c http://musl.cc/arm-linux-musleabihf-cross.tgz -O - | tar -xz + fi + popd + - uses: actions/checkout@v2 + - name: List + run: find . + - name: Build + run: | + export PATH=$PATH:$HOME/musl-compilers/x86_64-linux-musl-cross/bin + export PATH=$PATH:$HOME/musl-compilers/aarch64-linux-musl-cross/bin + export PATH=$PATH:$HOME/musl-compilers/arm-linux-musleabihf-cross/bin + cmake . + cmake --build . + - name: Compress + run: | + mkdir -p ./artifacts + tar -czf ./artifacts/$NAME-$TARGET-${{github.ref_name}}.tar.gz $NAME + - name: Archive artifact + uses: actions/upload-artifact@v2 + with: + name: result + path: | + ./artifacts + + # deploys to github releases on tag + deploy: + if: startsWith(github.ref, 'refs/tags/') + needs: build + runs-on: ubuntu-latest + steps: + - name: Download artifacts + uses: actions/download-artifact@v2 + with: + name: result + path: ./artifacts + - name: List + run: find ./artifacts + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: ./artifacts/*.tar.gz diff --git a/CMakeLists.txt b/CMakeLists.txt index 12456ca..7e1bd1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10) set(CMAKE_C_STANDARD 99) # set the project name -project(multirun VERSION 1.0.0 LANGUAGES C) +project(multirun VERSION 1.0.1 LANGUAGES C) configure_file(config.h.in config.h) diff --git a/README.md b/README.md index e4057c5..3d17fdf 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # multirun -[![Build Status](https://cloud.drone.io/api/badges/nicolas-van/multirun/status.svg)](https://cloud.drone.io/nicolas-van/multirun) +[![Build](https://github.com/nicolas-van/multirun/actions/workflows/build.yml/badge.svg)](https://github.com/nicolas-van/multirun/actions/workflows/build.yml) A simple Unix utility in C to run multiple commands concurrently. @@ -20,44 +20,48 @@ Unlink most process managers multirun never attempts to restart one of its child ## Installation -### Alpine +### Package manager -#### Package manager +Currently, multirun is only present in Alpine's distribution -```bash -apk add multirun -``` +#### Alpine -#### Binary install ```bash -wget https://github.com/nicolas-van/multirun/releases/download/1.0.0/multirun-musl-1.0.0.tar.gz && \ -tar -zxvf multirun-musl-1.0.0.tar.gz && \ -mv multirun /bin && \ -rm multirun-musl-1.0.0.tar.gz +apk add multirun ``` -### Ubuntu, Debian, Red Hat, Centos... +### Binary install -#### Binary install +The [release page](https://github.com/nicolas-van/multirun/releases) lists all provided binaries. + +Here is an example install script for an x86_64 Linux using GNU libc. Replace the URL with another one if you use another system. ```bash -wget https://github.com/nicolas-van/multirun/releases/download/1.0.0/multirun-glibc-1.0.0.tar.gz && \ -tar -zxvf multirun-glibc-1.0.0.tar.gz && \ -mv multirun /bin && \ -rm multirun-glibc-1.0.0.tar.gz +wget -c https://github.com/nicolas-van/multirun/releases/download/1.0.1/multirun-x86_64-linux-gnu-1.0.1.tar.gz -O - | tar -xz && \ +mv multirun /bin ``` +We provide binaries for the following systems: + +* x86_64 Linux, both using glibc (for most systems) and musl libc (for Alpine containers) +* aarch64 Linux (for cheaper servers like AWS EC2 t4g line), both using glibc and musl libc +* arm Linux (for Raspberry Pi), both using glibc and musl libc +* x86_64 Mac OS X + ### From sources +This project necessitates CMake. + ```bash -git clone --branch 1.0.0 https://github.com/nicolas-van/multirun.git && \ -cd multirun && \ +wget -c https://github.com/nicolas-van/multirun/archive/refs/tags/1.0.1.tar.gz -O - | tar -xz && \ +mv multirun-1.0.1 multirun-src && \ +cd multirun-src && \ cmake . && \ cmake --build . && \ cp multirun /bin && \ cd .. && \ -rm -rf multirun +rm -rf multirun-src ``` ## FAQ @@ -78,7 +82,7 @@ Here are some good use cases where multirun can be useful: Here is an example of bad use case: -* You want to pack a web server, a scheduler, a message queue, some workers and a database in a single container to make it "easy" to deploy: No no no, you're doing it wrong. Go learn about docker-compose, modify a little bit your application to properly use environment variables for things like database address and credentials, create a proper documentation, split everything into separate containers in an example `docker-compose.yml` file and send it to persons that need to deploy your application. It may seem more complicated but it's not. On the long run you will be much more effective in your Docker usage. +* You want to pack a web server, a scheduler, a message queue, some workers and a database in a single container to make it "easy" to deploy: No no no, you're doing it wrong. Go learn about docker-compose, modify a little bit your application to properly use environment variables for things like database address and credentials, create a proper documentation, split everything into separate containers in an example `docker-compose.yml` file and send it to the persons that need to deploy your application. It may seem more complicated but it's not. On the long run you will be much more effective in your Docker usage. ## Contributing From c55c6a9dd7fc0428c28d98e5fe727204eaff5a15 Mon Sep 17 00:00:00 2001 From: Nicolas Vanhoren Date: Thu, 2 Dec 2021 00:54:34 +0100 Subject: [PATCH 2/3] Fixed workflow --- .github/workflows/build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2c4ae0a..a04e56c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -92,6 +92,11 @@ jobs: - name: Compress run: | mkdir -p ./artifacts + if [[ $GITHUB_REF_TYPE =~ ^tag$ ]]; then + TAG=$GITHUB_REF_NAME + else + TAG=$GITHUB_SHA + fi tar -czf ./artifacts/$NAME-$TARGET-${{github.ref_name}}.tar.gz $NAME - name: Archive artifact uses: actions/upload-artifact@v2 From 1714038128613fdecd2d5538447b04e14a94f054 Mon Sep 17 00:00:00 2001 From: Nicolas Vanhoren Date: Thu, 2 Dec 2021 00:55:29 +0100 Subject: [PATCH 3/3] Removed pull request in workflow --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a04e56c..54e3c33 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,6 @@ name: Build on: push: - pull_request: jobs: test: