main.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. # Add toolchain for no_std tests
  34. - run: rustup toolchain install nightly
  35. - name: Add `aarch64-unknown-none` toolchain for `no_std` tests
  36. if: |
  37. matrix.os == 'ubuntu-latest' &&
  38. matrix.rust == 'nightly'
  39. run: rustup target add aarch64-unknown-none && rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
  40. - run: cargo build --all-targets
  41. # Run tests
  42. - name: Run tests
  43. run: cargo test
  44. # Run tests enabling the serde feature
  45. - name: Run tests with the serde feature
  46. run: cargo test --features "url/serde,url/expose_internals"
  47. # The #[debugger_visualizer] attribute is currently gated behind a feature flag until #[debugger_visualizer]
  48. # is available in all rustc versions past our MSRV. As such, we only run the tests on newer rustc versions.
  49. - name: Run debugger_visualizer tests
  50. if: |
  51. matrix.os == 'windows-latest' &&
  52. matrix.rust != '1.56.0'
  53. run: cargo test --test debugger_visualizer --features "url/debugger_visualizer,url_debug_tests/debugger_visualizer" -- --test-threads=1 || echo "debugger test failed"
  54. continue-on-error: true # Fails on GH actions, but not locally.
  55. - name: Test `no_std` support
  56. run: cargo test --no-default-features --features=alloc
  57. - name: Build `url` crate for `aarch64-unknown-none` with `no_std`
  58. if: |
  59. matrix.os == 'ubuntu-latest' &&
  60. matrix.rust == 'nightly'
  61. run: >
  62. cd url
  63. && cargo check --target aarch64-unknown-none -v --no-default-features
  64. WASM:
  65. runs-on: ubuntu-latest
  66. steps:
  67. - uses: actions/checkout@v4
  68. - uses: dtolnay/rust-toolchain@stable
  69. with:
  70. targets: wasm32-unknown-unknown
  71. - name: Install wasm-pack
  72. run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
  73. - run: cargo build --target wasm32-unknown-unknown
  74. - run: cd url && wasm-pack test --headless --chrome
  75. - run: cd url && wasm-pack test --headless --firefox
  76. Lint:
  77. runs-on: ubuntu-latest
  78. steps:
  79. - uses: actions/checkout@v4
  80. - uses: dtolnay/rust-toolchain@stable
  81. with:
  82. components: rustfmt, clippy
  83. - run: cargo fmt --all --check
  84. - run: cargo clippy --workspace --all-targets -- -D warnings
  85. if: always()
  86. Audit:
  87. runs-on: ubuntu-latest
  88. steps:
  89. - uses: actions/checkout@v4
  90. - uses: EmbarkStudios/cargo-deny-action@v1
  91. Result:
  92. name: Result
  93. runs-on: ubuntu-latest
  94. needs:
  95. - "Test"
  96. - "WASM"
  97. - "Lint"
  98. - "Audit"
  99. steps:
  100. - name: Mark the job as successful
  101. run: exit 0
  102. if: success()
  103. - name: Mark the job as unsuccessful
  104. run: exit 1
  105. if: "!success()"