]> begriffs open source - cmsis/blob - .github/workflows/corevalidation.yml
Update workflows and build scripts
[cmsis] / .github / workflows / corevalidation.yml
1 name: CoreValidation
2 on:
3   workflow_dispatch:
4   pull_request:
5     paths: 
6       - .github/workflows/corevalidation.yml
7       - .github/workflows/corevalidation-report.yml
8       - CMSIS/Core/Include/**/*
9       - CMSIS/Core/Source/**/*
10       - CMSIS/CoreValidation/**/*
11   push:
12     branches: [main]
13   
14 concurrency:
15   group: ${{ github.workflow }}-${{ github.ref }}
16   cancel-in-progress: true
17
18 env:
19   IAR_VERSION: '9.40.2'
20
21 jobs:
22   build-and-run:
23     
24     strategy:
25       fail-fast: true
26       matrix:
27         compiler: [AC6, GCC, Clang, IAR]
28     
29     runs-on: ubuntu-latest
30
31     env:
32       ARM_UBL_ACTIVATION_CODE: ${{ secrets.ARM_UBL_ACTIVATION_CODE }}
33
34     steps:
35       - run: |
36           sudo add-apt-repository ppa:deadsnakes/ppa
37           sudo apt-get install libpython3.9
38
39       - uses: actions/checkout@v4
40
41       - working-directory: /home/runner
42         env:
43           GH_TOKEN: ${{ github.token }}
44         run: |
45           if [ -d Cortex_DFP ]; then
46             cd Cortex_DFP
47             git fetch origin main
48             git checkout -f origin/main
49           else
50             gh repo clone ARM-software/Cortex_DFP
51           fi
52
53       - uses: actions/setup-python@v4
54         with:
55           python-version: '3.10'    
56           cache: 'pip'
57
58       - name: Python requirements
59         run: |
60           pip install -r ./CMSIS/CoreValidation/Project/requirements.txt
61
62       - name: Cache vcpkg
63         uses: actions/cache@v3
64         with:
65           key: vcpkg-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ matrix.compiler }}
66           restore-keys: |
67             vcpkg-${{ runner.os }}-${{ runner.arch }}-
68           path: /home/runner/.vcpkg
69
70       - name: Install LLVM/Clang dependencies
71         if: matrix.compiler == 'Clang'
72         working-directory: /home/runner
73         run: |
74           sudo apt-get update
75           sudo apt-get install libtinfo5
76     
77       - name: Prepare vcpkg env
78         working-directory: ./CMSIS/CoreValidation/Project
79         run: |
80           . <(curl https://aka.ms/vcpkg-init.sh -L)
81           vcpkg x-update-registry --all
82           vcpkg activate
83
84       - name: Cache IAR Toolchain
85         uses: actions/cache@v3
86         if: matrix.compiler == 'IAR'
87         with:
88           key: bxarm-${{env.IAR_VERSION}}-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}
89           restore-keys: |
90             bxarm-${{env.IAR_VERSION}}-${{ runner.os }}-${{ runner.arch }}-
91           path: bxarm-${{env.IAR_VERSION}}.deb
92
93       - name: Install IAR Toolchain
94         if: matrix.compiler == 'IAR'
95         run: |
96           if [ ! -f bxarm-${{env.IAR_VERSION}}.deb ]; then
97             curl -LO http://files.iar.com/ftp/pub/box/bxarm-${{env.IAR_VERSION}}.deb
98           fi
99           sudo dpkg -i bxarm-${{env.IAR_VERSION}}.deb
100           echo "/opt/iarsystems/bxarm/arm/bin" >> "$GITHUB_PATH"
101           echo "IAR_TOOLCHAIN_${IAR_VERSION//./_}=/opt/iarsystems/bxarm/arm/bin" >> "$GITHUB_ENV"
102           # TODO: activate license
103
104       - name: Activate Arm tool license
105         working-directory: ./CMSIS/CoreValidation/Project
106         run: |
107           . /home/runner/.vcpkg/vcpkg-init
108           vcpkg activate
109           if [[ -n "${{ env.ARM_UBL_ACTIVATION_CODE }}" ]]; then
110             armlm activate --code ${{ env.ARM_UBL_ACTIVATION_CODE }}
111           else
112             armlm activate --server https://mdk-preview.keil.arm.com --product KEMDK-COM0
113           fi
114         
115       - name: Initialize CodeQL
116         if: matrix.compiler == 'GCC'
117         uses: github/codeql-action/init@v2
118         with:
119           languages: cpp
120           queries: security-and-quality
121
122       - uses: ammaraskar/gcc-problem-matcher@master
123         if: matrix.compiler == 'Clang' || matrix.compiler == 'GCC'
124
125       - name: Build
126         working-directory: ./CMSIS/CoreValidation/Project
127         run: |
128           . /home/runner/.vcpkg/vcpkg-init
129           vcpkg activate
130
131           echo "Register local Cortex_DFP pack"
132           cpackget add /home/runner/Cortex_DFP/ARM.Cortex_DFP.pdsc
133
134           echo "Build test projects ..."
135           ./build.py --verbose -c ${{ matrix.compiler }} build || echo "::warning::=== Some configurations failed to build! ==="
136
137       - name: Perform CodeQL Analysis
138         if: ${{ !cancelled() && matrix.compiler == 'GCC' }}
139         uses: github/codeql-action/analyze@v2
140
141       - name: Execute
142         if: ${{ env.ARM_UBL_ACTIVATION_CODE }}
143         working-directory: ./CMSIS/CoreValidation/Project
144         run: |
145           . /home/runner/.vcpkg/vcpkg-init
146           vcpkg activate
147       
148           echo "Run test projects ..."
149           ./build.py --verbose -c ${{ matrix.compiler }} -d "CM*" run || echo "::warning::==== Some configurations failed to run! ==="
150
151       - name: Deactivate Arm tool license
152         if: always()
153         working-directory: ./CMSIS/CoreValidation/Project
154         run: |
155           . /home/runner/.vcpkg/vcpkg-init
156           vcpkg activate
157           if [[ -n "${{ env.ARM_UBL_ACTIVATION_CODE }}" ]]; then
158             armlm deactivate --code ${{ env.ARM_UBL_ACTIVATION_CODE }}
159           else
160             armlm deactivate --product KEMDK-COM0
161           fi
162
163       - name: Archive Test Reports
164         if: ${{ !cancelled() && env.ARM_UBL_ACTIVATION_CODE }}
165         uses: actions/upload-artifact@v3
166         with:
167           name: test-results-${{ matrix.compiler }}
168           path: ./CMSIS/CoreValidation/Project/build/*.junit
169
170   event-file:
171     needs: [build-and-run]
172     runs-on: ubuntu-latest
173     steps:
174       - name: Archive event file
175         if: ${{ !cancelled() }}
176         uses: actions/upload-artifact@v3
177         with:
178           name: EventFile
179           path: ${{ github.event_path }}