test.yml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. {{{{raw}}}}
  2. name: Test
  3. on:
  4. push:
  5. branches:
  6. - main
  7. pull_request:
  8. branches:
  9. - main
  10. - dev
  11. paths-ignore:
  12. - 'webview-src/**'
  13. - 'webview-dist/**'
  14. - 'examples/**'
  15. jobs:
  16. build-and-test:
  17. runs-on: ${{ matrix.os }}
  18. strategy:
  19. fail-fast: false
  20. matrix:
  21. os: [ubuntu-latest, macos-latest, windows-latest]
  22. steps:
  23. - uses: actions/checkout@v2
  24. - name: Install stable toolchain
  25. uses: actions-rs/toolchain@v1
  26. with:
  27. toolchain: stable
  28. override: true
  29. - name: Install gtk on Ubuntu
  30. if: matrix.os == 'ubuntu-latest'
  31. run: |
  32. sudo apt-get update
  33. sudo apt-get install -y webkit2gtk-4.0
  34. - name: Get current date
  35. if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
  36. run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
  37. - name: Get current date
  38. if: matrix.os == 'windows-latest'
  39. run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
  40. - name: Cache cargo registry
  41. uses: actions/cache@v2
  42. with:
  43. path: ~/.cargo/registry
  44. # Add date to the cache to keep it up to date
  45. key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
  46. # Restore from outdated cache for speed
  47. restore-keys: |
  48. ${{ matrix.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
  49. - name: Cache cargo index
  50. uses: actions/cache@v2
  51. with:
  52. path: ~/.cargo/git
  53. # Add date to the cache to keep it up to date
  54. key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
  55. # Restore from outdated cache for speed
  56. restore-keys: |
  57. ${{ matrix.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}
  58. - name: Cache cargo target
  59. uses: actions/cache@v2
  60. with:
  61. path: ${{ matrix.project}}/target
  62. # Add date to the cache to keep it up to date
  63. key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
  64. # Restore from outdated cache for speed
  65. restore-keys: |
  66. ${{ matrix.os }}-${{ matrix.rust }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }}
  67. - name: Run tests
  68. uses: actions-rs/cargo@v1
  69. with:
  70. command: test
  71. args: --manifest-path=Cargo.toml --release
  72. {{{{/raw}}}}