|
1 | | -# This is the name of the workflow, visible on GitHub UI. |
2 | 1 | name: build |
3 | 2 |
|
4 | | -# Here we tell GitHub to run the workflow when a commit |
5 | | -# is pushed or a Pull Request is opened. |
6 | 3 | on: [push, pull_request] |
7 | 4 |
|
8 | | -# This is the list of jobs that will be run concurrently. |
9 | | -# Since we use a build matrix, the actual number of jobs |
10 | | -# started depends on how many configurations the matrix |
11 | | -# will produce. |
12 | 5 | jobs: |
13 | | - # This is the name of the job - can be whatever. |
14 | 6 | build: |
15 | | - |
16 | | - # Here we tell GitHub that the jobs must be determined |
17 | | - # dynamically depending on a matrix configuration. |
18 | 7 | strategy: |
19 | 8 | matrix: |
20 | | - # The matrix will produce one job for each configuration |
21 | | - # parameter of type `arduino-platform`, in this case a |
22 | | - # total of 2. |
23 | | - arduino-platform: ["arduino:avr","esp8266:esp8266"] |
24 | | - # This is usually optional but we need to statically define the |
25 | | - # FQBN of the boards we want to test for each platform. In the |
26 | | - # future the CLI might automatically detect and download the core |
27 | | - # needed to compile against a certain FQBN, at that point the |
28 | | - # following `include` section will be useless. |
29 | | - include: |
30 | | - # This works like this: when the platform is "arduino:samd", the |
31 | | - # variable `fqbn` is set to "arduino:samd:nano_33_iot". |
32 | | - - arduino-platform: "arduino:avr" |
33 | | - fqbn: "arduino:avr:pro:cpu=8MHzatmega328" |
34 | | - - arduino-platform: "arduino:avr" |
35 | | - libraries: "LowPower_LowPowerLab" |
36 | | - - arduino-platform: "arduino:avr" |
37 | | - project_dir: "Firmware_Arduino" |
38 | | - |
39 | | - - arduino-platform: "esp8266:esp8266" |
40 | | - fqbn: "esp8266:esp8266:generic" |
41 | | - - arduino-platform: "esp8266:esp8266" |
42 | | - libraries: "LiquidCrystal_PCF8574" |
43 | | - - arduino-platform: "esp8266:esp8266" |
44 | | - project_dir: "Firmware_ESP8266" |
45 | | - |
46 | | - # This is the platform GitHub will use to run our workflow, we |
47 | | - # pick Windows for no particular reason. |
48 | | - runs-on: windows-latest |
| 9 | + project_dir: ["Firmware_Arduino", "Firmware_ESP8266"] |
| 10 | + runs-on: ubuntu-latest |
49 | 11 |
|
50 | | - # This is the list of steps this job will run. |
51 | 12 | steps: |
52 | | - # First of all, we clone the repo using the `checkout` action. |
53 | 13 | - name: Checkout |
54 | 14 | uses: actions/checkout@v4 |
55 | | - |
56 | | - # We use the `arduino/setup-arduino-cli` action to install and |
57 | | - # configure the Arduino CLI on the system. |
58 | | - - name: Setup Arduino CLI |
59 | | - uses: arduino/setup-arduino-cli@v1 |
60 | | - |
61 | | - # We then install the platform, which one will be determined |
62 | | - # dynamically by the build matrix. |
63 | | - - name: Install platform |
| 15 | + with: |
| 16 | + submodules: recursive |
| 17 | + |
| 18 | + - name: Setup Python |
| 19 | + uses: actions/setup-python@v5 |
| 20 | + with: |
| 21 | + python-version: "3.x" |
| 22 | + |
| 23 | + - name: Cache PlatformIO |
| 24 | + uses: actions/cache@v4 |
| 25 | + with: |
| 26 | + path: ~/.platformio |
| 27 | + key: pio-${{ runner.os }}-${{ hashFiles(format('{0}/platformio.ini', matrix.project_dir)) }} |
| 28 | + restore-keys: | |
| 29 | + pio-${{ runner.os }}- |
| 30 | +
|
| 31 | + - name: Install PlatformIO Core |
| 32 | + run: pip install -U platformio |
| 33 | + |
| 34 | + # Builds all environments defined in platformio.ini; use -e for environment matrix |
| 35 | + - name: Build ${{ matrix.project_dir }} |
| 36 | + working-directory: ${{ matrix.project_dir }} |
64 | 37 | run: | |
65 | | - arduino-cli core update-index --additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.json |
66 | | - arduino-cli core install ${{ matrix.arduino-platform }} --additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.json |
67 | | -
|
68 | | - # We then install the platform, which one will be determined |
69 | | - # dynamically by the build matrix. |
70 | | - - name: Install libraries |
71 | | - run: | |
72 | | - arduino-cli lib install ${{ matrix.libraries }} |
73 | | - arduino-cli lib list |
74 | | -
|
75 | | - # Update submodules |
76 | | - - name: Update submodules |
77 | | - run: | |
78 | | - git submodule update --init --recursive |
79 | | -
|
80 | | - # Finally, we compile the sketch, using the FQBN that was set |
81 | | - # in the build matrix. |
82 | | - - name: Compile Sketches |
83 | | - run: arduino-cli compile --fqbn ${{ matrix.fqbn }} --build-path "${{ matrix.project_dir }}/build" ./${{ matrix.project_dir }} |
| 38 | + pio run |
| 39 | + # If defining environment matrix: pio run -e ${{ matrix.env }} |
| 40 | + |
| 41 | + # Upload generated artifacts; hex for AVR; bin for ESP8266 |
| 42 | + - name: Upload artifacts |
| 43 | + if: always() |
| 44 | + uses: actions/upload-artifact@v4 |
| 45 | + with: |
| 46 | + name: ${{ matrix.project_dir }}-artifacts |
| 47 | + path: | |
| 48 | + ${{ matrix.project_dir }}/.pio/build/*/*.hex |
| 49 | + ${{ matrix.project_dir }}/.pio/build/*/*.bin |
| 50 | + ${{ matrix.project_dir }}/.pio/build/*/*.elf |
0 commit comments