main.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. name: CI
  2. on:
  3. push:
  4. branches: ["main"]
  5. pull_request:
  6. merge_group:
  7. types: [checks_requested]
  8. env:
  9. CARGO_NET_GIT_FETCH_WITH_CLI: true
  10. jobs:
  11. Test:
  12. strategy:
  13. matrix:
  14. os: [ubuntu-latest, macos-latest, windows-latest]
  15. rust: [1.56.0, stable, beta, nightly]
  16. exclude:
  17. - os: macos-latest
  18. rust: 1.56.0
  19. - os: windows-latest
  20. rust: 1.56.0
  21. - os: macos-latest
  22. rust: beta
  23. - os: windows-latest
  24. rust: beta
  25. - os: macos-latest
  26. rust: nightly
  27. runs-on: ${{ matrix.os }}
  28. steps:
  29. - uses: actions/checkout@v4
  30. - uses: dtolnay/rust-toolchain@master
  31. with:
  32. toolchain: ${{ matrix.rust }}
  33. - run: cargo build --all-targets
  34. # Run tests
  35. - name: Run tests
  36. run: cargo test
  37. # Run tests enabling the serde feature
  38. - name: Run tests with the serde feature
  39. run: cargo test --features "url/serde,url/expose_internals"
  40. # The #[debugger_visualizer] attribute is currently gated behind a feature flag until #[debugger_visualizer]
  41. # is available in all rustc versions past our MSRV. As such, we only run the tests on newer rustc versions.
  42. - name: Run debugger_visualizer tests
  43. if: |
  44. matrix.os == 'windows-latest' &&
  45. matrix.rust != '1.56.0'
  46. run: cargo test --test debugger_visualizer --features "url/debugger_visualizer,url_debug_tests/debugger_visualizer" -- --test-threads=1 || echo "debugger test failed"
  47. continue-on-error: true # Fails on GH actions, but not locally.
  48. - name: Test `no_std` support
  49. run: cargo test --no-default-features --features=alloc
  50. WASM:
  51. runs-on: ubuntu-latest
  52. steps:
  53. - uses: actions/checkout@v4
  54. - uses: dtolnay/rust-toolchain@stable
  55. with:
  56. targets: wasm32-unknown-unknown
  57. - name: Install wasm-pack
  58. run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
  59. - run: cargo build --target wasm32-unknown-unknown
  60. - run: cd url && wasm-pack test --headless --chrome
  61. - run: cd url && wasm-pack test --headless --firefox
  62. Lint:
  63. runs-on: ubuntu-latest
  64. steps:
  65. - uses: actions/checkout@v4
  66. - uses: dtolnay/rust-toolchain@stable
  67. with:
  68. components: rustfmt, clippy
  69. - run: cargo fmt --all --check
  70. - run: cargo clippy --workspace --all-targets -- -D warnings
  71. if: always()
  72. Audit:
  73. runs-on: ubuntu-latest
  74. steps:
  75. - uses: actions/checkout@v4
  76. - uses: EmbarkStudios/cargo-deny-action@v1
  77. Result:
  78. name: Result
  79. runs-on: ubuntu-latest
  80. needs:
  81. - "Test"
  82. - "WASM"
  83. - "Lint"
  84. - "Audit"
  85. steps:
  86. - name: Mark the job as successful
  87. run: exit 0
  88. if: success()
  89. - name: Mark the job as unsuccessful
  90. run: exit 1
  91. if: "!success()"