main.yml 3.7 KB

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