main.yml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. name: Main
  2. on:
  3. push:
  4. branches: [main]
  5. pull_request:
  6. env:
  7. RUST_VERSION: 1.78.0
  8. SOLANA_VERSION: 1.18.20
  9. CARGO_CACHE: |
  10. ~/.cargo/bin/
  11. ~/.cargo/registry/index/
  12. ~/.cargo/registry/cache/
  13. ~/.cargo/git/db/
  14. target/
  15. jobs:
  16. lint:
  17. name: Lint
  18. runs-on: ubuntu-latest
  19. steps:
  20. - name: Git checkout
  21. uses: actions/checkout@v4
  22. - name: Setup environment
  23. uses: ./.github/actions/setup
  24. - name: Install components
  25. uses: dtolnay/rust-toolchain@stable
  26. with:
  27. components: clippy, rustfmt
  28. - name: Formatting
  29. run: cargo fmt --check
  30. - name: Clippy
  31. run: cargo clippy
  32. build:
  33. name: Build
  34. needs: lint
  35. runs-on: ubuntu-latest
  36. steps:
  37. - name: Git checkout
  38. uses: actions/checkout@v4
  39. - name: Install Solana
  40. uses: nifty-oss/actions/install-solana@v1
  41. with:
  42. version: ${{ env.SOLANA_VERSION }}
  43. cache: true
  44. - name: Cache cargo dependencies
  45. uses: actions/cache@v4
  46. with:
  47. path: ${{ env.CARGO_CACHE }}
  48. key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
  49. restore-keys: ${{ runner.os }}-cargo
  50. - name: Build
  51. run: cargo build-bpf
  52. test:
  53. name: Test
  54. needs: lint
  55. runs-on: ubuntu-latest
  56. steps:
  57. - name: Git checkout
  58. uses: actions/checkout@v4
  59. - name: Setup environment
  60. uses: ./.github/actions/setup
  61. with:
  62. solana: ${{ env.SOLANA_VERSION }}
  63. - name: Cache cargo dependencies
  64. uses: actions/cache@v4
  65. with:
  66. path: ${{ env.CARGO_CACHE }}
  67. key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
  68. restore-keys: ${{ runner.os }}-cargo
  69. - name: Build
  70. run: cargo test