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 Arduino CLI
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
  arduino-esp8266:
18
    name: ESP8266 (arduino-cli) (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
        shard: [1, 2, 3, 4]
25
    steps:
26
      - name: Checkout
27
        uses: actions/checkout@v4
28
 
29
      - name: Install arduino-cli
30
        run: curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/usr/local/bin sh
31
 
32
      - name: Cache Arduino CLI data
33
        uses: actions/cache@v4
34
        with:
35
          key: ${{ runner.os }}-arduino-esp8266-${{ hashFiles('.github/workflows/cli-build-esp8266.yml') }}-${{ github.run_id }}-${{ matrix.shard }}
36
          restore-keys: |
37
            ${{ runner.os }}-arduino-esp8266-${{ hashFiles('.github/workflows/cli-build-esp8266.yml') }}-
38
            ${{ runner.os }}-arduino-esp8266-
39
          path: |
40
            ~/.arduino15
41
            ~/Arduino
42
            ~/.cache/arduino-cli
43
 
44
      - name: Update core index
45
        run: arduino-cli core update-index --additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.json
46
 
47
      - name: Install core
48
        run: arduino-cli core install --additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.json esp8266:esp8266
49
 
50
      - name: Install ESPAsyncTCP (ESP8266)
51
        run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/ESP32Async/ESPAsyncTCP#v2.0.0
52
 
53
      - name: Install ESPAsyncWebServer
54
        run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/ESP32Async/ESPAsyncWebServer#v3.7.3
55
 
56
      - name: Install ArduinoJson
57
        run: arduino-cli lib install ArduinoJson
58
 
59
      - name: Build Examples
60
        run: |
61
          set -uo pipefail
62
 
63
          total_shards=4
64
          shard="${{ matrix.shard }}"
65
 
66
          # Examples not intended for ESP8266 / this job
67
          EXCLUDE_EXAMPLES=(
68
            esp32-cam
69
            binaryWebSocket
70
            csvLoggerSD
71
            localRFID
72
            mysqlRFID
73
            mqtt_webserver
74
          )
75
 
76
          report_file="build-report-esp8266-arduino-cli-shard${{ matrix.shard }}.txt"
77
          : > "$report_file"
78
 
79
          failures=0
80
          total=0
81
          index=0
82
 
83
          for dir in examples/*; do
84
            if [[ ! -d "$dir" ]]; then
85
              continue
86
            fi
87
 
88
            example="$(basename "$dir")"
89
 
90
            if [[ " ${EXCLUDE_EXAMPLES[*]} " == *" ${example} "* ]]; then
91
              echo "Skipping: ${example}"
92
              printf '%-25s : SKIP\n' "${example}" >> "$report_file"
93
              continue
94
            fi
95
 
96
            # Split examples across shards for faster CI.
97
            index=$((index + 1))
98
            example_shard=$(( (index - 1) % total_shards + 1 ))
99
            if [[ "$example_shard" != "$shard" ]]; then
100
              continue
101
            fi
102
 
103
            sketch="examples/${example}/${example}.ino"
104
            total=$((total + 1))
105
 
106
            echo "============================================================="
107
            echo "Building ${sketch}..."
108
            echo "============================================================="
109
 
110
            if [[ ! -f "$sketch" ]]; then
111
              failures=$((failures + 1))
112
              printf '%-25s : FAIL (missing %s)\n' "${example}" "${sketch}" >> "$report_file"
113
              continue
114
            fi
115
 
116
            echo "::group::arduino-cli compile - ${example}"
117
            set +e
118
            arduino-cli compile \
119
              --library . \
120
              --warnings none \
121
              --build-cache-path "$HOME/.cache/arduino-cli" \
122
              -b esp8266:esp8266:huzzah \
123
              "$sketch"
124
            rc=$?
125
            set -e
126
            echo "::endgroup::"
127
 
128
            if [[ $rc -eq 0 ]]; then
129
              printf '%-25s : OK\n' "${example}" >> "$report_file"
130
            else
131
              failures=$((failures + 1))
132
              printf '%-25s : FAIL (exit=%s)\n' "${example}" "$rc" >> "$report_file"
133
            fi
134
          done
135
 
136
          echo ""
137
          echo "==================== Build report (esp8266/arduino-cli) ===================="
138
          cat "$report_file"
139
          echo "============================================================================="
140
          echo "Total attempted: ${total} | Failures: ${failures}"
141
 
142
          # Do not fail the job here: the final report job will decide.
143
 
144
      - name: Upload build report
145
        if: always()
146
        uses: actions/upload-artifact@v4
147
        with:
148
          name: arduino-cli-esp8266-report-shard${{ matrix.shard }}
149
          path: build-report-esp8266-arduino-cli-shard${{ matrix.shard }}.txt
150
 
151
  report:
152
    name: ESP8266 (arduino-cli) - Final report
153
    runs-on: ubuntu-latest
154
    needs: arduino-esp8266
155
    if: always() && needs.arduino-esp8266.result != 'skipped'
156
    steps:
157
      - name: Download all reports
158
        uses: actions/download-artifact@v4
159
        with:
160
          pattern: arduino-cli-esp8266-report-*
161
          merge-multiple: true
162
          path: reports
163
 
164
      - name: Print final report and set status
165
        run: |
166
          set -uo pipefail
167
          echo "==================== Final build report (ESP8266/arduino-cli) ===================="
168
          failures=0
169
          files=0
170
          shopt -s nullglob
171
          for f in reports/*.txt; do
172
            files=$((files + 1))
173
            echo "--- ${f} ---"
174
            cat "$f"
175
            if grep -q " : FAIL" "$f"; then
176
              failures=$((failures + 1))
177
            fi
178
          done
179
          if [[ $files -eq 0 ]]; then
180
            echo "No report files found (artifact download failed?)"
181
            exit 1
182
          fi
183
          echo "==========================================================================="
184
          if [[ $failures -gt 0 ]]; then
185
            echo "One or more shards reported FAIL."
186
            exit 1
187
          fi