Subversion Repositories ESP8266_P1_Meter

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 raymond 1
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2
 
3
name: (ESP8266) Build with PlatformIO
4
 
5
on:
6
  workflow_dispatch:
7
  push:
8
    branches:
9
      - dev
10
  pull_request:
11
 
12
concurrency:
13
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
14
  cancel-in-progress: true
15
 
16
jobs:
17
  platformio-esp8266:
18
    name: ESP8266 (pio) (board=${{ matrix.board }}, shard=${{ matrix.shard }})
19
    if: github.event_name == 'workflow_dispatch' || vars.ENABLE_BUILDS == 'true'
20
    runs-on: ubuntu-latest
21
    strategy:
22
      fail-fast: false
23
      matrix:
24
        board:
25
          - d1_mini
26
        shard: [1, 2, 3, 4]
27
 
28
    steps:
29
      - name: Checkout
30
        uses: actions/checkout@v4
31
 
32
      - name: Cache PlatformIO
33
        uses: actions/cache@v4
34
        with:
35
          key: ${{ runner.os }}-pio
36
          path: |
37
            ~/.cache/pip
38
            ~/.platformio
39
 
40
      - name: Python
41
        uses: actions/setup-python@v5
42
        with:
43
          python-version: "3.x"
44
 
45
      - name: Install PIO
46
        run: |
47
          python -m pip install --upgrade pip
48
          pip install --upgrade platformio
49
 
50
      - name: Build Examples
51
        run: |
52
          set -uo pipefail
53
 
54
          total_shards=4
55
          shard="${{ matrix.shard }}"
56
 
57
          # Examples not intended for ESP8266 / this job
58
          EXCLUDE_EXAMPLES=(
59
            esp32-cam
60
            binaryWebSocket
61
            csvLoggerSD
62
            localRFID
63
            mysqlRFID
64
            mqtt_webserver
65
          )
66
 
67
          report_file="build-report-esp8266-pio-${{ matrix.board }}-shard${{ matrix.shard }}.txt"
68
          : > "$report_file"
69
 
70
          failures=0
71
          total=0
72
          index=0
73
 
74
          for dir in examples/*; do
75
            if [[ ! -d "$dir" ]]; then
76
              continue
77
            fi
78
 
79
            example="$(basename "$dir")"
80
 
81
            if [[ " ${EXCLUDE_EXAMPLES[*]} " == *" ${example} "* ]]; then
82
              echo "Skipping: ${example}"
83
              printf '%-25s : SKIP\n' "${example}" >> "$report_file"
84
              continue
85
            fi
86
 
87
            # Split examples across shards for faster CI.
88
            index=$((index + 1))
89
            example_shard=$(( (index - 1) % total_shards + 1 ))
90
            if [[ "$example_shard" != "$shard" ]]; then
91
              continue
92
            fi
93
 
94
            total=$((total + 1))
95
 
96
            echo "============================================================="
97
            echo "Building examples/${example} (board=${{ matrix.board }}, shard=${shard})..."
98
            echo "============================================================="
99
 
100
            echo "::group::pio run - examples/${example}"
101
            set +e
102
            # Use a per-example build directory to avoid cross-example artefacts.
103
            PLATFORMIO_BUILD_DIR=".pio/build-${{ matrix.board }}-${example}" \
104
            PLATFORMIO_SRC_DIR="examples/${example}" PIO_BOARD="${{ matrix.board }}" \
105
              pio run -e ci-esp8266
106
            rc=$?
107
            set -e
108
            echo "::endgroup::"
109
 
110
            if [[ $rc -eq 0 ]]; then
111
              printf '%-25s : OK\n' "${example}" >> "$report_file"
112
            else
113
              failures=$((failures + 1))
114
              printf '%-25s : FAIL (exit=%s)\n' "${example}" "$rc" >> "$report_file"
115
            fi
116
          done
117
 
118
          echo ""
119
          echo "==================== Build report (esp8266/pio, board=${{ matrix.board }}, shard=${{ matrix.shard }}) ===================="
120
          cat "$report_file"
121
          echo "==============================================================================================="
122
          echo "Total attempted: ${total} | Failures: ${failures}"
123
 
124
          # Do not fail the job here: the final report job will decide.
125
 
126
      - name: Upload build report
127
        if: always()
128
        uses: actions/upload-artifact@v4
129
        with:
130
          name: pio-esp8266-report-${{ matrix.board }}-shard${{ matrix.shard }}
131
          path: build-report-esp8266-pio-${{ matrix.board }}-shard${{ matrix.shard }}.txt
132
 
133
  report:
134
    name: ESP8266 (pio) - Final report
135
    runs-on: ubuntu-latest
136
    needs: platformio-esp8266
137
    if: always() && needs.platformio-esp8266.result != 'skipped'
138
    steps:
139
      - name: Download all reports
140
        uses: actions/download-artifact@v4
141
        with:
142
          pattern: pio-esp8266-report-*
143
          merge-multiple: true
144
          path: reports
145
 
146
      - name: Print final report and set status
147
        run: |
148
          set -uo pipefail
149
          echo "==================== Final build report (ESP8266/pio) ===================="
150
          failures=0
151
          files=0
152
          shopt -s nullglob
153
          for f in reports/*.txt; do
154
            files=$((files + 1))
155
            echo "--- ${f} ---"
156
            cat "$f"
157
            if grep -q " : FAIL" "$f"; then
158
              failures=$((failures + 1))
159
            fi
160
          done
161
          if [[ $files -eq 0 ]]; then
162
            echo "No report files found (artifact download failed?)"
163
            exit 1
164
          fi
165
          echo "==========================================================================="
166
          if [[ $failures -gt 0 ]]; then
167
            echo "One or more shards reported FAIL."
168
            exit 1
169
          fi
170