1name: build & test
2
3on: [push, pull_request]
4
5jobs:
6# This workflow contains 2 jobs build and test
7
8  build:
9    name: Build uoscore-uedhoc
10    runs-on: ubuntu-latest
11
12    steps:
13      - name: Install Zephyr tools
14        run: |
15          wget https://apt.kitware.com/kitware-archive.sh
16          sudo bash kitware-archive.sh
17          sudo apt install --no-install-recommends git cmake ninja-build gperf ccache dfu-util device-tree-compiler wget python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1 lcov gdb
18          cmake --version
19          python3 --version
20          dtc --version
21
22          pip3 install tabulate
23          sudo apt install python3-venv
24          python3 -m venv ~/zephyrproject/.venv
25          source ~/zephyrproject/.venv/bin/activate
26
27          pip3 install west
28          west init ~/zephyrproject
29          cd ~/zephyrproject
30          west update
31
32          west zephyr-export
33
34          pip install -r ~/zephyrproject/zephyr/scripts/requirements.txt
35
36
37          cd ~
38          wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/zephyr-sdk-0.16.3_linux-x86_64.tar.xz
39          wget -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/sha256.sum | shasum --check --ignore-missing
40
41          tar xvf zephyr-sdk-0.16.3_linux-x86_64.tar.xz
42          cd zephyr-sdk-0.16.3
43          /bin/bash -c "yes | ./setup.sh"
44
45      - name: Checkout code
46        uses: actions/checkout@v2
47        with:
48          submodules: recursive
49
50### build, test and archive
51# native_posix (0x68)
52      - name: Build native_posix
53        run: |
54           source ~/zephyrproject/zephyr/zephyr-env.sh
55           source ~/zephyrproject/.venv/bin/activate
56           cd test/
57           bash ci_scripts/test_build_options.sh
58
59      - name: Archive static lib
60        uses: actions/upload-artifact@v2
61        with:
62          name: uoscore-uedhoc-x86
63          path: test/build/uoscore_uedhoc/libuoscore-uedhoc.a
64
65# native_posix_64
66      - name: Build native_posix_64
67        run: |
68           source ~/zephyrproject/zephyr/zephyr-env.sh
69           source ~/zephyrproject/.venv/bin/activate
70           cd test/
71           rm -rf build
72           rm -rf build_lib_test
73           west build -b=native_posix_64
74           west build -t run
75
76      - name: Archive static lib
77        uses: actions/upload-artifact@v2
78        with:
79          name: uoscore-uedhoc-x86-64
80          path: test/build/uoscore_uedhoc/libuoscore-uedhoc.a
81
82### Generate ROM report
83      - name: Genrate ROM report
84        run: |
85           source ~/zephyrproject/zephyr/zephyr-env.sh
86           source ~/zephyrproject/.venv/bin/activate
87           cd test/
88           bash ci_scripts/flash_report_gen.sh
89
90      - name: Upload rom report with tinycrypt
91        uses: actions/upload-artifact@v2
92        with: 
93          name: rom-report-tinycrypt-crypto
94          path: test/build_reports/rom_report_nrf91_with_tinycrypt.txt
95
96      - name: Upload rom report with mbedtls
97        uses: actions/upload-artifact@v2
98        with: 
99          name: rom-report-mbedtls-crypto
100          path: test/build_reports/rom_report_nrf91_with_mbedtls.txt
101
102### Generate stack report
103      - name: Genrate stack report
104        run: |
105           source ~/zephyrproject/zephyr/zephyr-env.sh
106           source ~/zephyrproject/.venv/bin/activate
107           cd test/
108           bash ci_scripts/stack_report_gen.sh
109
110      - name: Upload stack report
111        uses: actions/upload-artifact@v2
112        with: 
113          name: stack-report
114          path: test/build_reports/stack_report.html
115
116### Generate test coverage report
117      - name: Build native_posix with coverage information
118        run: |
119           source ~/zephyrproject/zephyr/zephyr-env.sh
120           source ~/zephyrproject/.venv/bin/activate
121           cd test/
122           rm -rf build
123           rm -rf build_lib_test
124           west build -b native_posix -- -DCONFIG_COVERAGE=y
125           west build -t run
126           lcov --capture --directory ./ --output-file lcov.info -q --rc lcov_branch_coverage=1
127           genhtml lcov.info --output-directory lcov_html -q --ignore-errors source --branch-coverage --highlight --legend
128           tar -zcvf github-pages.tar.gz lcov_html
129
130      - name: Upload test coverage report
131        uses: actions/upload-pages-artifact@v1
132        with: 
133          name: github-pages
134          path: test/lcov_html
135
136
137  # Deploy job
138  deploy:
139    # Add a dependency to the build job
140    needs: build
141
142    # Grant GITHUB_TOKEN the permissions required to make a Pages deployment
143    permissions:
144      pages: write      # to deploy to Pages
145      id-token: write   # to verify the deployment originates from an appropriate source
146
147    # Deploy to the github-pages environment
148    environment:
149      name: github-pages
150      url: ${{ steps.deployment.outputs.page_url }}
151
152    # Specify runner + deployment step
153    runs-on: ubuntu-latest
154    steps:
155      - name: Deploy to GitHub Pages
156        id: deployment
157        uses: actions/deploy-pages@v1