rust.yml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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@1.79.0
  34. with:
  35. components: rustfmt, clippy
  36. - name: Run tests
  37. run: cargo test
  38. # `fmt` container job
  39. fmt:
  40. name: Rustfmt
  41. runs-on: ubuntu-latest
  42. steps:
  43. - uses: actions/checkout@v4
  44. - uses: dtolnay/rust-toolchain@stable
  45. with:
  46. # Specific to dtolnay/rust-toolchain: Comma-separated string of additional components to install
  47. components: rustfmt
  48. - name: Enforce formatting
  49. run: cargo fmt --check
  50. # `clippy` container job
  51. clippy:
  52. name: Clippy
  53. runs-on: ubuntu-latest
  54. steps:
  55. - uses: actions/checkout@v4
  56. - uses: dtolnay/rust-toolchain@stable
  57. with:
  58. components: clippy
  59. - name: Linting
  60. run: cargo clippy -- -D warnings