diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 000000000000..3db063dea078 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,132 @@ +on: + push: + branches: [master] + pull_request: + +name: CI + +jobs: + build: + runs-on: ubuntu-latest + container: + image: ubuntu:20.10 + strategy: + matrix: + rust: + - stable + - beta + - nightly + - "1.40.0" + steps: + - run: apt-get update -y + - run: apt-get install -y libgtk-3-dev libglib2.0-dev libgraphene-1.0-dev git xvfb curl libcairo-gobject2 libcairo2-dev + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + # atk + - name: "atk: tests" + run: xvfb-run --auto-servernum cargo test --manifest-path atk/Cargo.toml --all-features + - name: "atk-sys: tests" + run: xvfb-run --auto-servernum cargo test --manifest-path atk/sys/Cargo.toml --all-features + - name: "atk: build" + run: cargo build --manifest-path atk/Cargo.toml --all-features + # cairo + - name: "cairo: tests" + run: xvfb-run --auto-servernum cargo test --manifest-path cairo/Cargo.toml --features "png,pdf,svg,ps,use_glib,v1_16,freetype,script,xcb,xlib,win32-surface" + - name: "cairo-sys: tests" + run: xvfb-run --auto-servernum cargo test --manifest-path cairo/sys/Cargo.toml --features "png,pdf,svg,ps,use_glib,v1_16,freetype,script,xcb,xlib,win32-surface" + - name: "cairo: build" + run: cargo build --manifest-path cairo/Cargo.toml --features "png,pdf,svg,ps,use_glib,v1_16,freetype,script,xcb,xlib,win32-surface" + # gdk + - name: "gdk: tests" + run: xvfb-run --auto-servernum cargo test --manifest-path gdk/Cargo.toml --features v3_24 + - name: "gdk: build" + run: cargo build --manifest-path gdk/Cargo.toml --features v3_24 + # gdk-pixbuf + - name: "gdk-pixbuf: tests" + run: xvfb-run --auto-servernum cargo test --manifest-path gdk-pixbuf/Cargo.toml --all-features + - name: "gdk-pixbuf-sys: tests" + run: xvfb-run --auto-servernum cargo test --manifest-path gdk-pixbuf/sys/Cargo.toml --all-features + - name: "gdk-pixbuf: build" + run: cargo build --manifest-path gdk-pixbuf/Cargo.toml --all-features + # gdkx11 + - name: "gdkx11: tests" + run: xvfb-run --auto-servernum cargo test --manifest-path gdkx11/Cargo.toml --all-features + - name: "gdkx11-sys: tests" + run: xvfb-run --auto-servernum cargo test --manifest-path gdkx11/sys/Cargo.toml --all-features + - name: "gdkx11: build" + run: cargo build --manifest-path gdkx11/Cargo.toml --all-features + # gio + - name: "gio: tests" + run: xvfb-run --auto-servernum cargo test --manifest-path gio/Cargo.toml --all-features + - name: "gio: build" + run: cargo build --manifest-path gio/Cargo.toml --all-features + # glib + - name: "glib: tests" + run: xvfb-run --auto-servernum cargo test --manifest-path glib/Cargo.toml --all-features + - name: "glib: build" + run: cargo build --manifest-path glib/Cargo.toml --all-features + # glib-macros + - name: "glib-macros: tests" + run: xvfb-run --auto-servernum cargo test --manifest-path glib-macros/Cargo.toml + - name: "glib-macros: build" + run: cargo build --manifest-path glib-macros/Cargo.toml + # graphene + - name: "graphene: tests" + run: xvfb-run --auto-servernum cargo test --manifest-path graphene/Cargo.toml --all-features + - name: "graphene: build" + run: cargo build --manifest-path graphene/Cargo.toml --all-features + # gtk + - name: "gtk: tests" + run: xvfb-run --auto-servernum cargo test --manifest-path gtk/Cargo.toml --all-features + - name: "gtk: build" + run: cargo build --manifest-path gtk/Cargo.toml --all-features + # pango + - name: "pango: tests" + run: xvfb-run --auto-servernum cargo test --manifest-path pango/Cargo.toml --all-features + - name: "pango: build" + run: cargo build --manifest-path pango/Cargo.toml --all-features + # pangocairo + - name: "pangocairo: tests" + run: xvfb-run --auto-servernum cargo test --manifest-path pangocairo/Cargo.toml --all-features + - name: "pangocairo-sys: tests" + run: xvfb-run --auto-servernum cargo test --manifest-path pangocairo/sys/Cargo.toml --all-features + - name: "pangocairo: build" + run: cargo build --manifest-path pangocairo/Cargo.toml --all-features + # examples + - name: "examples" + run: cargo build --manifest-path examples/Cargo.toml --bins --examples --all-features + + - uses: bcomnes/cleanup-xvfb@v1 + + fmt: + name: rust fmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: rustup component add rustfmt + - uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + checker: + name: gtk-rs checker + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + repository: gtk-rs/checker + ref: master + path: checker + - working-directory: checker + run: cargo build --release + - run: "./checker/target/release/checker ." + - run: "./checker/check_init_asserts" diff --git a/Cargo.toml b/Cargo.toml index 51c624e445e1..4f825935b7ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,4 +27,4 @@ members = [ "pangocairo/sys", ] -exclude = ["gir"] +exclude = ["gir", "checker"] diff --git a/gio/sys/tests/abi.rs b/gio/sys/tests/abi.rs index 703b02899017..477e4ff19ece 100644 --- a/gio/sys/tests/abi.rs +++ b/gio/sys/tests/abi.rs @@ -14,7 +14,8 @@ use std::process::Command; use std::str; use tempfile::Builder; -static PACKAGES: &[&str] = &["gio-2.0"]; +static PACKAGES_UNIX: &[&str] = &["gio-2.0", "gio-unix-2.0"]; +static PACKAGES_WINDOWS: &[&str] = &["gio-2.0"]; #[derive(Clone, Debug)] struct Compiler { @@ -22,14 +23,14 @@ struct Compiler { } impl Compiler { - pub fn new() -> Result> { + pub fn new(packages: &[&str]) -> Result> { let mut args = get_var("CC", "cc")?; args.push("-Wno-deprecated-declarations".to_owned()); // For %z support in printf when using MinGW. args.push("-D__USE_MINGW_ANSI_STDIO".to_owned()); args.extend(get_var("CFLAGS", "")?); args.extend(get_var("CPPFLAGS", "")?); - args.extend(pkg_config_cflags(PACKAGES)?); + args.extend(pkg_config_cflags(packages)?); Ok(Compiler { args }) } @@ -131,7 +132,13 @@ fn cross_validate_constants_with_c() { .prefix("abi") .tempdir() .expect("temporary directory"); - let cc = Compiler::new().expect("configured compiler"); + + let cc = if cfg!(target_family = "windows") { + Compiler::new(PACKAGES_WINDOWS) + } else { + Compiler::new(PACKAGES_UNIX) + } + .expect("configured compiler"); assert_eq!( "1", @@ -171,7 +178,13 @@ fn cross_validate_layout_with_c() { .prefix("abi") .tempdir() .expect("temporary directory"); - let cc = Compiler::new().expect("configured compiler"); + + let cc = if cfg!(target_family = "windows") { + Compiler::new(PACKAGES_WINDOWS) + } else { + Compiler::new(PACKAGES_UNIX) + } + .expect("configured compiler"); assert_eq!( Layout {