-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reproduce ns-3 CI pipelines (push, MR)
- Loading branch information
1 parent
da17109
commit ea1982e
Showing
10 changed files
with
486 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: "build" | ||
description: "Defines the central steps in building ns-3" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
# Pre-configuration steps | ||
- name: "Restore build cache of this job" | ||
uses: actions/cache@v3 | ||
with: | ||
path: ns-3-ccache-storage | ||
key: ccache-${{ env.BUILD_ID }} | ||
# Configuration steps | ||
- name: "Prepare ccache environment" | ||
run: | | ||
mkdir -p ns-3-ccache-storage | ||
echo "CCACHE_BASEDIR=$GITHUB_WORKSPACE" >> $GITHUB_ENV | ||
echo "CCACHE_DIR=$GITHUB_WORKSPACE/ns-3-ccache-storage" >> $GITHUB_ENV | ||
shell: bash | ||
- name: "Configure ns-3 CMake" | ||
run: CXX=$COMPILER ./ns3 configure -d $MODE -GNinja --enable-examples --enable-tests --enable-asserts --enable-werror --enable-modules "lorawan;applications" $EXTRA_OPTIONS | ||
shell: bash | ||
# Build steps | ||
- name: "Build ns-3" | ||
run: > | ||
ccache -z && | ||
./ns3 build && | ||
if [[ "`./utils/ccache-miss-rate.py`" != "0" ]]; | ||
then `touch build/tests-$GITHUB_SHA.txt`; | ||
fi && | ||
ccache -s | ||
shell: bash | ||
# Post-build steps | ||
- name: "Tar files to preserve permissions" | ||
run: tar -cf build.tzst --exclude build.tzst -P -C $GITHUB_WORKSPACE --use-compress-program zstdmt build/ .lock-* | ||
shell: bash | ||
- name: "Join extra options in string" | ||
run: echo "JOIN_EXTRA=`echo $EXTRA_OPTIONS | sed 's/ //g'`" >> $GITHUB_ENV | ||
shell: bash | ||
- name: "Upload build artifacts" | ||
uses: actions/[email protected] | ||
with: | ||
name: ${{ format('{0}{1}', env.BUILD_ID, env.JOIN_EXTRA ) }} | ||
path: build.tzst | ||
retention-days: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: "checkout-ns3" | ||
description: "Checkout this repository as ns-3 module" | ||
|
||
# Requires wget! | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: "Checkout supported ns-3 version" | ||
uses: actions/checkout@v4 | ||
with: | ||
sparse-checkout: | | ||
NS3-VERSION | ||
sparse-checkout-cone-mode: false | ||
- name: "Download ns-3-dev working tree with Gitlab API" | ||
run: | | ||
tag=$(< NS3-VERSION) && tag=${tag#release } | ||
wget -nv -O ns-3-dev.tar https://gitlab.com/api/v4/projects/nsnam%2Fns-3-dev/repository/archive.tar?sha=$tag | ||
tar -xf ns-3-dev.tar && cp -a ns-3-dev-$tag-*/. . && rm -R ns-3-dev.tar ns-3-dev-$tag* | ||
shell: bash | ||
- name: "Checkout this repository as ns-3 module" | ||
uses: actions/checkout@v4 | ||
with: | ||
path: "src/lorawan" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: "test" | ||
description: "Defines the central stepa in testing ns-3" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
# Pre-configuration steps | ||
- name: "Join extra options in string" | ||
run: echo "JOIN_EXTRA=`echo $EXTRA_OPTIONS | sed 's/ //g'`" >> $GITHUB_ENV | ||
shell: bash | ||
- name: "Download build artifacts from previous job" | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ format('{0}{1}', env.BUILD_ID, env.JOIN_EXTRA ) }} | ||
- name: "Unpack build artifacts for testing" | ||
run: tar -xf build.tzst -P -C $GITHUB_WORKSPACE --use-compress-program unzstd | ||
shell: bash | ||
# Configuration steps | ||
- name: "Configure ns-3 CMake" | ||
run: CXX=$COMPILER ./ns3 configure -d $MODE -GNinja --enable-examples --enable-tests --enable-asserts --enable-werror --enable-modules "lorawan;applications" $EXTRA_OPTIONS | ||
shell: bash | ||
# Test steps | ||
- if: env.MODE != 'debug' && hashFiles(format('build/tests-{0}.txt', github.sha)) != '' | ||
name: "Test ns-3" | ||
run: > | ||
./test.py -n && | ||
if [[ $? == 0 ]]; | ||
then `rm build/tests-$GITHUB_REF_NAME.txt` || true; | ||
fi; | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Base ns-3 CI job template for per-commit jobs involving building and testing | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
compiler: | ||
description: "g++|clang++" | ||
required: true | ||
type: string | ||
mode: | ||
description: "debug|default|release|optimized" | ||
required: true | ||
type: string | ||
extra_options: | ||
description: "additional './ns3 configure' options" | ||
required: false | ||
type: string | ||
do_test: | ||
description: "set to 'test' to run tests job after build" | ||
required: false | ||
type: string | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: archlinux | ||
timeout-minutes: 720 | ||
steps: | ||
- name: "Install required system packages" | ||
run: > | ||
pacman-key --init && | ||
pacman -Syu --noconfirm | ||
base-devel gcc clang cmake ninja ccache | ||
boost gsl gtk3 | ||
openssh | ||
python | ||
wget | ||
# The following 2 steps are required... | ||
# Github workflows/actions are too limited >:( | ||
# They will be duplicated in all reusable workflows | ||
- name: "Retrieve action from repository" | ||
uses: actions/checkout@v4 | ||
with: | ||
sparse-checkout: | | ||
.github/actions/checkout-ns3 | ||
sparse-checkout-cone-mode: false | ||
- name: "Checkout this repository as ns-3 module" | ||
uses: ./.github/actions/checkout-ns3 | ||
- name: "Build ns-3" | ||
uses: ./src/lorawan/.github/actions/build | ||
env: | ||
BUILD_ID: ${{ format('per-commit-{0}-{1}', inputs.compiler, inputs.mode) }} | ||
COMPILER: ${{ inputs.compiler }} | ||
MODE: ${{ inputs.mode }} | ||
EXTRA_OPTIONS: ${{ inputs.extra_options }} | ||
|
||
test: | ||
if: inputs.do_test == 'test' | ||
runs-on: ubuntu-latest | ||
needs: build | ||
container: | ||
image: archlinux | ||
timeout-minutes: 720 | ||
steps: | ||
- name: "Install required system packages" | ||
run: > | ||
pacman-key --init && | ||
pacman -Syu --noconfirm | ||
base-devel gcc clang cmake ninja ccache | ||
boost gsl gtk3 | ||
openssh | ||
python | ||
wget | ||
# The following 2 steps are required... | ||
# Github workflows/actions are too limited >:( | ||
# They will be duplicated in all reusable workflows | ||
- name: "Retrieve action from repository" | ||
uses: actions/checkout@v4 | ||
with: | ||
sparse-checkout: | | ||
.github/actions/checkout-ns3 | ||
sparse-checkout-cone-mode: false | ||
- name: "Checkout this repository as ns-3 module" | ||
uses: ./.github/actions/checkout-ns3 | ||
- name: "Test ns-3" | ||
uses: ./src/lorawan/.github/actions/test | ||
env: | ||
BUILD_ID: ${{ format('per-commit-{0}-{1}', inputs.compiler, inputs.mode) }} | ||
COMPILER: ${{ inputs.compiler }} | ||
MODE: ${{ inputs.mode }} | ||
EXTRA_OPTIONS: ${{ inputs.extra_options }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# ns-3 CI/CD script with the pre-build stage | ||
# | ||
# Contains jobs to check the ns-3 code formatting and spell-checking. | ||
|
||
on: workflow_call | ||
|
||
jobs: | ||
# Clang-format | ||
check-style-clang-format: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ubuntu:rolling | ||
strategy: | ||
matrix: | ||
version: [14, 15, 16] | ||
timeout-minutes: 60 | ||
steps: | ||
- name: "Install required system packages" | ||
run: > | ||
apt update && | ||
DEBIAN_FRONTEND=noninteractive apt install -y | ||
python3 | ||
wget | ||
clang-format-${{ matrix.version }} | ||
# The following 2 steps are required... | ||
# Github workflows/actions are too limited >:( | ||
# They will be duplicated in all reusable workflows | ||
- name: "Retrieve action from repository" | ||
uses: actions/checkout@v4 | ||
with: | ||
sparse-checkout: | | ||
.github/actions/checkout-ns3 | ||
sparse-checkout-cone-mode: false | ||
- name: "Checkout this repository as ns-3 module" | ||
uses: ./.github/actions/checkout-ns3 | ||
- name: "Check code style" | ||
run: python3 utils/check-style-clang-format.py --verbose . | ||
|
||
# Emacs line | ||
emacs-line: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 60 | ||
continue-on-error: true | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: > | ||
if ( egrep -rn --include="*.h" --include="*.cc" --include="*.c" --include="*.py" --include="*.rst" "c-file-style:|py-indent-offset:" ) ; then | ||
echo "Found Emacs lines on the above C/C++, Python and RST files" ; | ||
exit 1 ; | ||
else | ||
echo "No Emacs lines found on C/C++, Python and RST files" ; | ||
exit 0 ; | ||
fi | ||
# Spell checking | ||
spell-check: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: python:latest | ||
timeout-minutes: 60 | ||
continue-on-error: true | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: pip install codespell | ||
# Get commit messages | ||
- run: > | ||
if (git remote | grep -qw upstream) ; then | ||
git remote remove upstream ; | ||
fi | ||
- run: git config --global --add safe.directory $GITHUB_WORKSPACE | ||
# develop here is meant to be the "default branch" | ||
- run: git remote add -t develop --no-tags -f upstream https://github.com/signetlabdei/lorawan.git | ||
- run: git log --pretty=%B HEAD...upstream/develop ^upstream/develop > git_messages.txt | ||
# Check source code and commit messages | ||
- run: codespell -f -C0 --skip="./experiments" ./ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# ns-3 CI/CD script with jobs of the code-linting stage | ||
# | ||
# Contains jobs to perform lint checking. | ||
|
||
on: workflow_call | ||
|
||
jobs: | ||
# Clang-tidy | ||
clang-tidy-16: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ubuntu:rolling | ||
timeout-minutes: 180 | ||
continue-on-error: true | ||
env: | ||
CLANG_TIDY_OUTPUT: clang-tidy-output.log | ||
REPO_URL: https://github.com/signetlabdei/lorawan.git | ||
DEFAULT_BRANCH: develop | ||
steps: | ||
- name: "Install required system packages" | ||
run: > | ||
apt update && | ||
DEBIAN_FRONTEND=noninteractive apt install -y | ||
clang cmake | ||
clang-tidy clang-tidy-16 | ||
python3 python3-pip | ||
libboost-all-dev libeigen3-dev libgtk-3-dev libsqlite3-dev | ||
gsl-bin libgsl-dev libgsl27 | ||
git ssh | ||
wget | ||
- name: "Retrieve action from repository" | ||
uses: actions/checkout@v4 | ||
with: | ||
sparse-checkout: | | ||
.github/actions/checkout-ns3 | ||
sparse-checkout-cone-mode: false | ||
- name: "Checkout this repository as ns-3 module" | ||
uses: ./.github/actions/checkout-ns3 | ||
- name: "Configure ns-3 CMake" | ||
run: > | ||
./ns3 configure -d debug | ||
--enable-clang-tidy | ||
--enable-examples --enable-tests --enable-asserts | ||
--enable-modules "lorawan;applications" | ||
# Use a trick (git diff on empty tag) to only run clang-tidy on the lorawan module | ||
- name: "Running clang-tidy" | ||
run: > | ||
git -C src/lorawan/ tag empty $(git hash-object -t tree /dev/null) && | ||
git -C src/lorawan/ diff -U0 empty | ||
--src-prefix=a/src/lorawan/ --dst-prefix=b/src/lorawan/ | | ||
clang-tidy-diff-16.py -path cmake-cache/ -p1 -quiet -use-color | ||
-iregex "src\/lorawan\/.+\.(cpp|cc|cxx|c|h|hpp)" | ||
1> $CLANG_TIDY_OUTPUT | ||
2> /dev/null | ||
shell: bash | ||
- name: "Check job results" | ||
run: | | ||
(! egrep -A 3 "error:|warning:|note:" $CLANG_TIDY_OUTPUT) | ||
echo "No clang-tidy errors found" | ||
- name: "Upload build artifacts" | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ env.CLANG_TIDY_OUTPUT }} | ||
path: ${{ env.CLANG_TIDY_OUTPUT }} |
Oops, something went wrong.