Boards Test #163
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Boards Test | |
on: | |
workflow_dispatch: | |
pull_request: | |
paths: | |
- "boards.txt" | |
- ".github/workflows/boards.yml" | |
- ".github/scripts/find_boards.sh" | |
env: | |
# It's convenient to set variables for values used multiple times in the workflow | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
jobs: | |
setup-chunks: | |
name: Setup Chunks | |
runs-on: ubuntu-latest | |
outputs: | |
test-mode: ${{ env.TEST_MODE }} | |
test-chunks: ${{ steps.set-test-chunks.outputs.test-chunks }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Setup jq | |
uses: dcarbone/install-jq-action@e397bd87438d72198f81efd21f876461183d383a # v3.0.1 | |
- name: Determine test mode and find boards | |
run: | | |
if [ "${{ github.event_name }}" = "pull_request" ]; then | |
echo "TEST_MODE=new" >> "$GITHUB_ENV" | |
bash .github/scripts/find_boards.sh new ${{ github.repository }} ${{github.base_ref}} | |
else | |
echo "TEST_MODE=all" >> "$GITHUB_ENV" | |
bash .github/scripts/find_boards.sh all | |
fi | |
- id: set-test-chunks | |
name: Set Chunks | |
run: | | |
echo "test-chunks<<EOF" >> $GITHUB_OUTPUT | |
echo "$( jq -nc '${{ env.FQBNS }} | [_nwise( ${{ env.BOARD-COUNT }}/15 | ceil)] | to_entries | map({id: (.key + 1), chunk: .value})')" >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
test-boards: | |
name: Test Boards Chunk ${{ matrix.id }} | |
needs: setup-chunks | |
runs-on: ubuntu-latest | |
env: | |
REPOSITORY: | | |
- source-path: '.' | |
name: "espressif:esp32" | |
strategy: | |
fail-fast: false | |
matrix: | |
include: ${{ fromJSON(needs.setup-chunks.outputs.test-chunks) }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Echo FQBNS to file | |
run: echo "$FQBN" > fqbns.json | |
env: | |
FQBN: ${{ toJSON(matrix.chunk) }} | |
- name: Check if build.board is uppercase | |
if: ${{ env.TEST_MODE == 'new' }} | |
run: | | |
# Read FQBNs from the JSON file and check each one | |
invalid_boards="" | |
while IFS= read -r fqbn; do | |
board_name=$(echo "$fqbn" | awk -F':' '{print $NF}') | |
if grep -q "^$board_name.build.board=[A-Z0-9_]*$" boards.txt; then | |
echo "$board_name.build.board is valid."; | |
else | |
echo "Error: $board_name.build.board is not uppercase!"; | |
invalid_boards="$invalid_boards$board_name " | |
fi | |
done < <(jq -r '.[]' fqbns.json) | |
# If any boards are invalid, print them all and fail | |
if [ -n "$invalid_boards" ]; then | |
echo "The following boards have non-uppercase build.board entries:" | |
echo "$invalid_boards" | |
exit 1; | |
fi | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2 | |
with: | |
languages: cpp | |
build-mode: manual | |
config-file: ./.github/codeql/codeql-config.yml | |
- name: Compile sketch | |
uses: P-R-O-C-H-Y/compile-sketches@a62f069b92dc8f5053da4ac439ea6d1950cf6379 # main | |
with: | |
platforms: | | |
${{ env.REPOSITORY }} | |
multiple-fqbn: true | |
multiple-fqbn-path: "fqbns.json" | |
use-json-file: false | |
enable-deltas-report: false | |
enable-warnings-report: false | |
cli-compile-flags: | | |
- --warnings="all" | |
exit-on-fail: ${{ github.event_name == 'pull_request' }} | |
sketch-paths: "- ./libraries/ESP32/examples/CI/CIBoardsTest/CIBoardsTest.ino" | |
verbose: true | |
- name: Run CodeQL Analysis | |
uses: github/codeql-action/analyze@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2 | |
with: | |
category: "Boards Test: ${{ env.TEST_MODE }} chunk ${{ matrix.id }}" | |
output: sarif-results | |
upload: failure-only | |
- name: Filter CodeQL Results | |
uses: advanced-security/filter-sarif@v1 | |
with: | |
patterns: | | |
+**/* | |
-tools/** | |
input: sarif-results/cpp.sarif | |
output: sarif-results/cpp.sarif | |
- name: Upload filtered SARIF | |
uses: github/codeql-action/upload-sarif@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2 | |
with: | |
sarif_file: sarif-results/cpp.sarif | |
category: "Boards Test: ${{ env.TEST_MODE }} chunk ${{ matrix.id }}" | |