Skip to content

Commit bba2f0b

Browse files
committed
Improve the CI workflow with caching and add timeout limit
1 parent b53a643 commit bba2f0b

2 files changed

Lines changed: 65 additions & 21 deletions

File tree

.github/workflows/release.yml

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ permissions:
1111

1212
env:
1313
CARGO_TERM_COLOR: always
14+
CARGO_INCREMENTAL: 0 # Disable incremental for release builds
1415

1516
jobs:
1617
create-release:
1718
runs-on: ubuntu-latest
19+
timeout-minutes: 5
1820
outputs:
1921
version: ${{ steps.get_version.outputs.version }}
2022
steps:
@@ -35,6 +37,7 @@ jobs:
3537
3638
### Features
3739
- Real-time CANopen SDO monitoring and plotting
40+
- TPDO listener with automatic data plotting
3841
- Comprehensive subscription management
3942
- Plot export (PNG screenshots and CSV data)
4043
- Automatic logging with timestamps
@@ -52,6 +55,8 @@ jobs:
5255
**Linux (Generic):**
5356
```bash
5457
# Extract and run executable
58+
tar xzf canopen-viewer-v${{ steps.get_version.outputs.version }}-x86_64-unknown-linux-gnu.tar.gz
59+
cd dist
5560
chmod +x canopen-viewer
5661
./canopen-viewer
5762
```
@@ -65,14 +70,15 @@ jobs:
6570
1. Set up your CAN interface (physical or virtual)
6671
2. Run the application
6772
3. Select interface, node ID, and EDS file
68-
4. Start monitoring and subscribe to SDO objects
73+
4. Start monitoring and subscribe to SDO objects or start TPDO listeners
6974
draft: false
7075
prerelease: false
7176
generate_release_notes: true
7277

7378
build-linux:
7479
needs: create-release
7580
runs-on: ubuntu-latest
81+
timeout-minutes: 30
7682
strategy:
7783
matrix:
7884
target: [x86_64-unknown-linux-gnu]
@@ -81,12 +87,10 @@ jobs:
8187
- name: Checkout code
8288
uses: actions/checkout@v4
8389

84-
- name: Set up Rust
85-
uses: actions-rs/toolchain@v1
90+
- name: Install Rust stable
91+
uses: dtolnay/rust-toolchain@stable
8692
with:
87-
toolchain: stable
88-
target: ${{ matrix.target }}
89-
override: true
93+
targets: ${{ matrix.target }}
9094

9195
- name: Install system dependencies
9296
run: |
@@ -100,17 +104,21 @@ jobs:
100104
pkg-config \
101105
build-essential
102106
107+
# CRITICAL: Cache Cargo to avoid rebuilding dependencies
108+
- name: Cache Cargo
109+
uses: Swatinem/rust-cache@v2
110+
with:
111+
shared-key: "canopen-viewer-release"
112+
cache-on-failure: false
113+
103114
- name: Update version in Cargo.toml
104115
run: |
105116
sed -i 's/version = "0\.1\.0"/version = "${{ needs.create-release.outputs.version }}"/' canopen-viewer/Cargo.toml
106117
sed -i 's/version = "0\.1\.0"/version = "${{ needs.create-release.outputs.version }}"/' canopen-common/Cargo.toml
107118
sed -i 's/version = "0\.1\.0"/version = "${{ needs.create-release.outputs.version }}"/' mock-canopen-node/Cargo.toml
108119
109120
- name: Build release binary
110-
uses: actions-rs/cargo@v1
111-
with:
112-
command: build
113-
args: --release --target ${{ matrix.target }} -p canopen-viewer
121+
run: cargo build --release --target ${{ matrix.target }} -p canopen-viewer
114122

115123
- name: Create binary archive
116124
run: |
@@ -129,16 +137,14 @@ jobs:
129137
build-deb-package:
130138
needs: create-release
131139
runs-on: ubuntu-latest
140+
timeout-minutes: 30
132141

133142
steps:
134143
- name: Checkout code
135144
uses: actions/checkout@v4
136145

137-
- name: Set up Rust
138-
uses: actions-rs/toolchain@v1
139-
with:
140-
toolchain: stable
141-
override: true
146+
- name: Install Rust stable
147+
uses: dtolnay/rust-toolchain@stable
142148

143149
- name: Install system dependencies
144150
run: |
@@ -154,17 +160,21 @@ jobs:
154160
dpkg-dev \
155161
fakeroot
156162
163+
# CRITICAL: Cache Cargo for deb builds too
164+
- name: Cache Cargo
165+
uses: Swatinem/rust-cache@v2
166+
with:
167+
shared-key: "canopen-viewer-deb"
168+
cache-on-failure: false
169+
157170
- name: Update version in Cargo.toml
158171
run: |
159172
sed -i 's/version = "0\.1\.0"/version = "${{ needs.create-release.outputs.version }}"/' canopen-viewer/Cargo.toml
160173
sed -i 's/version = "0\.1\.0"/version = "${{ needs.create-release.outputs.version }}"/' canopen-common/Cargo.toml
161174
sed -i 's/version = "0\.1\.0"/version = "${{ needs.create-release.outputs.version }}"/' mock-canopen-node/Cargo.toml
162175
163176
- name: Build release binary
164-
uses: actions-rs/cargo@v1
165-
with:
166-
command: build
167-
args: --release -p canopen-viewer
177+
run: cargo build --release -p canopen-viewer
168178

169179
- name: Create .deb package structure
170180
run: |
@@ -216,4 +226,4 @@ jobs:
216226
- name: Upload .deb package
217227
uses: softprops/action-gh-release@v1
218228
with:
219-
files: ./debian/canopen-viewer_${{ needs.create-release.outputs.version }}_amd64.deb
229+
files: ./debian/canopen-viewer_${{ needs.create-release.outputs.version }}_amd64.deb

.github/workflows/rust.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,54 @@ name: Rust
33
on:
44
push:
55
branches: [ "main" ]
6+
paths-ignore:
7+
- '**.md'
8+
- 'docs/**'
9+
- '.gitignore'
10+
- 'LICENSE'
611
pull_request:
712
branches: [ "main" ]
13+
paths-ignore:
14+
- '**.md'
15+
- 'docs/**'
16+
- '.gitignore'
17+
- 'LICENSE'
818

919
env:
1020
CARGO_TERM_COLOR: always
21+
CARGO_INCREMENTAL: 0 # Disable incremental compilation for CI (saves cache space)
1122

1223
jobs:
1324
build:
14-
1525
runs-on: ubuntu-latest
26+
timeout-minutes: 15 # Prevent runaway builds
1627

1728
steps:
1829
- uses: actions/checkout@v4
30+
31+
- name: Install Rust stable
32+
uses: dtolnay/rust-toolchain@stable
33+
34+
- name: Install system dependencies
35+
run: |
36+
sudo apt-get update
37+
sudo apt-get install -y \
38+
libx11-dev \
39+
libxrandr-dev \
40+
libxi-dev \
41+
libgl1-mesa-dev \
42+
libasound2-dev \
43+
pkg-config
44+
45+
# THIS IS THE BIG ONE - Cargo caching saves 5-10 minutes per build!
46+
- name: Cache Cargo registry and build artifacts
47+
uses: Swatinem/rust-cache@v2
48+
with:
49+
shared-key: "canopen-viewer-ci"
50+
cache-on-failure: true
51+
1952
- name: Build
2053
run: cargo build --verbose
54+
2155
- name: Run tests
2256
run: cargo test --verbose

0 commit comments

Comments
 (0)