Przeglądaj źródła

Merge pull request #1222 from DioxusLabs/jk/add-caching-to-ios

Add caching to windows CI, and build for Android + iOS
Jonathan Kelley 1 rok temu
rodzic
commit
b028ca87ec

+ 0 - 42
.github/workflows/macos.yml

@@ -1,42 +0,0 @@
-name: macOS tests
-
-on:
-  push:
-    branches:
-      - master
-    paths:
-      - packages/**
-      - examples/**
-      - src/**
-      - .github/**
-      - lib.rs
-      - Cargo.toml
-
-  pull_request:
-    types: [opened, synchronize, reopened, ready_for_review]
-    branches:
-      - master
-    paths:
-      - packages/**
-      - examples/**
-      - src/**
-      - .github/**
-      - lib.rs
-      - Cargo.toml
-
-concurrency:
-  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
-  cancel-in-progress: true
-
-jobs:
-  test:
-    if: github.event.pull_request.draft == false
-    name: Test Suite
-    runs-on: macos-latest
-    steps:
-      - uses: dtolnay/rust-toolchain@stable
-      - uses: Swatinem/rust-cache@v2
-      - uses: actions/checkout@v3
-      - run: |
-          cargo test --all --tests
-          cargo test --package fermi --release

+ 64 - 0
.github/workflows/main.yml

@@ -83,6 +83,69 @@ jobs:
       - uses: actions/checkout@v3
       - run: cargo clippy --workspace --examples --tests -- -D warnings
 
+  matrix_test:
+    runs-on: ${{ matrix.platform.os }}
+    strategy:
+      matrix:
+        platform:
+          - {
+              target: x86_64-pc-windows-msvc,
+              os: windows-latest,
+              toolchain: '1.70.0',
+              cross: false,
+              command: 'test',
+              args: '--all --tests'
+            }
+          - {
+              target: x86_64-apple-darwin,
+              os: macos-latest,
+              toolchain: '1.70.0',
+              cross: false,
+              command: 'test',
+              args: '--all --tests'
+            }
+          - {
+              target: aarch64-apple-ios,
+              os: macos-latest,
+              toolchain: '1.70.0',
+              cross: false,
+              command: 'build',
+              args: '--package dioxus-mobile'
+            }
+          - {
+              target: aarch64-linux-android,
+              os: ubuntu-latest,
+              toolchain: '1.70.0',
+              cross: true,
+              command: 'build',
+              args: '--package dioxus-mobile'
+            }
+
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: install stable
+        uses: actions-rs/toolchain@v1
+        with:
+          toolchain: ${{ matrix.platform.toolchain }}
+          target: ${{ matrix.platform.target }}
+          override: true
+          default: true
+
+      - uses: Swatinem/rust-cache@v2
+        with:
+          workspaces: core -> ../target
+          save-if: ${{ matrix.features.key == 'all' }}
+
+      - name: test
+        uses: actions-rs/cargo@v1
+        with:
+          use-cross: ${{ matrix.platform.cross }}
+          command: ${{ matrix.platform.command }}
+          args: --target ${{ matrix.platform.target }} ${{ matrix.platform.args }}
+
+
+
   # Coverage is disabled until we can fix it
   # coverage:
   #   name: Coverage
@@ -103,3 +166,4 @@ jobs:
   #       uses: codecov/codecov-action@v2
   #       with:
   #         fail_ci_if_error: false
+

+ 0 - 93
.github/workflows/windows.yml

@@ -1,93 +0,0 @@
-name: windows
-
-on:
-  push:
-    branches:
-      - master
-    paths:
-      - packages/**
-      - examples/**
-      - src/**
-      - .github/**
-      - lib.rs
-      - Cargo.toml
-
-  pull_request:
-    types: [opened, synchronize, reopened, ready_for_review]
-    branches:
-      - master
-    paths:
-      - packages/**
-      - examples/**
-      - src/**
-      - .github/**
-      - lib.rs
-      - Cargo.toml
-
-concurrency:
-  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
-  cancel-in-progress: true
-
-jobs:
-  test:
-    if: github.event.pull_request.draft == false
-    runs-on: windows-latest
-    name: (${{ matrix.target }}, ${{ matrix.cfg_release_channel }})
-    env:
-      CFG_RELEASE_CHANNEL: ${{ matrix.cfg_release_channel }}
-    strategy:
-      # https://help.github.com/en/actions/getting-started-with-github-actions/about-github-actions#usage-limits
-      # There's a limit of 60 concurrent jobs across all repos in the rust-lang organization.
-      # In order to prevent overusing too much of that 60 limit, we throttle the
-      # number of rustfmt jobs that will run concurrently.
-      # max-parallel:
-      # fail-fast: false
-      matrix:
-        target: [x86_64-pc-windows-gnu, x86_64-pc-windows-msvc]
-        cfg_release_channel: [stable]
-
-    steps:
-      # The Windows runners have autocrlf enabled by default
-      # which causes failures for some of rustfmt's line-ending sensitive tests
-      - name: disable git eol translation
-        run: git config --global core.autocrlf false
-
-        # Run build
-      - name: Install Rustup using win.rustup.rs
-        run: |
-          # Disable the download progress bar which can cause perf issues
-          $ProgressPreference = "SilentlyContinue"
-          Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe
-          .\rustup-init.exe -y --default-host=x86_64-pc-windows-msvc --default-toolchain=none
-          del rustup-init.exe
-          rustup target add ${{ matrix.target }}
-        shell: powershell
-
-      - name: Add mingw64 to path for x86_64-gnu
-        run: echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
-        if: matrix.target == 'x86_64-pc-windows-gnu' && matrix.channel == 'nightly'
-        shell: bash
-
-      # - name: checkout
-      #   uses: actions/checkout@v3
-      #   with:
-      #     path: C:/dioxus.git
-      #     fetch-depth: 1
-
-      #  we need to use the C drive as the working directory
-
-      - name: Checkout
-        run: |
-          mkdir C:/dioxus.git
-          git clone https://github.com/dioxuslabs/dioxus.git C:/dioxus.git --depth 1
-
-      - name: test
-        working-directory: C:/dioxus.git
-        run: |
-          rustc -Vv
-          cargo -V
-          set RUST_BACKTRACE=1
-          cargo build --all --tests --examples
-          cargo test --all --tests
-          cargo test --package fermi --release
-        shell: cmd

+ 39 - 36
packages/desktop/src/file_upload.rs

@@ -14,42 +14,6 @@ pub(crate) struct FileDialogRequest {
     pub bubbles: bool,
 }
 
-fn get_file_event_for_folder(request: &FileDialogRequest, dialog: rfd::FileDialog) -> Vec<PathBuf> {
-    if request.multiple {
-        dialog.pick_folders().into_iter().flatten().collect()
-    } else {
-        dialog.pick_folder().into_iter().collect()
-    }
-}
-
-fn get_file_event_for_file(
-    request: &FileDialogRequest,
-    mut dialog: rfd::FileDialog,
-) -> Vec<PathBuf> {
-    let filters: Vec<_> = request
-        .accept
-        .as_deref()
-        .unwrap_or_default()
-        .split(',')
-        .filter_map(|s| Filters::from_str(s).ok())
-        .collect();
-
-    let file_extensions: Vec<_> = filters
-        .iter()
-        .flat_map(|f| f.as_extensions().into_iter())
-        .collect();
-
-    dialog = dialog.add_filter("name", file_extensions.as_slice());
-
-    let files: Vec<_> = if request.multiple {
-        dialog.pick_files().into_iter().flatten().collect()
-    } else {
-        dialog.pick_file().into_iter().collect()
-    };
-
-    files
-}
-
 #[cfg(not(any(
     target_os = "windows",
     target_os = "macos",
@@ -73,6 +37,45 @@ pub(crate) fn get_file_event(_request: &FileDialogRequest) -> Vec<PathBuf> {
     target_os = "openbsd"
 ))]
 pub(crate) fn get_file_event(request: &FileDialogRequest) -> Vec<PathBuf> {
+    fn get_file_event_for_folder(
+        request: &FileDialogRequest,
+        dialog: rfd::FileDialog,
+    ) -> Vec<PathBuf> {
+        if request.multiple {
+            dialog.pick_folders().into_iter().flatten().collect()
+        } else {
+            dialog.pick_folder().into_iter().collect()
+        }
+    }
+
+    fn get_file_event_for_file(
+        request: &FileDialogRequest,
+        mut dialog: rfd::FileDialog,
+    ) -> Vec<PathBuf> {
+        let filters: Vec<_> = request
+            .accept
+            .as_deref()
+            .unwrap_or_default()
+            .split(',')
+            .filter_map(|s| Filters::from_str(s).ok())
+            .collect();
+
+        let file_extensions: Vec<_> = filters
+            .iter()
+            .flat_map(|f| f.as_extensions().into_iter())
+            .collect();
+
+        dialog = dialog.add_filter("name", file_extensions.as_slice());
+
+        let files: Vec<_> = if request.multiple {
+            dialog.pick_files().into_iter().flatten().collect()
+        } else {
+            dialog.pick_file().into_iter().collect()
+        };
+
+        files
+    }
+
     let dialog = rfd::FileDialog::new();
 
     if request.directory {

+ 1 - 1
packages/router-macro/src/segment.rs

@@ -236,7 +236,7 @@ pub(crate) fn create_error_type(
         match segment {
             RouteSegment::Static(index) => {
                 error_variants.push(quote! { #error_name(String) });
-                display_match.push(quote! { Self::#error_name(found) => write!(f, "Static segment '{}' did not match instead found '{found}'", #index)? });
+                display_match.push(quote! { Self::#error_name(found) => write!(f, "Static segment '{}' did not match instead found '{}'", #index, found)? });
             }
             RouteSegment::Dynamic(ident, ty) => {
                 let missing_error = segment.missing_error_name().unwrap();