|
| 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" ./ |
0 commit comments