diff --git a/.github/workflows/per_commit.yml b/.github/workflows/per_commit.yml new file mode 100644 index 000000000..5611e6962 --- /dev/null +++ b/.github/workflows/per_commit.yml @@ -0,0 +1,255 @@ +name: "CI" + +on: [push] +jobs: + Ubuntu: + runs-on: ubuntu-latest + outputs: + cache_misses: ${{ steps.ccache_results.outputs.cache_misses }} + steps: + - uses: actions/checkout@v1 + - name: Install required packages + run: | + sudo apt-get update + sudo apt-get -y install apt-utils + sudo apt-get -y install git gcc g++ cmake python make ninja-build + sudo apt-get -y install tcpdump libgsl-dev libxml2-dev + sudo apt-get -y install curl unzip tar + sudo apt-get -y install ccache + - name: Get timestamp + id: time + run: python3 -c "from datetime import datetime; print('::set-output name=time::'+datetime.now().strftime('%Y-%m-%d-%H-%M-%S'))" + - name: Restore ccache + id: ccache + uses: actions/cache@v1.1.0 + with: + path: .ccache + key: ubuntu-ci-${{steps.time.outputs.time}} + restore-keys: ubuntu-ci- + - name: Setup ccache + run: | + ccache --set-config=cache_dir="$GITHUB_WORKSPACE/.ccache" + ccache --set-config=max_size=400M + ccache --set-config=compression=true + ccache -z + - name: Configure CMake + run: | + mkdir cmake-cache + cd cmake-cache + cmake -DCMAKE_BUILD_TYPE=release -DNS3_EXAMPLES=ON -DNS3_TESTS=ON -DNS3_WARNINGS_AS_ERRORS=OFF -G"Ninja" .. + - name: Build ns-3 + run: | + cd cmake-cache + ninja + - name: Print ccache statistics + id: ccache_results + run: | + ccache -s + python3 -c "import re, subprocess;print('::set-output name=cache_misses::%d' % int(re.findall('cache_miss(.*)', subprocess.check_output(['ccache', '--print-stats']).decode())[0]))" + - name: Run tests and examples + if: steps.ccache_results.outputs.cache_misses != '0' + run: python3 test.py --no-build + + CodeQL: + runs-on: ubuntu-latest + needs: Ubuntu + if: needs.Ubuntu.outputs.cache_misses != '0' + strategy: + fail-fast: false + steps: + - name: Checkout repository + uses: actions/checkout@v2 + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: 'cpp' + - name: Install required packages + run: | + sudo apt-get update + sudo apt-get -y install apt-utils + sudo apt-get -y install git gcc g++ cmake python make ninja-build + sudo apt-get -y install tcpdump libgsl-dev libxml2-dev + sudo apt-get -y install curl unzip tar + sudo apt-get -y install ccache + - name: Get timestamp + id: time + run: python3 -c "from datetime import datetime; print('::set-output name=time::'+datetime.now().strftime('%Y-%m-%d-%H-%M-%S'))" + - name: Restore ccache + id: ccache + uses: actions/cache@v1.1.0 + with: + path: .ccache + key: ubuntu-ci-${{steps.time.outputs.time}} + restore-keys: ubuntu-ci- + - name: Setup ccache + run: | + ccache --set-config=cache_dir="$GITHUB_WORKSPACE/.ccache" + ccache --set-config=max_size=400M + ccache --set-config=compression=true + ccache -z + - name: Configure CMake + run: | + mkdir cmake-cache + cd cmake-cache + cmake -DCMAKE_BUILD_TYPE=release -DNS3_EXAMPLES=ON -DNS3_TESTS=ON -DNS3_WARNINGS_AS_ERRORS=OFF -G"Ninja" .. + - name: Build ns-3 + run: | + cd cmake-cache + ninja + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + + Codecov: + runs-on: ubuntu-latest + needs: Ubuntu + if: needs.Ubuntu.outputs.cache_misses != '0' + steps: + - uses: actions/checkout@v1 + - name: Install required packages + run: | + sudo apt-get update + sudo apt-get -y install apt-utils + sudo apt-get -y install git gcc g++ cmake python3 make ninja-build + sudo apt-get -y install tcpdump libgsl-dev libxml2-dev + sudo apt-get -y install curl unzip tar + sudo apt-get -y install ccache + sudo apt-get -y install lcov + - name: Get timestamp + id: time + run: python3 -c "from datetime import datetime; print('::set-output name=time::'+datetime.now().strftime('%Y-%m-%d-%H-%M-%S'))" + - name: Restore ccache + id: ccache + uses: actions/cache@v1.1.0 + with: + path: .ccache + key: ubuntu-coverage-${{steps.time.outputs.time}} + restore-keys: ubuntu-coverage- + - name: Setup ccache + run: | + ccache --set-config=cache_dir="$GITHUB_WORKSPACE/.ccache" + ccache --set-config=max_size=400M + ccache --set-config=compression=true + ccache -z + - name: Configure CMake + run: | + mkdir cmake-cache + cd cmake-cache + cmake -DCMAKE_BUILD_TYPE=relwithdebinfo -DNS3_EXAMPLES=ON -DNS3_TESTS=ON -DNS3_COVERAGE=ON -DNS3_WARNINGS_AS_ERRORS=OFF -G"Ninja" .. + - name: Build ns-3 + run: | + cd cmake-cache + cmake --build . -j3 + - name: Print ccache statistics + id: ccache_results + run: | + ccache -s + python3 -c "import re, subprocess;print('::set-output name=cache_misses::%d' % int(re.findall('cache_miss(.*)', subprocess.check_output(['ccache', '--print-stats']).decode())[0]))" + - name: Generate coverage data and submit to codecov.io + if: steps.ccache_results.outputs.cache_misses != '0' + run: | + cd cmake-cache + ninja coverage_gcc + cd ../build/coverage + bash <(curl -s https://codecov.io/bash) -f ns3.info || echo "Codecov did not collect coverage reports" + + Windows_MinGW: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + steps: + - uses: actions/checkout@v1 + - uses: msys2/setup-msys2@v2 + - name: Install required msys2/mingw64 packages + run: | + pacman -S --noconfirm unzip + pacman -S --noconfirm tar + pacman -S --noconfirm mingw-w64-x86_64-curl + pacman -S --noconfirm mingw-w64-x86_64-binutils + pacman -S --noconfirm mingw-w64-x86_64-cmake + pacman -S --noconfirm mingw-w64-x86_64-gcc + pacman -S --noconfirm mingw-w64-x86_64-ninja + pacman -S --noconfirm mingw-w64-x86_64-python + pacman -S --noconfirm mingw-w64-x86_64-ccache + pacman -S --noconfirm mingw-w64-x86_64-gsl + pacman -S --noconfirm mingw-w64-x86_64-libxml2 + pacman -S --noconfirm mingw-w64-x86_64-lld + pacman --noconfirm -Scc + - name: Get timestamp + id: time + run: python -c "from datetime import datetime; print('::set-output name=time::'+datetime.now().strftime('%Y-%m-%d-%H-%M-%S'))" + - name: Restore ccache + id: ccache + uses: actions/cache@v1.1.0 + with: + path: .ccache + key: msys2-${{steps.time.outputs.time}} + restore-keys: msys2- + - name: Setup ccache + run: | + ccache --set-config=cache_dir="$GITHUB_WORKSPACE/.ccache" + ccache --set-config=max_size=400M + ccache --set-config=compression=true + ccache -z + - name: Configure CMake + run: | + mkdir cmake-cache + cd cmake-cache + cmake -DCMAKE_BUILD_TYPE=release -DNS3_EXAMPLES=ON -DNS3_TESTS=ON -DNS3_WARNINGS_AS_ERRORS=OFF -G"Ninja" .. + - name: Build ns-3 + run: | + cd cmake-cache + ninja + - name: Print ccache statistics + id: ccache_results + run: | + ccache -s + python3 -c "import re, subprocess;print('::set-output name=cache_misses::%d' % int(re.findall('cache_miss(.*)', subprocess.check_output(['ccache', '--print-stats']).decode())[0]))" + - name: Run tests and examples + if: steps.ccache_results.outputs.cache_misses != '0' + run: python test.py --no-build + + Mac_OS_X: + runs-on: macos-latest + steps: + - uses: actions/checkout@v1 + - name: Install required packages + run: | + brew install ninja cmake ccache libxml2 gsl open-mpi #qt5 + - name: Get timestamp + id: time + run: python3 -c "from datetime import datetime; print('::set-output name=time::'+datetime.now().strftime('%Y-%m-%d-%H-%M-%S'))" + - name: Restore ccache + id: ccache + uses: actions/cache@v1.1.0 + with: + path: .ccache + key: osx_brew-ci-${{steps.time.outputs.time}} + restore-keys: osx_brew-ci- + - name: Setup ccache + run: | + export PATH=/usr/local/bin:$PATH #:/usr/local/opt/qt/bin + ccache --set-config=cache_dir="$GITHUB_WORKSPACE/.ccache" + ccache --set-config=max_size=400M + ccache --set-config=compression=true + ccache -z + - name: Configure CMake + run: | + export PATH=/usr/local/bin:$PATH #:/usr/local/opt/qt/bin + mkdir cmake-cache + cd cmake-cache + cmake -DCMAKE_BUILD_TYPE=release -DNS3_EXAMPLES=ON -DNS3_TESTS=ON -DNS3_WARNINGS_AS_ERRORS=OFF -G"Ninja" .. + - name: Build ns-3 + run: | + export PATH="$PATH" #:/usr/local/opt/qt/bin + cd cmake-cache + ninja + - name: Print ccache statistics + id: ccache_results + run: | + ccache -s + python3 -c "import re, subprocess;print('::set-output name=cache_misses::%d' % int(re.findall('cache_miss(.*)', subprocess.check_output(['ccache', '--print-stats']).decode())[0]))" + - name: Run tests and examples + if: steps.ccache_results.outputs.cache_misses != '0' + run: python3 test.py --no-build