Skip to content

Commit

Permalink
Update CI pipeline and bump supported ns-3 version to ns-3.43 (#173)
Browse files Browse the repository at this point in the history
* Remove manual CodeQL workflow job

* Update install-doc CI as in ns-3.43

* Remove CI actions that do not reduce duplication

* Update linting and formatting CI as in ns-3.43

* Simplify CI job names

* Fix new doxygen, clang-format and clang-tidy warnings

* Change GPL license text to SPDX license

* Codecov CI action in place of deprecated script

* Remove "applications" module from dependencies

* Extend buildings model test coverage
  • Loading branch information
non-det-alle authored Oct 13, 2024
1 parent e99f688 commit 17b213f
Show file tree
Hide file tree
Showing 119 changed files with 204 additions and 1,436 deletions.
4 changes: 2 additions & 2 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ runs:
steps:
# Pre-configuration steps
# (skip ccache for --disable-precompiled-headers because it won't use it)
# (skip ccache for optimized because built files are too architecture dependent)
# (skip ccache for optimized because built files are architecture dependent)
- if: env.MODE != 'optimized' && ( ! contains(env.EXTRA_OPTIONS, '--disable-precompiled-headers') )
name: "Restore build cache of this job"
uses: hendrikmuhs/[email protected]
Expand All @@ -27,7 +27,7 @@ runs:
run: >
CXX=$COMPILER ./ns3 configure -d $MODE -GNinja
--enable-examples --enable-tests --enable-asserts --enable-werror
--enable-modules "lorawan;applications" $EXTRA_OPTIONS
--enable-modules lorawan $EXTRA_OPTIONS
# Build steps
- name: "Build ns-3"
shell: bash
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/checkout-in-ns3/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ runs:
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*
echo
echo "###################################################"
echo "######################################################"
echo "###### WARNING! CURRENT NS-3 VERSION: $tag ######"
echo "###################################################"
echo "######################################################"
shell: bash
20 changes: 0 additions & 20 deletions .github/actions/install-analysis/action.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/actions/install-doc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ runs:
pacman-key --init && pacman -Syu --noconfirm
base-devel ninja cmake python ccache
graphviz imagemagick texlive-basic texlive-bin texlive-binextra texlive-latexextra
texlive-fontutils texlive-fontsrecommended python-sphinx
wget &&
texlive-fontutils texlive-fontsrecommended texlive-mathscience python-sphinx wget &&
pacman --noconfirm -U https://archive.archlinux.org/packages/d/dia/dia-0.97.3-9-x86_64.pkg.tar.zst &&
pacman --noconfirm -U https://archive.archlinux.org/packages/d/doxygen/doxygen-1.9.6-1-x86_64.pkg.tar.zst &&
wget http://www.nsnam.org/packages/doxygen-1.11.0-4-x86_64.pkg.tar.zst &&
pacman --noconfirm -U doxygen-1.11.0-4-x86_64.pkg.tar.zst &&
mv /etc/ImageMagick-7/policy.xml /etc/ImageMagick-7/policy.xml.bak
- name: "Checkout this repository as ns-3 module"
uses: ./.github/actions/checkout-in-ns3
Expand Down
17 changes: 0 additions & 17 deletions .github/actions/install-linting/action.yml

This file was deleted.

64 changes: 24 additions & 40 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ns-3 CI/CD script with job for code quality and coverage
# ns-3 CI/CD script with job for code analysis
#
# Contains jobs to run code quality and coverage analysis.
# Contains jobs to run code analysis tasks.
name: "Run code analysis"
run-name: "analysis"

Expand All @@ -13,37 +13,6 @@ env:
MODE: default

jobs:
# CodeQL
code-ql:
runs-on: ubuntu-latest
continue-on-error: true
steps:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: "cpp"
# The following step is required in all jobs that use this repo's actions
- name: "Retrieve actions from repository"
uses: actions/checkout@v4
with:
sparse-checkout: .github/actions
- name: "Install dependencies and checkout repo in ns-3"
uses: ./.github/actions/install-analysis
- name: "Build ns-3"
env:
BUILD_ID: ubuntu-codeql
COMPILER: g++
MODE: release
EXTRA_OPTIONS: --disable-werror
uses: ./.github/actions/build
with:
store-artifacts: "false"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
checkout_path: ${{ github.workspace }}/src/lorawan

# CodeCov
code-cov:
runs-on: ubuntu-latest
Expand All @@ -53,23 +22,38 @@ jobs:
uses: actions/checkout@v4
with:
sparse-checkout: .github/actions
- name: "Install dependencies and checkout repo in ns-3"
uses: ./.github/actions/install-analysis
- name: "Install required system packages"
run: >
sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt install -y
apt-utils
git gcc g++ cmake python3 make ninja-build
curl unzip tar
ccache
lcov
wget
- name: "Checkout this repository as ns-3 module"
uses: ./.github/actions/checkout-in-ns3
- name: "Build ns-3"
env:
BUILD_ID: ubuntu-coverage
COMPILER: g++
MODE: release
MODE: default
EXTRA_OPTIONS: --disable-werror --enable-gcov
uses: ./.github/actions/build
with:
store-artifacts: "false"
- name: "Extract ccache statistics"
run: echo "CACHE_MISSES=`./utils/ccache-miss-rate.py`" >> $GITHUB_ENV
- if: env.CACHE_MISSES != '0'
name: "Generate coverage data and submit to codecov.io"
name: "Generate coverage data"
run: |
./ns3 build coverage_gcc
bash <(curl -s https://codecov.io/bash) -f build/coverage/ns3.info -R src/lorawan/ || echo "Codecov did not collect coverage reports"
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
mv build/coverage/ns3.info src/lorawan
- if: env.CACHE_MISSES != '0'
name: "Submit coverage data to codecov.io"
uses: codecov/codecov-action@v4
with:
working-directory: src/lorawan
file: ns3.info
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
9 changes: 5 additions & 4 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
image: ubuntu:rolling
strategy:
matrix:
version: [14, 15, 16, 17]
version: [14, 17]
timeout-minutes: 60
steps:
# The following step is required in all jobs that use this repo's actions
Expand Down Expand Up @@ -56,6 +56,8 @@ jobs:
container:
image: python:latest
timeout-minutes: 60
env:
CI_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
steps:
- uses: actions/checkout@v4
- run: pip install codespell
Expand All @@ -65,9 +67,8 @@ jobs:
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
- run: git remote add -t $CI_DEFAULT_BRANCH --no-tags -f upstream https://github.com/signetlabdei/lorawan.git
- run: git log --pretty=%B HEAD...upstream/$CI_DEFAULT_BRANCH ^upstream/$CI_DEFAULT_BRANCH > git_messages.txt
# Check source code and commit messages
- run: codespell -f -C0 --skip="./experiments" ./

Expand Down
43 changes: 31 additions & 12 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,57 @@ on:

jobs:
# Clang-tidy
clang-tidy-17:
clang-tidy-18:
runs-on: ubuntu-latest
container:
image: ubuntu:rolling
timeout-minutes: 180
env:
CLANG_TIDY_OUTPUT: clang-tidy-output.log
CI_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
steps:
# The following step is required in all jobs that use this repo's actions
- name: "Retrieve actions from repository"
uses: actions/checkout@v4
with:
sparse-checkout: .github/actions
- name: "Install dependencies and checkout repo in ns-3"
uses: ./.github/actions/install-linting
- name: "Install required system packages"
run: >
apt update && DEBIAN_FRONTEND=noninteractive apt install -y
clang cmake
clang-tidy clang-tidy-18
git wget
- name: "Checkout this repository as ns-3 module"
uses: ./.github/actions/checkout-in-ns3
- name: "Configure ns-3 CMake"
run: >
./ns3 configure -d debug
--enable-examples --enable-tests --enable-asserts
--enable-modules "lorawan;applications"
--enable-clang-tidy
# Use a trick (git diff on empty tag) to only run clang-tidy on the lorawan module
--enable-examples --enable-tests --enable-asserts
--enable-modules lorawan
- name: "Prepare git environment"
run: >
if (git -C src/lorawan/ remote | grep -qw upstream) ; then
git -C src/lorawan/ remote remove upstream ;
fi &&
git -C src/lorawan/ remote add -t $CI_DEFAULT_BRANCH --no-tags -f upstream https://github.com/signetlabdei/lorawan.git
- name: "Running clang-tidy"
shell: bash
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-17.py -path cmake-cache/ -p1 -quiet -use-color
-iregex "src\/lorawan\/.+\.(cpp|cc|cxx|c|h|hpp)"
if [[ $GITHUB_REF_NAME == $CI_DEFAULT_BRANCH ]] ; then
echo "Running full clang-tidy" ;
run-clang-tidy-18 -p cmake-cache/ -quiet "src\/lorawan\/.+\.(cpp|cc|cxx|c|h|hpp)"
1> $CLANG_TIDY_OUTPUT
2> /dev/null ;
else
echo "Running clang-tidy-diff" ;
git -C src/lorawan/ diff -U0 upstream/$CI_DEFAULT_BRANCH --src-prefix=a/src/lorawan/ --dst-prefix=b/src/lorawan/ |
clang-tidy-diff-18.py -path cmake-cache/ -p1 -quiet -use-color -iregex "src\/lorawan\/.+\.(cpp|cc|cxx|c|h|hpp)"
1> $CLANG_TIDY_OUTPUT
2> /dev/null
2> /dev/null || true ;
fi
- name: "Trim empty lines from output file"
run: sed -i '/^$/d' $CLANG_TIDY_OUTPUT
- name: "Check job results"
run: |
(! egrep -v "file not found \[clang-diagnostic-error\]" $CLANG_TIDY_OUTPUT | egrep -A3 "error:|warning:|note:")
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/per-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ on:
workflow_dispatch:

jobs:
code-formatting:
formatting:
uses: ./.github/workflows/formatting.yml

compile:
needs: code-formatting
compilation:
needs: formatting
runs-on: ubuntu-latest
container:
image: archlinux
Expand Down Expand Up @@ -58,15 +58,15 @@ jobs:
name: "Test ns-3"
uses: ./.github/actions/test

code-linting:
needs: compile
linting:
needs: compilation
uses: ./.github/workflows/linting.yml

documentation:
needs: code-linting
needs: linting
uses: ./.github/workflows/test-doc.yml

code-analysis:
analysis:
needs: documentation
uses: ./.github/workflows/analysis.yml
secrets: inherit
Expand Down
2 changes: 1 addition & 1 deletion NS3-VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release ns-3.42
release ns-3.43
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,9 @@ Finally, ensure tests run smoothly with:
./test.py
```

If the script reports that all tests passed or that just `three-gpp-propagation-loss-model` failed[^1], you are good to go.
If the script reports that all tests passed you are good to go.

If other tests fail or crash, consider filing an issue.

[^1]: This is due to [a bug in the current ns-3 version](https://gitlab.com/nsnam/ns-3-dev/-/issues/965) when restricting compilation to the lorawan module and its dependencies. If you need to use the `three-gpp-propagation-loss-model`, you can solve this by compiling ns-3 as a whole or with the `--enable-modules "lorawan;applications"` option to reduce compilation time.
If some tests fail or crash, consider filing an issue.

## Usage examples

Expand Down
13 changes: 1 addition & 12 deletions examples/adr-example.cc
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
/*
* Copyright (c) 2018 University of Padova
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* SPDX-License-Identifier: GPL-2.0-only
*
* Author: Davide Magrin <[email protected]>
*/
Expand Down
13 changes: 1 addition & 12 deletions examples/aloha-throughput.cc
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
/*
* Copyright (c) 2017 University of Padova
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* SPDX-License-Identifier: GPL-2.0-only
*
* Author: Davide Magrin <[email protected]>
*/
Expand Down
16 changes: 4 additions & 12 deletions examples/complete-network-example.cc
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
/*
* Copyright (c) 2017 University of Padova
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* SPDX-License-Identifier: GPL-2.0-only
*
* Author: Davide Magrin <[email protected]>
*/
Expand Down Expand Up @@ -75,6 +64,9 @@ main(int argc, char* argv[])
CommandLine cmd(__FILE__);
cmd.AddValue("nDevices", "Number of end devices to include in the simulation", nDevices);
cmd.AddValue("radius", "The radius (m) of the area to simulate", radiusMeters);
cmd.AddValue("realisticChannel",
"Whether to use a more realistic channel model",
realisticChannelModel);
cmd.AddValue("simulationTime", "The time (s) for which to simulate", simulationTimeSeconds);
cmd.AddValue("appPeriod",
"The period in seconds to be used by periodically transmitting applications",
Expand Down
Loading

0 comments on commit 17b213f

Please sign in to comment.