rust.yml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # The name of your workflow. GitHub displays the names of your workflows on your repository's "Actions" tab
  2. name: Rust
  3. # To automatically trigger the workflow
  4. on:
  5. # NB: this differs from the book's project!
  6. # These settings allow us to run this specific CI pipeline for PRs against
  7. # this specific branch (a.k.a. book chapter).
  8. push:
  9. branches:
  10. - main
  11. pull_request:
  12. types: [ opened, synchronize, reopened ]
  13. branches:
  14. - main
  15. # A workflow run is made up of one or more jobs, which run in parallel by default
  16. # Each job runs in a runner environment specified by runs-on
  17. jobs:
  18. # Unique identifier of our job (`job_id`)
  19. test:
  20. # Sets the name `Test` for the job, which is displayed in the GitHub UI
  21. name: Test
  22. # Containers must run in Linux based operating systems
  23. runs-on: ubuntu-latest
  24. steps:
  25. # Downloads a copy of the code in your repository before running CI tests
  26. - name: Check out repository code
  27. # The uses keyword specifies that this step will run v3 of the actions/checkout action.
  28. # This is an action that checks out your repository onto the runner, allowing you to run scripts or other actions against your code (such as build and test tools).
  29. # You should use the checkout action any time your workflow will run against the repository's code.
  30. uses: actions/checkout@v4
  31. # This GitHub Action installs a Rust toolchain using rustup. It is designed for one-line concise usage and good defaults.
  32. - name: Install the Rust toolchain
  33. uses: dtolnay/rust-toolchain@stable
  34. - name: Run tests
  35. run: cargo test
  36. # `fmt` container job
  37. fmt:
  38. name: Rustfmt
  39. runs-on: ubuntu-latest
  40. steps:
  41. - uses: actions/checkout@v4
  42. - uses: dtolnay/rust-toolchain@stable
  43. with:
  44. # Specific to dtolnay/rust-toolchain: Comma-separated string of additional components to install
  45. components: rustfmt
  46. - name: Enforce formatting
  47. run: cargo fmt --check
  48. # `clippy` container job
  49. clippy:
  50. name: Clippy
  51. runs-on: ubuntu-latest
  52. steps:
  53. - uses: actions/checkout@v4
  54. - uses: dtolnay/rust-toolchain@stable
  55. with:
  56. components: clippy
  57. - name: Linting
  58. run: cargo clippy -- -D warnings