Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
216 changes: 216 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
name: Build

on:
workflow_dispatch:
pull_request:
branches:
- master
- develop
- release
push:
branches:
- master
- develop
- release

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
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
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build

- name: Get Conan
# You may pin to the exact commit or the version.
# uses: turtlebrowser/get-conan@4dc7e6dd45c8b1e02e909979d7cfc5ebba6ddbe2
uses: turtlebrowser/get-conan@v1.0

- name: Conan profile and settings
run: |
conan profile new --detect default
conan config set general.revisions_enabled=1

- name: Conan profile (linux-workaround)
if: matrix.os == 'ubuntu-latest'
run:
conan profile update settings.compiler.libcxx=libstdc++11 default

- name: Conan install (osx-workaround)
if: matrix.os == 'macos-latest'
working-directory: ${{github.workspace}}/build
run: |
conan remote add ns1labs-conan https://ns1labs.jfrog.io/artifactory/api/conan/ns1labs-conan
conan install --build=missing ..

- name: linux package install
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends golang ca-certificates jq

- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: PKG_CONFIG_PATH=${{github.workspace}}/local/lib/pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE

- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE -- -j 2

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

package:
needs: build
runs-on: ubuntu-latest
# if this is a push into one of our main branches (rather than just a pull request), we will also package
if: github.event_name != 'pull_request'

steps:
- uses: actions/checkout@v2

- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build

- name: Configure CMake to generate VERSION
shell: bash
working-directory: ${{github.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE

- name: Get branch name
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV

- name: Debug branch name
run: echo ${{ env.BRANCH_NAME }}

- name: Get VERSION
run: |
echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV

- name: Debug version
run: echo ${{ env.VERSION }}

- name: Generate ref tag (master)
if: ${{ env.BRANCH_NAME == 'master' }}
run: |
echo "REF_TAG=latest" >> $GITHUB_ENV
echo "PRERELEASE=false" >> $GITHUB_ENV
echo "DRAFT=true" >> $GITHUB_ENV

- name: Generate ref tag (develop)
if: ${{ env.BRANCH_NAME == 'develop' }}
run: |
echo "REF_TAG=latest-develop" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
echo "DRAFT=false" >> $GITHUB_ENV

- name: Generate ref tag (release candidate)
if: ${{ env.BRANCH_NAME == 'release' }}
run: |
echo "REF_TAG=latest-rc" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
echo "DRAFT=false" >> $GITHUB_ENV

- name: Debug ref tag
run: echo ${{ env.REF_TAG }}

- name: Manage Github ref tags
uses: actions/github-script@v3
with:
github-token: ${{ github.token }}
# note deleteRef can't start with refs/, but create createRef does.
script: |
try {
await github.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/${{ env.REF_TAG }}",
})
} catch (e) {
console.log("The tag doesn't exist yet: " + e)
}
await github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ env.REF_TAG }}",
sha: context.sha
})

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build + push VERSION - pktvisor
env:
IMAGE_NAME: ns1labs/pktvisor
run: |
docker build . --file docker/Dockerfile --tag ${{ env.IMAGE_NAME }}:${{ env.VERSION }}
docker push ${{ env.IMAGE_NAME }}:${{ env.VERSION }}

- name: Tag + push docker image with ref tag (cached build) - pktvisor
env:
IMAGE_NAME: ns1labs/pktvisor
run: |
docker build . --file docker/Dockerfile --tag ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
docker push ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}

- name: Build + push VERSION - pktvisor-prom-write
env:
IMAGE_NAME: ns1labs/pktvisor-prom-write
working-directory: ${{github.workspace}}/centralized_collection/prometheus/docker-grafana-agent
run: |
docker build . --file docker/Dockerfile --tag ${{ env.IMAGE_NAME }}:${{ env.VERSION }}
docker push ${{ env.IMAGE_NAME }}:${{ env.VERSION }}

- name: Tag + push docker image with ref tag (cached build) - pktvisor-prom-write
env:
IMAGE_NAME: ns1labs/pktvisor-prom-write
working-directory: ${{github.workspace}}/centralized_collection/prometheus/docker-grafana-agent
run: |
docker build . --file docker/Dockerfile --tag ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
docker push ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}

- name: Generate AppImage
env:
IMAGE_NAME: ns1labs/pktvisor
working-directory: ${{github.workspace}}/appimage
run: |
DEV_IMAGE="${{ env.IMAGE_NAME }}:${{ env.VERSION }}" DEV_MODE=t make pktvisor-x86_64.AppImage
mv pktvisor-x86_64.AppImage pktvisor-x86_64-${{ env.VERSION }}.AppImage

- name: Upload AppImage artifact
uses: actions/upload-artifact@v2
with:
name: pktvisor-AppImage
path: ${{github.workspace}}/appimage/pktvisor-x86_64-${{ env.VERSION }}.AppImage

86 changes: 0 additions & 86 deletions .github/workflows/cmake.yml

This file was deleted.

15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@ cmake_minimum_required(VERSION 3.13)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

# this is the source of truth for version, which will be written to config.h include file.
# VERSION
# this is the source of truth for semver version
project(visor VERSION 3.2.0)

# for main line release, this is empty
# for development release, this is "-develop"
# for release candidate, this is "-rc"
set(VISOR_PRERELEASE "-develop")

# these are computed
set(VISOR_VERSION_NUM "${PROJECT_VERSION}${VISOR_PRERELEASE}")
set(VISOR_VERSION " pktvisor ${PROJECT_VERSION}${VISOR_PRERELEASE}")
set(VISOR_VERSION "pktvisor ${PROJECT_VERSION}${VISOR_PRERELEASE}")

# used in CI
file(WRITE ${CMAKE_BINARY_DIR}/VERSION ${VISOR_VERSION_NUM})
######

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
1 change: 0 additions & 1 deletion appimage/pktvisor/AppRun
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/sh
set -x

# borrowed from appimage directly
SELF=$(readlink -f "$0")
Expand Down
2 changes: 1 addition & 1 deletion appimage/pktvisor/TerminalEmulatorRequired.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
This app needs to be run from a terminal to function correctly. See the docs at https://github.com/ns1/pktvisor for more details.
This app needs to be run from a terminal to function correctly. See the docs at https://github.com/ns1labs/pktvisor for more details.
3 changes: 2 additions & 1 deletion centralized_collection/prometheus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ the [Grafana Agent](https://github.com/grafana/agent) for collecting and sending
[remote write](https://prometheus.io/docs/operating/integrations/#remote-endpoints-and-storage), including cloud
providers.

There is also a sample [Grafana dashboard](grafana-dashboard-prometheus.json).
There is a sample [Grafana dashboard](grafana-dashboard-prometheus.json), which you can also find online in
the [Grafana community dashboards](https://grafana.com/grafana/dashboards/14221) with ID 14221.

Example:

Expand Down
Loading