nightly-rustfmt.yml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. name: Nightly rustfmt
  2. on:
  3. schedule:
  4. - cron: "0 0 * * *" # runs daily at 00:00 UTC
  5. workflow_dispatch: # allows manual triggering
  6. permissions: {}
  7. jobs:
  8. format:
  9. name: Nightly rustfmt
  10. runs-on: ubuntu-latest
  11. permissions:
  12. contents: write
  13. pull-requests: write
  14. steps:
  15. - uses: actions/checkout@v4
  16. with:
  17. ref: main
  18. - name: Get flake hash
  19. id: flake-hash
  20. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  21. - name: Install Nix
  22. uses: DeterminateSystems/nix-installer-action@v17
  23. - name: Nix Cache
  24. uses: DeterminateSystems/magic-nix-cache-action@main
  25. with:
  26. diagnostic-endpoint: ""
  27. use-flakehub: false
  28. - name: Rust Cache
  29. uses: Swatinem/rust-cache@v2
  30. with:
  31. shared-key: "nightly-${{ steps.flake-hash.outputs.hash }}"
  32. - name: Run Nightly rustfmt
  33. run: |
  34. nix develop -i -L .#nightly --command bash -c '
  35. # Force use of Nix-provided rustfmt
  36. export RUSTFMT=$(command -v rustfmt)
  37. cargo fmt
  38. '
  39. # Manually remove trailing whitespace
  40. find . -name '*.rs' -type f -exec sed -E -i 's/[[:space:]]+$//' {} +
  41. - name: Get the current date
  42. run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
  43. - name: Create Pull Request
  44. uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
  45. env:
  46. PRE_COMMIT_ALLOW_NO_CONFIG: 1
  47. with:
  48. token: ${{ secrets.BACKPORT_TOKEN }}
  49. author: Fmt Bot <bot@cashudevkit.org>
  50. title: Automated nightly rustfmt (${{ env.date }})
  51. body: |
  52. Automated nightly `rustfmt` changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action
  53. commit-message: ${{ env.date }} automated rustfmt nightly
  54. labels: rustfmt
  55. branch: automated-rustfmt-${{ env.date }}