Skip to content

Commit 0a468c8

Browse files
authored
Cleanup matrix and run tests in CI (servo#323)
* Cleanup matrix and run tests in CI Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Ignore some failures on angle Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
1 parent c8d6b4b commit 0a468c8

File tree

5 files changed

+91
-96
lines changed

5 files changed

+91
-96
lines changed

.github/workflows/main.yml

+58-55
Original file line numberDiff line numberDiff line change
@@ -13,74 +13,77 @@ env:
1313

1414
jobs:
1515
Build:
16-
runs-on: ${{ matrix.os }}
16+
name: ${{ format('{0} {1}', matrix.platform.target, matrix.features)}}
17+
runs-on: ${{ matrix.platform.os }}
18+
env:
19+
RUST_BACKTRACE: 1
1720
strategy:
1821
fail-fast: false
1922
matrix:
20-
os: [macos-latest, ubuntu-22.04, windows-latest]
21-
rust: [stable]
22-
features: ["", "--features 'chains sm-raw-window-handle-06'", "--features 'chains sm-raw-window-handle-05'"]
23-
target: ["default"]
23+
platform:
24+
- { target: aarch64-apple-darwin, os: macos-14, test: true }
25+
- { target: x86_64-apple-darwin, os: macos-13, test: true }
26+
- { target: x86_64-unknown-linux-gnu, os: ubuntu-24.04, test: true }
27+
- { target: x86_64-pc-windows-msvc, os: windows-latest, test: true }
28+
- { target: i686-pc-windows-msvc, os: windows-latest, test: false }
29+
- { target: aarch64-pc-windows-msvc, os: windows-latest, test: false }
30+
- {
31+
target: aarch64-unknown-linux-ohos,
32+
os: ubuntu-24.04,
33+
test: false,
34+
}
35+
- { target: arm-linux-androideabi, os: ubuntu-24.04, test: false }
36+
features:
37+
[
38+
"",
39+
"chains sm-raw-window-handle-06",
40+
"chains sm-raw-window-handle-05",
41+
]
2442
include:
25-
# rust stable
26-
- os: ubuntu-22.04
27-
features: "--features 'sm-x11 sm-wayland-default'"
28-
rust: stable
29-
target: "default"
30-
- os: ubuntu-22.04
31-
target: "arm-linux-androideabi"
32-
rust: stable
33-
- os: windows-latest
34-
features: "--features 'chains sm-angle-builtin'"
35-
rust: stable
36-
target: "default"
37-
- os: windows-latest
38-
features: "--features 'chains sm-no-wgl sm-angle-builtin'"
39-
rust: stable
40-
target: "default"
41-
- os: windows-latest
42-
target: "aarch64-pc-windows-msvc"
43-
rust: stable
44-
- os: ubuntu-22.04
45-
target: "aarch64-unknown-linux-ohos"
46-
rust: stable
43+
- features: "sm-x11 sm-wayland-default"
44+
platform:
45+
{ target: x86_64-unknown-linux-gnu, os: ubuntu-24.04, test: true }
46+
- features: "chains sm-angle-builtin"
47+
platform:
48+
{ target: x86_64-pc-windows-msvc, os: windows-latest, test: true }
49+
- features: "chains sm-no-wgl sm-angle-builtin"
50+
platform:
51+
{ target: x86_64-pc-windows-msvc, os: windows-latest, test: true }
4752
steps:
48-
- uses: actions/checkout@v4
49-
- name: Install dependencies (Linux)
50-
if: startsWith(matrix.os, 'ubuntu')
51-
run: |
52-
sudo apt update
53-
sudo apt install gcc libxxf86vm-dev libosmesa6-dev libgles2-mesa-dev -y
54-
- name: Install rust
55-
id: toolchain
56-
uses: dtolnay/rust-toolchain@master
57-
with:
58-
toolchain: ${{ matrix.rust }}
59-
- name: Build target
60-
if: matrix.target != 'default' && startsWith(matrix.target, 'aarch64-uwp-windows-msvc') != true
61-
run: |
62-
rustup +${{steps.toolchain.outputs.name}} target add ${{ matrix.target }}
63-
cargo +${{steps.toolchain.outputs.name}} build --verbose ${{ matrix.features }} --target=${{ matrix.target }}
64-
- name: Build
65-
if: matrix.target == 'default'
66-
run: |
67-
cargo +${{steps.toolchain.outputs.name}} build --verbose ${{ matrix.features }}
68-
- name: Build Windows
69-
if: startsWith(matrix.target, 'aarch64-uwp-windows-msvc')
70-
shell: cmd
71-
run: |
72-
rustup +${{steps.toolchain.outputs.name}} component add rust-src --target=aarch64-uwp-windows-msvc
73-
cargo +${{steps.toolchain.outputs.name}} build -Z build-std --verbose --target=aarch64-uwp-windows-msvc
53+
- uses: actions/checkout@v4
54+
- name: Install dependencies (Linux)
55+
if: startsWith(matrix.platform.os, 'ubuntu')
56+
run: |
57+
sudo apt update
58+
sudo apt install gcc libxxf86vm-dev libosmesa6-dev libgles2-mesa-dev xvfb weston -y
59+
- name: Install rust
60+
id: toolchain
61+
uses: dtolnay/rust-toolchain@stable
62+
with:
63+
targets: ${{ matrix.platform.target }}
64+
- name: Build
65+
run: |
66+
rustup target add ${{ matrix.platform.target }}
67+
cargo build --features "${{ matrix.features }}" --target ${{ matrix.platform.target }}
68+
- name: Test
69+
if: ${{ matrix.platform.test && startsWith(matrix.platform.os, 'ubuntu') }}
70+
run: |
71+
weston --no-config --socket=wl-test-env --backend=headless &
72+
WAYLAND_DISPLAY=wl-test-env xvfb-run cargo test --features "${{ matrix.features }}" --target ${{ matrix.platform.target }}
73+
- name: Test
74+
if: ${{ matrix.platform.test && !startsWith(matrix.platform.os, 'ubuntu') }}
75+
run: |
76+
cargo test --features "${{ matrix.features }}" --target ${{ matrix.platform.target }}
7477
Format:
7578
name: Run `rustfmt`
76-
runs-on: ubuntu-latest
79+
runs-on: ubuntu-24.04
7780
steps:
7881
- uses: actions/checkout@v4
7982
- uses: mkroening/rust-toolchain-toml@main
8083
- run: cargo fmt --check
8184
build_result:
8285
name: Result
83-
runs-on: ubuntu-latest
86+
runs-on: ubuntu-24.04
8487
needs: ["Build", "Format"]
8588
if: always()
8689
steps:

examples/chaos_game.rs

+19-13
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
//
33
//! Demonstrates how to use `surfman` to draw to a window surface via the CPU.
44
5-
use euclid::default::Point2D;
5+
use euclid::default::{Point2D, Size2D};
66
use rand::{self, Rng};
77
use surfman::{SurfaceAccess, SurfaceType};
88
use winit::dpi::PhysicalSize;
99
use winit::event::WindowEvent::KeyboardInput;
10-
use winit::event::{DeviceEvent, Event, WindowEvent};
10+
use winit::event::{DeviceEvent, ElementState, Event, KeyEvent, RawKeyEvent, WindowEvent};
1111
use winit::event_loop::{ControlFlow, EventLoop};
12+
use winit::keyboard::{Key, NamedKey, PhysicalKey};
13+
use winit::raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle, HasWindowHandle};
1214
use winit::window::WindowBuilder;
1315

1416
#[cfg(target_os = "macos")]
@@ -29,18 +31,18 @@ static TRIANGLE_POINTS: [(f32, f32); 3] = [
2931
(400.0 - 259.81, 300.0 + 75.0 - 300.0),
3032
];
3133

32-
#[cfg(not(target_os = "macos"))]
34+
#[cfg(not(all(target_os = "macos", feature = "sm-raw-window-handle-06")))]
3335
fn main() {
3436
println!("The `chaos_game` demo is not yet supported on this platform.");
3537
}
3638

37-
#[cfg(target_os = "macos")]
39+
#[cfg(all(target_os = "macos", feature = "sm-raw-window-handle-06"))]
3840
fn main() {
3941
let connection = SystemConnection::new().unwrap();
4042
let adapter = connection.create_adapter().unwrap();
4143
let mut device = connection.create_device(&adapter).unwrap();
4244

43-
let event_loop = EventLoop::new();
45+
let event_loop = EventLoop::new().unwrap();
4446
let physical_size = PhysicalSize::new(WINDOW_WIDTH, WINDOW_HEIGHT);
4547
let window = WindowBuilder::new()
4648
.with_title("Chaos game example")
@@ -54,7 +56,7 @@ fn main() {
5456
let window_size = Size2D::new(window_size.width as i32, window_size.height as i32);
5557
let handle = window.window_handle().unwrap();
5658
let native_widget = connection
57-
.create_native_widget_from_raw_window_handle(handle.as_raw(), window_size)
59+
.create_native_widget_from_window_handle(handle, window_size)
5860
.unwrap();
5961

6062
let surface_type = SurfaceType::Widget { native_widget };
@@ -66,20 +68,25 @@ fn main() {
6668
let mut point = Point2D::new(WINDOW_WIDTH as f32 * 0.5, WINDOW_HEIGHT as f32 * 0.5);
6769
let mut data = vec![0; WINDOW_WIDTH as usize * WINDOW_HEIGHT as usize * 4];
6870

69-
event_loop.run(move |event, _, control_flow| {
71+
event_loop.run(move |event, event_loop| {
7072
match event {
7173
Event::WindowEvent {
7274
event: WindowEvent::CloseRequested,
7375
..
7476
}
75-
| Event::DeviceEvent {
77+
| Event::WindowEvent {
7678
event:
77-
DeviceEvent::Key(KeyboardInput {
78-
virtual_keycode: Some(VirtualKeyCode::Escape),
79+
WindowEvent::KeyboardInput {
80+
event:
81+
KeyEvent {
82+
state: ElementState::Pressed,
83+
logical_key: Key::Named(NamedKey::Escape),
84+
..
85+
},
7986
..
80-
}),
87+
},
8188
..
82-
} => *control_flow = ControlFlow::Exit,
89+
} => event_loop.exit(),
8390
_ => {
8491
for _ in 0..ITERATIONS_PER_FRAME {
8592
let (dest_x, dest_y) = TRIANGLE_POINTS[rng.gen_range(0..3)];
@@ -93,7 +100,6 @@ fn main() {
93100
.data()
94101
.copy_from_slice(&data);
95102
device.present_surface(&mut surface).unwrap();
96-
*control_flow = ControlFlow::Poll;
97103
}
98104
};
99105
});

examples/threads.rs

+2-25
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//
33
// This example demonstrates how to create a multithreaded OpenGL application using `surfman`.
44

5+
#![cfg(feature = "sm-raw-window-handle-06")]
6+
57
use self::common::{ck, Buffer, Program, ResourceLoader, Shader, ShaderKind};
68

79
use euclid::default::{Point2D, Rect, Size2D, Vector2D};
@@ -24,9 +26,6 @@ use winit::{
2426
window::WindowBuilder,
2527
};
2628

27-
#[cfg(feature = "sm-raw-window-handle-05")]
28-
use rwh_05::{HasRawDisplayHandle, HasRawWindowHandle};
29-
#[cfg(not(feature = "sm-raw-window-handle-05"))]
3029
use rwh_06::{HasDisplayHandle, HasWindowHandle};
3130

3231
pub mod common;
@@ -90,14 +89,6 @@ static BACKGROUND_COLOR: [f32; 4] = [
9089
1.0,
9190
];
9291

93-
#[cfg(feature = "sm-raw-window-handle-05")]
94-
fn make_connection(window: &winit::window::Window) -> surfman::Connection {
95-
let raw_display_handle = window.raw_display_handle();
96-
let connection = Connection::from_raw_display_handle(raw_display_handle).unwrap();
97-
connection
98-
}
99-
100-
#[cfg(not(feature = "sm-raw-window-handle-05"))]
10192
fn make_connection(window: &winit::window::Window) -> surfman::Connection {
10293
let display_handle = window
10394
.display_handle()
@@ -106,20 +97,6 @@ fn make_connection(window: &winit::window::Window) -> surfman::Connection {
10697
connection
10798
}
10899

109-
#[cfg(feature = "sm-raw-window-handle-05")]
110-
fn make_native_widget(
111-
window: &winit::window::Window,
112-
connection: &surfman::Connection,
113-
window_size: Size2D<i32>,
114-
) -> surfman::NativeWidget {
115-
let raw_window_handle = window.raw_window_handle();
116-
let native_widget = connection
117-
.create_native_widget_from_raw_window_handle(raw_window_handle, window_size)
118-
.unwrap();
119-
native_widget
120-
}
121-
122-
#[cfg(not(feature = "sm-raw-window-handle-05"))]
123100
fn make_native_widget(
124101
window: &winit::window::Window,
125102
connection: &surfman::Connection,

src/platform/egl/connection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl Connection {
168168
raw_handle: rwh_05::RawWindowHandle,
169169
_size: Size2D<i32>,
170170
) -> Result<NativeWidget, Error> {
171-
create_native_widget_from_rwh_05_handle(raw_handle)
171+
Self::create_native_widget_from_rwh_05_handle(raw_handle)
172172
}
173173

174174
#[cfg(all(feature = "sm-raw-window-handle-06", android_platform))]

src/tests.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,19 @@ pub fn test_context_creation() {
153153
// requested GL version.
154154
}
155155
Err(error) => {
156-
panic!(
156+
let error = format!(
157157
"Failed to create context ({:?}/{:?}): {:?}",
158158
version, flags, error
159-
)
159+
);
160+
// This fail on angle
161+
if cfg!(all(feature = "sm-no-wgl", feature = "sm-angle"))
162+
&& (flags.contains(ContextAttributeFlags::COMPATIBILITY_PROFILE)
163+
|| version == *GL_ES_VERSIONS.last().unwrap())
164+
{
165+
println!("{error}");
166+
} else {
167+
panic!("{error}");
168+
}
160169
}
161170
}
162171
}

0 commit comments

Comments
 (0)