Skip to content

Commit

Permalink
chore: gha cleanup (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
leoparente authored Jan 7, 2025
1 parent ce169e4 commit 81267c6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 149 deletions.
99 changes: 13 additions & 86 deletions .github/workflows/build-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,11 @@ env:

jobs:
unit-tests-mac:
# 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

runs-on: macos-latest
steps:
- uses: actions/checkout@v4

- 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: Python Setup
Expand All @@ -55,34 +48,21 @@ jobs:
restore-keys: conan-${{ runner.os }}-

- 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
run: cmake --build . --config $BUILD_TYPE -- -j 4

- 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

unit-tests-linux:
# 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

runs-on: ubuntu-latest
outputs:
version_number: ${{ env.VERSION }}
Expand All @@ -91,8 +71,6 @@ jobs:
- uses: actions/checkout@v4

- 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
Expand All @@ -101,11 +79,6 @@ jobs:
with:
version: 1.66.0

- name: linux package install
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends jq
- name: Setup Conan Cache
uses: actions/cache@v4
with:
Expand All @@ -114,50 +87,34 @@ jobs:
restore-keys: conan-${{ runner.os }}-

- 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: Get VERSION
id: build
run: |
echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV
echo "::set-output name=version::$(cat ${{github.workspace}}/build/VERSION)"
echo "COMMIT=`git rev-parse --short HEAD`" >> $GITHUB_ENV
- 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
run: cmake --build . --config $BUILD_TYPE -- -j 4

- 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: sudo ctest -C $BUILD_TYPE

build-win64:
# 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

runs-on: windows-2019
outputs:
version_number: ${{ env.VERSION }}
steps:
- uses: actions/checkout@v4

- 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
Expand All @@ -174,13 +131,8 @@ jobs:
restore-keys: conan-${{ runner.os }}-

- 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: Get VERSION
Expand All @@ -193,7 +145,6 @@ jobs:
- 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 -- -m

# TODO: Fix unit tests for windows platform
Expand Down Expand Up @@ -310,13 +261,9 @@ jobs:
id: build
run: |
echo "VERSION=${{needs.unit-tests-linux.outputs.version_number}}" >> $GITHUB_ENV
echo "::set-output name=version::$(echo env.VERSION)"
- name: Generate ref tag (develop)
run: |
echo "REF_TAG=latest-develop" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
echo "DRAFT=false" >> $GITHUB_ENV
run: echo "REF_TAG=latest-develop" >> $GITHUB_ENV

- name: Debug ref tag
run: echo ${{ env.REF_TAG }}
Expand Down Expand Up @@ -353,18 +300,12 @@ jobs:
context: .
file: ./docker/Dockerfile.crashhandler
platforms: linux/amd64
tags: ${{ env.IMAGE_NAME }}:${{ needs.unit-tests-linux.outputs.version_number }} , ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ needs.unit-tests-linux.outputs.version_number }}
${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
outputs: type=docker,dest=/tmp/amd64.tar

- name: Load image
env:
IMAGE_NAME: netboxlabs/pktvisor
run: |
docker load --input /tmp/amd64.tar
docker image ls -a
docker push ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
docker push ${{ env.IMAGE_NAME }}:${{ needs.unit-tests-linux.outputs.version_number }}
build-app-image-x64:
needs: [ package-amd64 ]
runs-on: ubuntu-latest
Expand All @@ -388,20 +329,15 @@ jobs:

- name: Get VERSION
id: build
run: |
echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV
echo "::set-output name=version::$(cat ${{github.workspace}}/build/VERSION)"
run: echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV

- name: Debug version
run: |
echo ${{ env.VERSION }}
echo ${{ steps.build.outputs.version }}
- name: Generate ref tag (develop)
run: |
echo "REF_TAG=latest-develop" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
echo "DRAFT=false" >> $GITHUB_ENV
- name: Prepare version file
run: |
Expand Down Expand Up @@ -498,10 +434,7 @@ jobs:
run: ls -lha .

- name: Generate ref tag (develop)
run: |
echo "REF_TAG=latest-develop" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
echo "DRAFT=false" >> $GITHUB_ENV
run: echo "REF_TAG=latest-develop" >> $GITHUB_ENV

- name: Debug ref tag
run: echo ${{ env.REF_TAG }}
Expand Down Expand Up @@ -539,14 +472,8 @@ jobs:
context: .
file: ./docker/Dockerfile.crashhandler
platforms: linux/arm64
tags: ${{ env.IMAGE_NAME }}:${{ needs.unit-tests-linux.outputs.version_number }} , ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ needs.unit-tests-linux.outputs.version_number }}
${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
outputs: type=docker,dest=/tmp/arm64.tar

- name: Load image
env:
IMAGE_NAME: netboxlabs/pktvisor
run: |
docker load --input /tmp/arm64.tar
docker image ls -a
docker push ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
docker push ${{ env.IMAGE_NAME }}:${{ needs.unit-tests-linux.outputs.version_number }}
41 changes: 6 additions & 35 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ jobs:
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-

- name: linux package install
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends jq
- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build
Expand All @@ -55,7 +49,7 @@ jobs:
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
run: cmake --build . --config $BUILD_TYPE -- -j 2
run: cmake --build . --config $BUILD_TYPE -- -j 4

- name: Test
working-directory: ${{github.workspace}}/build
Expand Down Expand Up @@ -93,16 +87,12 @@ jobs:

- name: Get VERSION
id: build
run: |
echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV
echo "::set-output name=version::$(cat ${{github.workspace}}/build/VERSION)"
run: echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV

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

- name: Persist to workspace
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -171,20 +161,13 @@ jobs:
prerelease: false

build-win64:
# 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

runs-on: windows-2019
outputs:
version_number: ${{ env.VERSION }}
steps:
- uses: actions/checkout@v4

- 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
Expand All @@ -201,13 +184,8 @@ jobs:
restore-keys: conan-${{ runner.os }}-

- 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: Get VERSION
Expand Down Expand Up @@ -353,8 +331,7 @@ jobs:
run: echo ${{ env.BRANCH_NAME }}

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

- name: Debug version
run: echo ${{ env.VERSION }}
Expand All @@ -363,8 +340,6 @@ jobs:
if: ${{ env.BRANCH_NAME == 'master' }}
run: |
echo "REF_TAG=latest" >> $GITHUB_ENV
echo "PRERELEASE=false" >> $GITHUB_ENV
echo "DRAFT=true" >> $GITHUB_ENV
- name: Debug ref tag
run: echo ${{ env.REF_TAG }}
Expand Down Expand Up @@ -474,18 +449,14 @@ jobs:
run: echo ${{ env.BRANCH_NAME }}

- name: Get VERSION
run: |
echo "VERSION=`cat ${{github.workspace}}/build/VERSION`" >> $GITHUB_ENV
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
run: echo "REF_TAG=latest" >> $GITHUB_ENV

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

0 comments on commit 81267c6

Please sign in to comment.