|
| 1 | +name: Cheking of compile Arduino sketch for AVR/AtMega |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main, master] |
| 6 | + |
| 7 | +env: |
| 8 | + platform: "arduino:avr" |
| 9 | + fqbn_master: "arduino:avr:mega" |
| 10 | + COMMIT_COUNT: $(( ${{ github.event_name == 'pull_request' && github.event.pull_request.commits || 0 }} + 1 )) |
| 11 | + |
| 12 | +jobs: |
| 13 | + handle_bad_branch_name: |
| 14 | + runs-on: ubuntu-22.04 |
| 15 | + if: (contains(github.head_ref, 'mc_lab_1') || contains(github.head_ref, 'mc_lab_2') || contains(github.head_ref, 'mc_lab_3') || contains(github.head_ref, 'mc_lab_4') || contains(github.head_ref, 'mc_lab_5') || contains(github.head_ref, 'mc_lab_6') || contains(github.head_ref, 'mc_lab_7')) == false |
| 16 | + steps: |
| 17 | + - name: Fail the build |
| 18 | + run: | |
| 19 | + echo "The branch name is not correct. It should contain 'mc_lab_' prefix" |
| 20 | + exit 1 |
| 21 | + build_labs_1_to_4: |
| 22 | + runs-on: ubuntu-22.04 |
| 23 | + if: contains(github.head_ref, 'mc_lab_1') || contains(github.head_ref, 'mc_lab_2') || contains(github.head_ref, 'mc_lab_3') || contains(github.head_ref, 'mc_lab_4') |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + fetch-depth: ${{ env.COMMIT_COUNT }} |
| 29 | + |
| 30 | + - name: Get changed files list |
| 31 | + uses: ./.github/actions/get_changed_files |
| 32 | + |
| 33 | + - name: Set up Arduino CLI |
| 34 | + uses: arduino/setup-arduino-cli@v2 |
| 35 | + |
| 36 | + - name: Install platform |
| 37 | + run: | |
| 38 | + arduino-cli core update-index |
| 39 | + arduino-cli core install ${{ env.platform }} |
| 40 | +
|
| 41 | + - name: Compile Sketch |
| 42 | + run: arduino-cli compile --fqbn ${{ env.fqbn_master }} $(grep -E '\.ino$' changed_files.txt | xargs) |
| 43 | + build_lab_5: |
| 44 | + runs-on: ubuntu-22.04 |
| 45 | + if: contains(github.head_ref, 'mc_lab_5') |
| 46 | + env: |
| 47 | + fqbn_slave: "arduino:avr:nano" |
| 48 | + steps: |
| 49 | + - name: Checkout |
| 50 | + uses: actions/checkout@v4 |
| 51 | + with: |
| 52 | + fetch-depth: ${{ env.COMMIT_COUNT }} |
| 53 | + |
| 54 | + - name: Get changed files list |
| 55 | + uses: ./.github/actions/get_changed_files |
| 56 | + |
| 57 | + - name: Get master folder |
| 58 | + run: | |
| 59 | + cat changed_files.txt | xargs dirname | grep 'master' | grep -m 1 -vE '/(.*master.*|.*slave.*)/' > master_project.txt |
| 60 | + echo "Master project:" |
| 61 | + cat master_project.txt |
| 62 | +
|
| 63 | + - name: Get slave folders |
| 64 | + run: | |
| 65 | + cat changed_files.txt | xargs dirname | grep 'slave' | grep -vE '/(.*master.*|.*slave.*)/' > slave_projects.txt |
| 66 | + echo "Slave projects:" |
| 67 | + cat slave_projects.txt |
| 68 | +
|
| 69 | + - name: Check if there is at least one master and one slave project |
| 70 | + run: | |
| 71 | + if [ ! -s master_project.txt ] || [ ! -s slave_projects.txt ]; then |
| 72 | + echo "There is no master or slave project" |
| 73 | + exit 1 |
| 74 | + fi |
| 75 | +
|
| 76 | + - name: Set up Arduino CLI |
| 77 | + uses: arduino/setup-arduino-cli@v2 |
| 78 | + |
| 79 | + - name: Install platform |
| 80 | + run: | |
| 81 | + arduino-cli core update-index |
| 82 | + arduino-cli core install ${{ env.platform }} |
| 83 | +
|
| 84 | + - name: Compile master |
| 85 | + run: while read master_folder; do arduino-cli compile --fqbn ${{ env.fqbn_master }} $master_folder/*.ino; done < master_project.txt |
| 86 | + |
| 87 | + - name: Compile slaves |
| 88 | + run: while read slave_folder; do arduino-cli compile --fqbn ${{ env.fqbn_slave }} $slave_folder/*.ino; done < slave_projects.txt |
| 89 | + build_lab_6: |
| 90 | + runs-on: ubuntu-22.04 |
| 91 | + if: contains(github.head_ref, 'mc_lab_6') |
| 92 | + steps: |
| 93 | + - name: Checkout |
| 94 | + uses: actions/checkout@v4 |
| 95 | + with: |
| 96 | + fetch-depth: ${{ env.COMMIT_COUNT }} |
| 97 | + |
| 98 | + - name: It just passes |
| 99 | + run: echo "It just passes. It's too complex" |
| 100 | + build_lab_7: |
| 101 | + runs-on: ubuntu-22.04 |
| 102 | + if: contains(github.head_ref, 'mc_lab_7') |
| 103 | + env: |
| 104 | + register-bindings: "m2560def.inc" |
| 105 | + steps: |
| 106 | + - name: Checkout |
| 107 | + uses: actions/checkout@v4 |
| 108 | + with: |
| 109 | + fetch-depth: ${{ env.COMMIT_COUNT }} |
| 110 | + |
| 111 | + - name: Get changed files list |
| 112 | + uses: ./.github/actions/get_changed_files |
| 113 | + |
| 114 | + - name: Setup AVRA Assembler |
| 115 | + run: | |
| 116 | + git clone https://github.com/Ro5bert/avra.git |
| 117 | + cd avra |
| 118 | + sudo make install |
| 119 | +
|
| 120 | + - name: Preprocess sketch - append register bindings to the top of the file |
| 121 | + run: printf ".include \"${{ env.register-bindings }}\"\n\n" | cat - $(grep -m 1 -E '\.(asm|S)$' changed_files.txt | xargs) > pipeline_main_assembly_source_file.asm |
| 122 | + |
| 123 | + - name: Compile Sketch |
| 124 | + run: avra pipeline_main_assembly_source_file.asm |
0 commit comments