Skip to content

Commit ca4e911

Browse files
committed
Reproduce ns-3 CI pipelines (push, MR) (#141)
1 parent 926478b commit ca4e911

15 files changed

Lines changed: 535 additions & 80 deletions

File tree

.github/actions/build/action.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: "build"
2+
description: "Defines the central steps in building ns-3"
3+
4+
inputs:
5+
save-ccache:
6+
description: "Whether to update build ccache after building"
7+
default: "true"
8+
store-artifacts:
9+
description: "Whether to upload build artifacts after building"
10+
default: "true"
11+
12+
runs:
13+
using: "composite"
14+
steps:
15+
# Pre-configuration steps
16+
- if: env.MODE != 'optimized' && ( ! contains(env.EXTRA_OPTIONS, '--disable-precompiled-headers') )
17+
name: "Restore build cache of this job"
18+
uses: hendrikmuhs/ccache-action@v1.2
19+
with:
20+
key: ${{ env.BUILD_ID }}
21+
save: ${{ inputs.save-ccache }}
22+
# Configuration steps
23+
- name: "Configure ns-3 CMake"
24+
shell: bash
25+
run: >
26+
CXX=$COMPILER ./ns3 configure -d $MODE -GNinja
27+
--enable-examples --enable-tests --enable-asserts --enable-werror
28+
--enable-modules "lorawan;applications" $EXTRA_OPTIONS
29+
# Build steps
30+
- name: "Build ns-3"
31+
shell: bash
32+
run: ./ns3 build
33+
# Post-build steps
34+
- if: inputs.store-artifacts == 'true'
35+
name: "Tar files to preserve permissions"
36+
shell: bash
37+
run: tar -cf build.tzst --exclude build.tzst -P -C $GITHUB_WORKSPACE --use-compress-program zstdmt build/ .lock-*
38+
- if: inputs.store-artifacts == 'true'
39+
name: "Upload build artifacts"
40+
uses: actions/upload-artifact@v3.0.0
41+
with:
42+
name: ${{ env.BUILD_ID }}
43+
path: build.tzst
44+
retention-days: 2
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: "checkout-in-ns3"
2+
description: "Checkout this repository as ns-3 module"
3+
4+
# Requires wget!
5+
6+
runs:
7+
using: "composite"
8+
steps:
9+
- name: "Checkout this repository as ns-3 module"
10+
uses: actions/checkout@v4
11+
with:
12+
path: "src/lorawan"
13+
- name: "Download ns-3-dev working tree with Gitlab API"
14+
run: |
15+
tag=$(< src/lorawan/NS3-VERSION) && tag=${tag#release }
16+
wget -nv -O ns-3-dev.tar https://gitlab.com/api/v4/projects/nsnam%2Fns-3-dev/repository/archive.tar?sha=$tag
17+
tar -xf ns-3-dev.tar && cp -a ns-3-dev-$tag-*/. . && rm -R ns-3-dev.tar ns-3-dev-$tag*
18+
shell: bash
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Note: this action requires an ubuntu container and access to the repos's actions!
2+
# (see analysis.yml)
3+
name: "install-analysis"
4+
description: "Installs required ubuntu packages and checks-out the repo in ns-3"
5+
6+
runs:
7+
using: "composite"
8+
steps:
9+
- name: "Install required system packages"
10+
shell: bash
11+
run: >
12+
sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt install -y
13+
apt-utils
14+
git gcc g++ cmake python3 make ninja-build
15+
tcpdump libgsl-dev libxml2-dev
16+
curl unzip tar
17+
ccache
18+
lcov
19+
wget
20+
- name: "Checkout this repository as ns-3 module"
21+
uses: ./.github/actions/checkout-in-ns3
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Note: this action requires an archlinux container and access to the repos's actions!
2+
# (see .doc.yml)
3+
name: "install-doc"
4+
description: "Installs required archlinux packages and checks-out the repo in ns-3"
5+
6+
runs:
7+
using: "composite"
8+
steps:
9+
- name: "Install required system packages"
10+
shell: bash
11+
run: >
12+
pacman-key --init && pacman -Syu --noconfirm
13+
base-devel ninja cmake python ccache gsl gtk3 boost openssh
14+
graphviz imagemagick texlive-basic texlive-bin texlive-binextra texlive-latexextra
15+
texlive-fontutils texlive-fontsrecommended python-sphinx
16+
wget &&
17+
pacman --noconfirm -U https://archive.archlinux.org/packages/d/dia/dia-0.97.3-9-x86_64.pkg.tar.zst &&
18+
pacman --noconfirm -U https://archive.archlinux.org/packages/d/doxygen/doxygen-1.9.6-1-x86_64.pkg.tar.zst &&
19+
mv /etc/ImageMagick-7/policy.xml /etc/ImageMagick-7/policy.xml.bak
20+
- name: "Checkout this repository as ns-3 module"
21+
uses: ./.github/actions/checkout-in-ns3
22+
- name: "Add lorawan module to docs"
23+
shell: bash
24+
working-directory: doc/models
25+
run: |
26+
sed -i '/lr-wpan\/doc\/lr-wpan.rst/a\\t\$(SRC)\/lorawan\/doc\/lorawan.rst \\' Makefile
27+
sed -i '/lr-wpan\/doc\/lr-wpan-arch.dia/i\\t\$(SRC)\/lorawan\/doc\/figures\/LoRaWANTopology.pdf \\' Makefile
28+
sed -i '/lr-wpan/i\ lorawan' source/index.rst
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Note: this action requires an ubuntu container and access to the repos's actions!
2+
# (see .linting.yml)
3+
name: "install-linting"
4+
description: "Installs required ubuntu packages and checks-out the repo in ns-3"
5+
6+
runs:
7+
using: "composite"
8+
steps:
9+
- name: "Install required system packages"
10+
shell: bash
11+
run: >
12+
apt update && DEBIAN_FRONTEND=noninteractive apt install -y
13+
clang cmake
14+
clang-tidy clang-tidy-16
15+
python3 python3-pip
16+
libboost-all-dev libeigen3-dev libgtk-3-dev libsqlite3-dev
17+
gsl-bin libgsl-dev libgsl27
18+
git ssh
19+
wget
20+
- name: "Checkout this repository as ns-3 module"
21+
uses: ./.github/actions/checkout-in-ns3
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Note: this action requires an archlinux container, specific inputs and access to the repos's actions!
2+
# (see .base-per-commit.yml)
3+
name: "install-per-commit"
4+
description: "Installs required archlinux packages and checks-out the repo in ns-3"
5+
6+
runs:
7+
using: "composite"
8+
steps:
9+
- name: "Install required system packages"
10+
shell: bash
11+
run: >
12+
pacman-key --init && pacman -Syu --noconfirm
13+
base-devel gcc clang cmake ninja ccache
14+
boost gsl gtk3
15+
openssh
16+
python
17+
wget
18+
- name: "Checkout this repository as ns-3 module"
19+
uses: ./.github/actions/checkout-in-ns3
20+
- name: "Format a string id for the build conf. of this job"
21+
shell: bash
22+
run: |
23+
EXTRA_ID=`echo $EXTRA_OPTIONS | sed 's/--/-/g' | sed 's/ //g'`
24+
echo "BUILD_ID=per-commit-$COMPILER-$MODE$EXTRA_ID" >> $GITHUB_ENV

.github/actions/test/action.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: "test"
2+
description: "Defines the central steps in testing ns-3"
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
# Test steps
8+
- name: "Store ccache miss rate"
9+
shell: bash
10+
run: echo "CACHE_MISS=`./utils/ccache-miss-rate.py`" >> $GITHUB_ENV
11+
- if: env.CACHE_MISS != '0' && env.MODE != 'debug'
12+
name: "Test ns-3"
13+
shell: bash
14+
run: ./test.py -n

.github/workflows/.doc.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Base ns-3 CI job template for per-commit jobs involving building and testing
2+
3+
on: workflow_call
4+
5+
jobs:
6+
doxygen:
7+
runs-on: ubuntu-latest
8+
container:
9+
image: archlinux
10+
timeout-minutes: 120
11+
continue-on-error: true
12+
steps:
13+
# The following step is required in all jobs that use this repo's actions
14+
- name: "Retrieve actions from repository"
15+
uses: actions/checkout@v4
16+
with:
17+
sparse-checkout: .github/actions
18+
- name: "Install dependencies and checkout repo in ns-3"
19+
uses: ./.github/actions/install-doc
20+
- name: "Build ns-3"
21+
env:
22+
BUILD_ID: per-commit-g++-debug
23+
COMPILER: g++
24+
MODE: debug
25+
uses: ./.github/actions/build
26+
with:
27+
save-ccache: "false"
28+
store-artifacts: "false"
29+
- name: "Build ns-3 assemble-introspected-command-line"
30+
run: ./ns3 build assemble-introspected-command-line
31+
- name: "Check documentation coverage and formatting"
32+
run: |
33+
doc/doxygen.warnings.report.sh -i -m lorawan
34+
python3 utils/check-style-clang-format.py --no-formatting --no-tabs doc/introspected-doxygen.h
35+
python3 utils/check-style-clang-format.py --no-formatting --no-tabs doc/introspected-command-line.h
36+
./ns3 clean
37+
- name: "Upload doxygen warnings as artifact"
38+
if: always()
39+
uses: actions/upload-artifact@v3.0.0
40+
with:
41+
name: doxygen.warnings.log
42+
path: doc/doxygen.warnings.log
43+
44+
models:
45+
runs-on: ubuntu-latest
46+
container:
47+
image: archlinux
48+
timeout-minutes: 120
49+
steps:
50+
# The following step is required in all jobs that use this repo's actions
51+
- name: "Retrieve actions from repository"
52+
uses: actions/checkout@v4
53+
with:
54+
sparse-checkout: .github/actions
55+
- name: "Install dependencies and checkout repo in ns-3"
56+
uses: ./.github/actions/install-doc
57+
- name: "Make html and latexpdf"
58+
working-directory: doc/models
59+
run: |
60+
make html
61+
make latexpdf

.github/workflows/.formatting.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# ns-3 CI/CD script with the pre-build stage
2+
#
3+
# Contains jobs to check the ns-3 code formatting and spell-checking.
4+
5+
on: workflow_call
6+
7+
jobs:
8+
# Clang-format
9+
check-style-clang-format:
10+
runs-on: ubuntu-latest
11+
container:
12+
image: ubuntu:rolling
13+
strategy:
14+
matrix:
15+
version: [14, 15, 16]
16+
timeout-minutes: 60
17+
steps:
18+
# The following step is required in all jobs that use this repo's actions
19+
- name: "Retrieve actions from repository"
20+
uses: actions/checkout@v4
21+
with:
22+
sparse-checkout: .github/actions
23+
- name: "Install required system packages"
24+
run: >
25+
apt update && DEBIAN_FRONTEND=noninteractive apt install -y
26+
python3
27+
clang-format-${{ matrix.version }}
28+
wget
29+
- name: "Checkout this repository as ns-3 module"
30+
uses: ./.github/actions/checkout-in-ns3
31+
- name: "Check code style"
32+
run: python3 utils/check-style-clang-format.py --verbose src/lorawan
33+
34+
# Emacs line
35+
emacs-line:
36+
runs-on: ubuntu-latest
37+
timeout-minutes: 60
38+
steps:
39+
- uses: actions/checkout@v4
40+
- run: >
41+
if ( egrep -rn --include="*.h" --include="*.cc" --include="*.c" --include="*.py" --include="*.rst" "c-file-style:|py-indent-offset:" ) ; then
42+
echo "Found Emacs lines on the above C/C++, Python and RST files" ;
43+
exit 1 ;
44+
else
45+
echo "No Emacs lines found on C/C++, Python and RST files" ;
46+
exit 0 ;
47+
fi
48+
49+
# Spell checking
50+
spell-check:
51+
runs-on: ubuntu-latest
52+
container:
53+
image: python:latest
54+
timeout-minutes: 60
55+
steps:
56+
- uses: actions/checkout@v4
57+
- run: pip install codespell
58+
# Get commit messages
59+
- run: >
60+
if (git remote | grep -qw upstream) ; then
61+
git remote remove upstream ;
62+
fi
63+
- run: git config --global --add safe.directory $GITHUB_WORKSPACE
64+
# develop here is meant to be the "default branch"
65+
- run: git remote add -t develop --no-tags -f upstream https://github.com/signetlabdei/lorawan.git
66+
- run: git log --pretty=%B HEAD...upstream/develop ^upstream/develop > git_messages.txt
67+
# Check source code and commit messages
68+
- run: codespell -f -C0 --skip="./experiments" ./

.github/workflows/.linting.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# ns-3 CI/CD script with jobs of the code-linting stage
2+
#
3+
# Contains jobs to perform lint checking.
4+
5+
on: workflow_call
6+
7+
jobs:
8+
# Clang-tidy
9+
clang-tidy-16:
10+
runs-on: ubuntu-latest
11+
container:
12+
image: ubuntu:rolling
13+
timeout-minutes: 180
14+
env:
15+
CLANG_TIDY_OUTPUT: clang-tidy-output.log
16+
steps:
17+
# The following step is required in all jobs that use this repo's actions
18+
- name: "Retrieve actions from repository"
19+
uses: actions/checkout@v4
20+
with:
21+
sparse-checkout: .github/actions
22+
- name: "Install dependencies and checkout repo in ns-3"
23+
uses: ./.github/actions/install-linting
24+
- name: "Configure ns-3 CMake"
25+
run: >
26+
./ns3 configure -d debug
27+
--enable-examples --enable-tests --enable-asserts
28+
--enable-modules "lorawan;applications"
29+
--enable-clang-tidy
30+
# Use a trick (git diff on empty tag) to only run clang-tidy on the lorawan module
31+
- name: "Running clang-tidy"
32+
shell: bash
33+
run: >
34+
git -C src/lorawan/ tag empty $(git hash-object -t tree /dev/null) &&
35+
git -C src/lorawan/ diff -U0 empty
36+
--src-prefix=a/src/lorawan/ --dst-prefix=b/src/lorawan/ |
37+
clang-tidy-diff-16.py -path cmake-cache/ -p1 -quiet -use-color
38+
-iregex "src\/lorawan\/.+\.(cpp|cc|cxx|c|h|hpp)"
39+
1> $CLANG_TIDY_OUTPUT
40+
2> /dev/null
41+
- name: "Check job results"
42+
run: |
43+
(! egrep -A 3 "error:|warning:|note:" $CLANG_TIDY_OUTPUT)
44+
echo "No clang-tidy errors found"
45+
- if: failure()
46+
name: "Upload clang-tidy-output.log"
47+
uses: actions/upload-artifact@v3.0.0
48+
with:
49+
name: ${{ env.CLANG_TIDY_OUTPUT }}
50+
path: ${{ env.CLANG_TIDY_OUTPUT }}

0 commit comments

Comments
 (0)