Skip to content

Commit 323a91d

Browse files
committed
Add first pipeline check
1 parent 8ce7784 commit 323a91d

File tree

5 files changed

+145
-38
lines changed

5 files changed

+145
-38
lines changed

.github/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: "Get changed files list"
2+
description: "Setup Node with caching for dependencies"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Set up Arduino CLI
7+
uses: arduino/setup-arduino-cli@v2
8+
9+
- name: Install platform
10+
run: |
11+
arduino-cli core update-index
12+
arduino-cli core install ${{ env.platform }}
13+
shell: bash
14+
15+
- name: Install popular libs
16+
run: |
17+
arduino-cli lib install LiquidCrystal
18+
shell: bash
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: "Get changed files list"
2+
description: "Setup Node with caching for dependencies"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Get changed files list
7+
id: get_changed_files
8+
run: |
9+
echo "Changed files:"
10+
git diff --name-only ${{ github.event.pull_request.base.sha }} > changed_files.txt
11+
cat changed_files.txt
12+
echo "The list is saved to changed_files.txt"
13+
shell: bash

.github/workflows/Lab_01_CI.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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: ./.github/actions/avr_setup
35+
36+
- name: Compile Sketch
37+
run: arduino-cli compile --fqbn ${{ env.fqbn_master }} $(grep -E '\.ino$' changed_files.txt | xargs)
38+
build_lab_5:
39+
runs-on: ubuntu-22.04
40+
if: contains(github.head_ref, 'mc_lab_5')
41+
env:
42+
fqbn_slave: "arduino:avr:nano"
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v4
46+
with:
47+
fetch-depth: ${{ env.COMMIT_COUNT }}
48+
49+
- name: Get changed files list
50+
uses: ./.github/actions/get_changed_files
51+
52+
- name: Get master folder
53+
run: |
54+
cat changed_files.txt | xargs dirname | grep 'master' | grep -m 1 -vE '/(.*master.*|.*slave.*)/' > master_project.txt
55+
echo "Master project:"
56+
cat master_project.txt
57+
58+
- name: Get slave folders
59+
run: |
60+
cat changed_files.txt | xargs dirname | grep 'slave' | grep -vE '/(.*master.*|.*slave.*)/' > slave_projects.txt
61+
echo "Slave projects:"
62+
cat slave_projects.txt
63+
64+
- name: Check if there is at least one master and one slave project
65+
run: |
66+
if [ ! -s master_project.txt ] || [ ! -s slave_projects.txt ]; then
67+
echo "There is no master or slave project"
68+
exit 1
69+
fi
70+
71+
- name: Set up Arduino CLI
72+
uses: ./.github/actions/avr_setup
73+
74+
- name: Compile master
75+
run: while read master_folder; do arduino-cli compile --fqbn ${{ env.fqbn_master }} $master_folder/*.ino; done < master_project.txt
76+
77+
- name: Compile slaves
78+
run: while read slave_folder; do arduino-cli compile --fqbn ${{ env.fqbn_slave }} $slave_folder/*.ino; done < slave_projects.txt
79+
build_lab_6:
80+
runs-on: ubuntu-22.04
81+
if: contains(github.head_ref, 'mc_lab_6')
82+
steps:
83+
- name: Checkout
84+
uses: actions/checkout@v4
85+
with:
86+
fetch-depth: ${{ env.COMMIT_COUNT }}
87+
88+
- name: It just passes
89+
run: echo "It just passes. It's too complex"
90+
build_lab_7:
91+
runs-on: ubuntu-22.04
92+
if: contains(github.head_ref, 'mc_lab_7')
93+
env:
94+
register-bindings: "m2560def.inc"
95+
steps:
96+
- name: Checkout
97+
uses: actions/checkout@v4
98+
with:
99+
fetch-depth: ${{ env.COMMIT_COUNT }}
100+
101+
- name: Get changed files list
102+
uses: ./.github/actions/get_changed_files
103+
104+
- name: Setup AVRA Assembler
105+
run: |
106+
git clone https://github.com/Ro5bert/avra.git
107+
cd avra
108+
sudo make install
109+
110+
- name: Preprocess sketch - append register bindings to the top of the file
111+
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
112+
113+
- name: Compile Sketch
114+
run: avra pipeline_main_assembly_source_file.asm

0 commit comments

Comments
 (0)