@@ -3,121 +3,108 @@ on: [push, pull_request, workflow_dispatch]
33name : CI
44
55env :
6- RUSTFLAGS : -D warnings
6+ # --cfg=web_sys_unstable_apis is required to enable the web_sys clipboard API which egui_web uses
7+ # https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Clipboard.html
8+ # https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
9+ RUSTFLAGS : -D warnings --cfg=web_sys_unstable_apis
710 RUSTDOCFLAGS : -D warnings
811
912jobs :
1013 check :
1114 name : Check
15+ strategy :
16+ fail-fast : false
17+ matrix :
18+ include :
19+ - TARGET : x86_64-unknown-linux-gnu
20+ # If you add features to your crate, chances are you want to test for all features for native binaries,
21+ # so that all features are checked and can be build by someone cloning your repository.
22+ # If you build natively it will be a binary, the default binary will have the entrypoint "src/main.rs".
23+ flags : " --all-features --bins"
24+ - TARGET : wasm32-unknown-unknown
25+ # With the current trunk setup, if you add features, the webpage will have the default features.
26+ # You could test for all features too, however that might require a lot of conditional compilation annotations.
27+ # Thus we only test for the default features by default.
28+ # Since we build with trunk the entrypoint will also be the "src/main.rs" file.
29+ flags : " --bin ${{ github.event.repository.name }}"
1230 runs-on : ubuntu-latest
1331 steps :
1432 - uses : actions/checkout@v4
15- - uses : actions-rs/toolchain@v1
16- with :
17- profile : minimal
18- toolchain : stable
19- override : true
20- - uses : actions-rs/cargo@v1
21- with :
22- command : check
23- args : --all-features
24-
25- check_wasm :
26- name : Check wasm32
27- runs-on : ubuntu-latest
28- steps :
29- - uses : actions/checkout@v4
30- - uses : actions-rs/toolchain@v1
33+ - uses : dtolnay/rust-toolchain@stable
3134 with :
32- profile : minimal
33- toolchain : stable
34- target : wasm32-unknown-unknown
35- override : true
36- - uses : actions-rs/cargo@v1
37- with :
38- command : check
39- args : --all-features --lib --target wasm32-unknown-unknown
35+ targets : ${{matrix.TARGET}}
36+ - uses : Swatinem/rust-cache@v2
37+ - run : cargo check ${{matrix.flags}} --target ${{matrix.TARGET}}
4038
4139 test :
4240 name : Test Suite
4341 runs-on : ubuntu-latest
4442 steps :
4543 - uses : actions/checkout@v4
46- - uses : actions-rs/toolchain@v1
47- with :
48- profile : minimal
49- toolchain : stable
50- override : true
51- - run : sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev
52- - uses : actions-rs/cargo@v1
53- with :
54- command : test
55- args : --lib
44+ - uses : dtolnay/rust-toolchain@stable
45+ - uses : Swatinem/rust-cache@v2
46+ - run : cargo test --lib
5647
5748 fmt :
5849 name : Rustfmt
5950 runs-on : ubuntu-latest
6051 steps :
6152 - uses : actions/checkout@v4
62- - uses : actions-rs/ toolchain@v1
53+ - uses : dtolnay/rust- toolchain@stable
6354 with :
64- profile : minimal
65- toolchain : stable
66- override : true
6755 components : rustfmt
68- - uses : actions-rs/cargo@v1
69- with :
70- command : fmt
71- args : --all -- --check
56+ - uses : Swatinem/rust-cache@v2
57+ - run : cargo fmt --all -- --check
7258
7359 clippy :
7460 name : Clippy
7561 runs-on : ubuntu-latest
7662 steps :
7763 - uses : actions/checkout@v4
78- - uses : actions-rs/ toolchain@v1
64+ - uses : dtolnay/rust- toolchain@stable
7965 with :
80- profile : minimal
81- toolchain : stable
82- override : true
8366 components : clippy
84- - uses : actions-rs/cargo@v1
85- with :
86- command : clippy
87- args : -- -D warnings
67+ - uses : Swatinem/rust-cache@v2
68+ - run : cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::all
8869
8970 trunk :
9071 name : trunk
9172 runs-on : ubuntu-latest
9273 steps :
9374 - uses : actions/checkout@v4
94- - uses : actions-rs/ toolchain@v1
75+ - uses : dtolnay/rust- toolchain@stable
9576 with :
96- profile : minimal
97- toolchain : 1.76.0
98- target : wasm32-unknown-unknown
99- override : true
77+ targets : wasm32-unknown-unknown
78+ - uses : Swatinem/rust-cache@v2
10079 - name : Download and install Trunk binary
10180 run : wget -qO- https://github.com/thedodd/trunk/releases/latest/download/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf-
10281 - name : Build
10382 run : ./trunk build
10483
10584 build :
106- # Temporarily disable build job
107- if : false
10885 runs-on : ${{ matrix.os }}
10986 strategy :
11087 fail-fast : false
11188 matrix :
11289 include :
11390 - os : macos-latest
91+ # macos-latest seems to already run on arm64(=aarch64):
92+ # https://docs.github.com/en/actions/using-jobs/choosing-the-runner-for-a-job#standard-github-hosted-runners-for-public-repositories
11493 TARGET : aarch64-apple-darwin
11594
95+ - os : macos-latest
96+ TARGET : x86_64-apple-darwin
97+ # even though the runner uses arm64, MacOS on arm64 seems to support building for amd64.
98+ # which makes sense, would be bad for devs otherwise.
99+ cross : false
100+
116101 - os : ubuntu-latest
117102 TARGET : aarch64-unknown-linux-gnu
103+ cross : true
118104
119105 - os : ubuntu-latest
120106 TARGET : armv7-unknown-linux-gnueabihf
107+ cross : true
121108
122109 - os : ubuntu-latest
123110 TARGET : x86_64-unknown-linux-gnu
@@ -127,46 +114,57 @@ jobs:
127114 EXTENSION : .exe
128115
129116 steps :
117+ - name : Install cross
118+ # Github doesnt have runners with exotic architectures (eg. arm64/aarch64 on anything but macos).
119+ # Thus we use cross.
120+ # It's necessary to use an up-to-date cross from the git repository to avoid glibc problems on linux
121+ # Ref: https://github.com/cross-rs/cross/issues/1510
122+ if : matrix.cross
123+ run : |
124+ cargo install cross --git https://github.com/cross-rs/cross --rev 1b8cf50d20180c1a394099e608141480f934b7f7
125+
130126 - name : Building ${{ matrix.TARGET }}
131127 run : echo "${{ matrix.TARGET }}"
132128
133129 - uses : actions/checkout@master
134- - name : Install build dependencies - Rustup
135- run : |
136- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable --profile default --target ${{ matrix.TARGET }} -y
137- echo "$HOME/.cargo/bin" >> $GITHUB_PATH
138130
139- # For linux, it's necessary to use cross from the git repository to avoid glibc problems
140- # Ref: https://github.com/cross-rs/cross/issues/1510
141- - name : Install cross for linux
142- if : contains(matrix.TARGET, 'linux')
143- run : |
144- cargo install cross --git https://github.com/cross-rs/cross --rev 1b8cf50d20180c1a394099e608141480f934b7f7
131+ - uses : dtolnay/rust-toolchain@stable
132+ with :
133+ targets : ${{ matrix.TARGET }}
145134
146- - name : Install cross for mac and windows
147- if : ${{ !contains(matrix.TARGET, 'linux') }}
148- run : |
149- cargo install cross
135+ - uses : Swatinem/rust-cache@v2
136+ with :
137+ # this is required to avoid failures due to caching of artifacts for different architectures
138+ # The reason is the potential usage of cross.
139+ # The cache checks the rustc host which doesn't record us targeting
140+ # different architectures (and native) with cross on the generic ubuntu-latest.
141+ key : ${{ matrix.TARGET }}
150142
151- - name : Build
152- run : |
153- cross build --verbose --release --target=${{ matrix.TARGET }}
143+ - if : ${{ !matrix.cross }}
144+ name : Cargo Build
145+ run : cargo build --verbose --release --target=${{ matrix.TARGET }}
146+
147+ - if : matrix.cross
148+ name : Cross Build
149+ run : cross build --verbose --release --target=${{ matrix.TARGET }}
154150
155151 - name : Rename
156- run : cp target/${{ matrix.TARGET }}/release/video_editor ${{ matrix.EXTENSION }} video_editor -${{ matrix.TARGET }}${{ matrix.EXTENSION }}
152+ run : cp target/${{ matrix.TARGET }}/release/${{ github.event.repository.name }}${{ matrix.EXTENSION }} ${{ github.event.repository.name }} -${{ matrix.TARGET }}${{ matrix.EXTENSION }}
157153
158154 - uses : actions/upload-artifact@master
159155 with :
160- name : video_editor -${{ matrix.TARGET }}${{ matrix.EXTENSION }}
161- path : video_editor -${{ matrix.TARGET }}${{ matrix.EXTENSION }}
156+ name : ${{ github.event.repository.name }} -${{ matrix.TARGET }}${{ matrix.EXTENSION }}
157+ path : ${{ github.event.repository.name }} -${{ matrix.TARGET }}${{ matrix.EXTENSION }}
162158
159+ # this requires read-write permissions on the repo:
160+ # https://github.com/svenstaro/upload-release-action/issues/70
163161 - uses : svenstaro/upload-release-action@v2
164162 name : Upload binaries to release
165163 if : ${{ github.event_name == 'push' }}
166164 with :
167165 repo_token : ${{ secrets.GITHUB_TOKEN }}
168- file : video_editor -${{ matrix.TARGET }}${{ matrix.EXTENSION }}
169- asset_name : video_editor -${{ matrix.TARGET }}${{ matrix.EXTENSION }}
166+ file : ${{ github.event.repository.name }} -${{ matrix.TARGET }}${{ matrix.EXTENSION }}
167+ asset_name : ${{ github.event.repository.name }} -${{ matrix.TARGET }}${{ matrix.EXTENSION }}
170168 tag : ${{ github.ref }}
171169 prerelease : ${{ !startsWith(github.ref, 'refs/tags/') }}
172170 overwrite : true
0 commit comments