Skip to content

Commit

Permalink
Merge pull request #266 from flaviojs/build-test-linux-amd64-with-wor…
Browse files Browse the repository at this point in the history
…kflow

Build and test a linux-amd64 version of dynamips with a github workflow.
  • Loading branch information
grossmj authored Oct 6, 2024
2 parents 67072fa + fdbbb7d commit 7b6f3f7
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 6 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/ci_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI build

on:
workflow_dispatch: # run manually https://docs.github.com/en/actions/using-workflows/manually-running-a-workflow
push:
branches: [ "master" ] # run for these branches
pull_request:
branches: [ "master" ] # run for pull requests that target these branches

env:
BUILD_TYPE: RelWithDebInfo # CMake build type (Release, Debug, RelWithDebInfo, etc.)

jobs:
# ----------------------------------------------------------------------------------------------
linux-amd64:
name: Linux (amd64/x86_64)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install dependencies with APT (libelf, libpcap)
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libelf-dev libpcap0.8-dev
version: linux-amd64

- name: Configure with CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DDYNAMIPS_CODE=both -DBUILD_UDP_RECV=ON -DBUILD_UDP_SEND=ON -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/install -DCPACK_PACKAGE_FILE_NAME=dynamips-package -DCPACK_GENERATOR=ZIP

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Test
run: |
set -x
cd ${{github.workspace}}/build
ctest --verbose --build-config ${{env.BUILD_TYPE}}
./stable/dynamips -e
./unstable/dynamips_amd64_unstable -e
- name: Install
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target install

- name: Package
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target package

- name: Upload success
if: ${{ success() }}
uses: actions/upload-artifact@v4
with:
name: linux-amd64-success
path: |
${{github.workspace}}/build/install/
${{github.workspace}}/build/dynamips-package.zip
compression-level: 9 # maximum compression

- name: Upload failure
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: linux-amd64-failure
path: ${{github.workspace}}/build/
compression-level: 9 # maximum compression
18 changes: 12 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
# - ANY_COMPILER : skip compiler check (assumes gcc)
# - CMAKE_INSTALL_PREFIX : where to install

set ( CMAKE_LEGACY_CYGWIN_WIN32 0 ) # Remove when CMake >= 2.8.4 is required
cmake_minimum_required ( VERSION 2.8 )
cmake_policy ( VERSION 2.8 )
cmake_policy ( SET CMP0017 NEW ) # Prefer files from the CMake module directory when including from there.
cmake_minimum_required ( VERSION 3.5 )
foreach ( _dir
"/usr/sfw" # search in "Sun FreeWare" (SunOS)
"/opt/csw" # search in "OpenCSW" (SunOS)
Expand All @@ -24,8 +21,11 @@ endif ( CMAKE_PREFIX_PATH )
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
message ( STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}" )

project ( dynamips C )
set ( DYNAMIPS_VERSION_TRAIN 0.2.23 )
project ( dynamips
VERSION 0.2.23
LANGUAGES C
)
set ( DYNAMIPS_VERSION_TRAIN "${PROJECT_VERSION}" )
set ( DYNAMIPS_VERSION_SUB )

include ( utils )
Expand All @@ -37,6 +37,9 @@ if( APPLE OR (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") )
include_directories(include /opt/local/include/)
endif()

# Enable testing
include(CTest)

add_subdirectory ( man )
add_subdirectory ( common )
add_subdirectory ( stable )
Expand All @@ -63,3 +66,6 @@ add_custom_target (
)

print_summary ()

# Enable packaging
include(CPack)

0 comments on commit 7b6f3f7

Please sign in to comment.