summaryrefslogtreecommitdiff
path: root/.github/workflows/build-and-run.yml
blob: 0fefd5e9ee57fb6adf18cc7f29452c4cc2f88cbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Build and Run

on:
  workflow_dispatch:
  pull_request:
  push:
    branches:
      - master

jobs:
  Build-in-VM:
    #if: ${{ false }} # disable for now
    strategy:
      fail-fast: false
      matrix:
        distro: ["ubuntu-22.04", "ubuntu-20.04"]
    runs-on: ${{ matrix.distro }}
    steps:
      - name: Set vars for Ubuntu 20.04
        if: ${{ matrix.distro == 'ubuntu-20.04' }}
        run: |
          echo "DISTRO=ubuntu20.04" >> $GITHUB_ENV
          echo "CPACK_TYPE=Ubuntu20" >> $GITHUB_ENV
      - name: Set vars for Ubuntu 22.04
        if: ${{ matrix.distro == 'ubuntu-22.04' }}
        run: |
          echo "DISTRO=ubuntu22.04" >> $GITHUB_ENV
          echo "CPACK_TYPE=Ubuntu20" >> $GITHUB_ENV
      - name: Set common vars
        run: |
          echo UNAME_R=`uname -r` >> $GITHUB_ENV
          echo UNAME_M=`uname -m` >> $GITHUB_ENV;
      - name: Install build tools
        run: >
          sudo apt update && 
          sudo apt -y install git build-essential cmake gcc linux-headers-`uname -r` 
          libpcre3-dev libssl-dev liblua5.1-0-dev kmod
      - name: Check out repository code
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: mkdir build
        run: mkdir build
      - name: cmake
        working-directory: ./build
        run: >
          cmake -DBUILD_IPOE_DRIVER=TRUE -DBUILD_VLAN_MON_DRIVER=TRUE -DCMAKE_INSTALL_PREFIX=/usr 
          -DKDIR=/usr/src/linux-headers-`uname -r` 
          -DLUA=TRUE -DSHAPER=FALSE -DRADIUS=TRUE 
          -DCPACK_TYPE=${{ env.CPACK_TYPE }} ..
      - name: make
        working-directory: ./build
        run: make
      - name: Generate debian package
        working-directory: ./build
        run: cpack -G DEB
      - name: Rename accel-ppp deb package
        working-directory: ./build
        run: >
          mv -v accel-ppp.deb 
          accel-ppp_`git describe --tags --long | sed 's/^v//' | sed 's/-/+/' | sed 's/-/~/'`-1+${{ env.DISTRO }}_`uname -m`.deb
      - name: Install debian package
        working-directory: ./build
        run: sudo apt -y install ./accel-ppp*.deb
      - name: Copy default config
        run: sudo cp /etc/accel-ppp.conf.dist /etc/accel-ppp.conf
      - name: Start accel-ppp
        run: sudo systemctl start accel-ppp
      - name: Check accel-ppp running status
        run: sudo systemctl status accel-ppp
      - name: Check accel-ppp stat
        run: accel-cmd show stat
      - name: Upload .deb package as artifact
        uses: actions/upload-artifact@v3
        with:
          name: deb-package-${{ matrix.distro }}-${{ env.UNAME_M }}-${{ env.UNAME_R }}
          path: build/accel-ppp_*.deb
          if-no-files-found: error

  Build-in-Container:
    #if: ${{ false }} # disable for now
    strategy:
      fail-fast: false
      matrix:
        distro:
          [
            "debian:10",
            "debian:11",
            "debian:12",
            "debian:trixie",
            "ubuntu:20.04",
            "ubuntu:22.04",
          ]
    runs-on: ubuntu-latest
    container:
      image: ${{ matrix.distro }}
    steps:
      - name: Set distro-specific vars
        run: >
          HEADERS_SUFFIX=`uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/`;
          DISTRO=`echo ${{ matrix.distro }} |  sed 's/://'`;
          case "${{ matrix.distro }}" in
          debian:trixie) DISTRO=debian13; CPACK_TYPE=Debian13 ;;
          debian:12) DISTRO=debian12; CPACK_TYPE=Debian12 ;;
          debian:11) CPACK_TYPE=Debian11 ;;
          debian:10) CPACK_TYPE=Debian10 ;;
          ubuntu:22.04) CPACK_TYPE=Ubuntu22 ; HEADERS_SUFFIX=generic ;;
          ubuntu:20.04) CPACK_TYPE=Ubuntu20 ; HEADERS_SUFFIX=generic ;;
          esac;
          echo HEADERS_SUFFIX=$HEADERS_SUFFIX >> $GITHUB_ENV;
          echo DISTRO=$DISTRO >> $GITHUB_ENV;
          echo CPACK_TYPE=$CPACK_TYPE >> $GITHUB_ENV;
          echo UNAME_M=`uname -m` >> $GITHUB_ENV;
          cat $GITHUB_ENV
      - name: Install build tools
        run: >
          apt update && apt -y upgrade && apt -y dist-upgrade &&
          DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt -y install git build-essential cmake gcc 
          linux-headers-${{ env.HEADERS_SUFFIX }}
          libpcre3-dev libssl-dev liblua5.1-0-dev kmod
      - name: Get kernel name from headers
        run: >
          echo KERNEL_NAME=`ls -1 /usr/src/ | grep  'linux-headers.*${{ env.HEADERS_SUFFIX }}' | 
          sed 's/linux-headers-//'` >> $GITHUB_ENV;
          cat $GITHUB_ENV
      - name: Check out repository code
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: mkdir build
        run: mkdir build
      - name: Disable git security warnings
        run: git config --global --add safe.directory '*'
      - name: cmake
        working-directory: ./build
        run: >
          cmake -DBUILD_IPOE_DRIVER=TRUE -DBUILD_VLAN_MON_DRIVER=TRUE -DCMAKE_INSTALL_PREFIX=/usr 
          -DKDIR=/usr/src/linux-headers-${{ env.KERNEL_NAME }}
          -DMODULES_KDIR=${{ env.KERNEL_NAME }}
          -DLUA=TRUE -DSHAPER=FALSE -DRADIUS=TRUE 
          -DCPACK_TYPE=${{ env.CPACK_TYPE }} ..
      - name: make
        working-directory: ./build
        run: make
      - name: Generate debian package
        working-directory: ./build
        run: cpack -G DEB
      - name: Rename accel-ppp deb package
        working-directory: ./build
        run: >
          mv -v accel-ppp.deb 
          accel-ppp_`git describe --tags --long | sed 's/^v//' | sed 's/-/+/' | sed 's/-/~/'`-1+${{ env.DISTRO }}_${{ env.UNAME_M }}.deb
      - name: Install debian package
        working-directory: ./build
        run: apt -y install ./accel-ppp*.deb
      - name: Start accel-ppp with default config
        run: accel-pppd -d -c /etc/accel-ppp.conf.dist
      - name: Sleep for 1 sec
        run: sleep 1
      - name: Check accel-ppp stat
        run: accel-cmd show stat
      - name: Upload .deb package as artifact
        uses: actions/upload-artifact@v3
        with:
          name: deb-package-${{ env.DISTRO }}-${{ env.UNAME_M }}-${{ env.KERNEL_NAME }}
          path: build/accel-ppp_*.deb
          if-no-files-found: error