1- name : Build Release
1+ name : Check, test, build release zip, publish docs
22
33on :
44 push :
5- branches : [main, "release-*"]
65 pull_request :
7- branches : ["main"]
6+ workflow_call :
87
98env :
109 CARGO_TERM_COLOR : always
1312 FILE_RAYHUNTER_DAEMON_TPLINK : ../../rayhunter-daemon-tplink/rayhunter-daemon
1413
1514jobs :
15+ files_changed :
16+ name : Detect file changes
17+ runs-on : ubuntu-latest
18+ permissions :
19+ contents : read
20+ outputs :
21+ code_changed : ${{ steps.files_changed.outputs.code_count }}
22+ daemon_changed : ${{ steps.files_changed.outputs.daemon_count }}
23+ docs_changed : ${{ steps.files_changed.outputs.docs_count }}
24+ installer_changed : ${{ steps.files_changed.outputs.installer_count }}
25+ rootshell_changed : ${{ steps.files_changed.outputs.rootshell_count }}
26+ steps :
27+ - uses : actions/checkout@v4
28+ with :
29+ fetch-depth : 0
30+ - name : detect file changes
31+ id : files_changed
32+ run : |
33+ lcommit=${{ github.event.pull_request.base.sha || 'origin/main' }}
34+ if [ ${{ github.ref }} = 'refs/heads/main' ]
35+ then
36+ echo "building everything"
37+ echo code_count=forced >> "$GITHUB_OUTPUT"
38+ echo daemon_count=forced >> "$GITHUB_OUTPUT"
39+ echo docs_count=forced >> "$GITHUB_OUTPUT"
40+ echo installer_count=forced >> "$GITHUB_OUTPUT"
41+ echo rootshell_count=forced >> "$GITHUB_OUTPUT"
42+ else
43+ echo "code_count=$(git diff --name-only $lcommit...HEAD | grep -e ^bin -e ^installer -e ^lib -e ^rootshell -e ^telcom-parser | wc -l)" >> "$GITHUB_OUTPUT"
44+ echo "daemon_count=$(git diff --name-only $lcommit...HEAD | grep -e ^bin -e ^lib -e ^telcom-parser | wc -l)" >> "$GITHUB_OUTPUT"
45+ echo "docs_count=$(git diff --name-only $lcommit...HEAD | grep -e ^book.toml -e ^doc | wc -l)" >> "$GITHUB_OUTPUT"
46+ echo "installer_count=$(git diff --name-only $lcommit...HEAD | grep -e ^installer | wc -l)" >> "$GITHUB_OUTPUT"
47+ echo "rootshell_count=$(git diff --name-only $lcommit...HEAD | grep -e ^rootshell | wc -l)" >> "$GITHUB_OUTPUT"
48+ fi
49+
50+ mdbook_test :
51+ name : Test mdBook Documentation builds
52+ needs : files_changed
53+ if : needs.files_changed.outputs.docs_changed != '0'
54+ runs-on : ubuntu-latest
55+ permissions :
56+ contents : read
57+ steps :
58+ - uses : actions/checkout@v4
59+ - name : Install mdBook
60+ run : |
61+ cargo install mdbook --no-default-features --features search --vers "^0.4" --locked
62+ - name : Test mdBook
63+ run : mdbook test
64+
65+ mdbook_publish :
66+ name : Publish mdBook to Github Pages
67+ needs : mdbook_test
68+ if : ${{ github.event_name != 'pull_request' }}
69+ permissions :
70+ pages : write
71+ contents : write
72+ id-token : write
73+ runs-on : ubuntu-latest
74+ steps :
75+ - uses : actions/checkout@v4
76+ - name : Install mdBook
77+ run : |
78+ cargo install mdbook --no-default-features --features search --vers "^0.4" --locked
79+
80+ - name : Build mdBook
81+ run : mdbook build
82+
83+ - name : Setup Pages
84+ uses : actions/configure-pages@v4
85+ - name : Upload artifact
86+ uses : actions/upload-pages-artifact@v3
87+ with :
88+ path : book
89+ - name : Deploy to Github Pages
90+ uses : actions/deploy-pages@v4
91+
92+ check_and_test :
93+ needs : files_changed
94+ if : needs.files_changed.outputs.code_changed != '0'
95+ strategy :
96+ matrix :
97+ device :
98+ - name : tplink
99+ - name : orbic
100+ runs-on : ubuntu-latest
101+ permissions :
102+ contents : read
103+ steps :
104+ - uses : actions/checkout@v4
105+ - name : Check formatting
106+ run : cargo fmt --all --check
107+ - name : Check
108+ run : |
109+ pushd bin/web
110+ npm install
111+ npm run build
112+ popd
113+ NO_FIRMWARE_BIN=true cargo check --verbose --no-default-features --features=${{ matrix.device.name }}
114+ - name : Run tests
115+ run : |
116+ NO_FIRMWARE_BIN=true cargo test --verbose --no-default-features --features=${{ matrix.device.name }}
117+ - name : Run clippy
118+ run : |
119+ NO_FIRMWARE_BIN=true cargo clippy --verbose --no-default-features --features=${{ matrix.device.name }}
120+
121+ windows_installer_check_and_test :
122+ needs : files_changed
123+ if : needs.files_changed.outputs.installer_changed != '0'
124+ runs-on : windows-latest
125+ permissions :
126+ contents : read
127+ steps :
128+ - uses : actions/checkout@v4
129+ - name : cargo check
130+ shell : bash
131+ run : |
132+ cd installer
133+ NO_FIRMWARE_BIN=true cargo check --verbose
134+ - name : cargo test
135+ shell : bash
136+ run : |
137+ cd installer
138+ NO_FIRMWARE_BIN=true cargo test --verbose --no-default-features
139+
16140 build_rayhunter_check :
141+ if : needs.files_changed.outputs.daemon_changed != '0'
142+ needs :
143+ - check_and_test
144+ - files_changed
145+ permissions :
146+ contents : read
147+ packages : write
17148 strategy :
18149 matrix :
19150 platform :
@@ -42,8 +173,15 @@ jobs:
42173 name : rayhunter-check-${{ matrix.platform.name }}
43174 path : target/release/rayhunter-check${{ matrix.platform.os == 'windows-latest' && '.exe' || '' }}
44175 if-no-files-found : error
176+
45177 build_rootshell :
178+ if : needs.files_changed.outputs.rootshell_changed != '0'
179+ needs :
180+ - check_and_test
181+ - files_changed
46182 runs-on : ubuntu-latest
183+ permissions :
184+ contents : read
47185 steps :
48186 - uses : actions/checkout@v4
49187 - uses : dtolnay/rust-toolchain@stable
@@ -56,7 +194,15 @@ jobs:
56194 name : rootshell
57195 path : target/armv7-unknown-linux-musleabihf/firmware/rootshell
58196 if-no-files-found : error
197+
59198 build_rayhunter :
199+ if : needs.files_changed.outputs.daemon_changed != '0'
200+ needs :
201+ - check_and_test
202+ - files_changed
203+ permissions :
204+ contents : read
205+ packages : write
60206 strategy :
61207 matrix :
62208 device :
@@ -88,9 +234,16 @@ jobs:
88234 name : rayhunter-daemon-${{ matrix.device.name }}
89235 path : target/armv7-unknown-linux-musleabihf/firmware/rayhunter-daemon
90236 if-no-files-found : error
237+
91238 build_rust_installer :
239+ if : needs.files_changed.outputs.installer_changed != '0'
240+ permissions :
241+ contents : read
242+ packages : write
92243 needs :
93244 - build_rayhunter
245+ - files_changed
246+ - windows_installer_check_and_test
94247 strategy :
95248 matrix :
96249 platform :
@@ -124,6 +277,9 @@ jobs:
124277 if-no-files-found : error
125278
126279 build_release_zip :
280+ permissions :
281+ contents : read
282+ packages : write
127283 needs :
128284 - build_rayhunter_check
129285 - build_rootshell
0 commit comments