main.yml 4.0 KB

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