action.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. name: Setup environment
  2. inputs:
  3. cargo-cache-key:
  4. description: The key to cache cargo dependencies. Skips cargo caching if not provided.
  5. required: false
  6. cargo-cache-fallback-key:
  7. description: The fallback key to use when caching cargo dependencies. Default to not using a fallback key.
  8. required: false
  9. cargo-cache-local-key:
  10. description: The key to cache local cargo dependencies. Skips local cargo caching if not provided.
  11. required: false
  12. clippy:
  13. description: Install Clippy if `true`. Defaults to `false`.
  14. required: false
  15. rustfmt:
  16. description: Install Rustfmt if `true`. Defaults to `false`.
  17. required: false
  18. solana:
  19. description: Install Solana if `true`. Defaults to `false`.
  20. required: false
  21. runs:
  22. using: 'composite'
  23. steps:
  24. - name: Setup pnpm
  25. uses: pnpm/action-setup@v3
  26. - name: Setup Node.js
  27. uses: actions/setup-node@v4
  28. with:
  29. node-version: 18
  30. cache: 'pnpm'
  31. - name: Install Dependencies
  32. run: pnpm install --frozen-lockfile
  33. shell: bash
  34. - name: Set Environment Variables
  35. shell: bash
  36. run: pnpm zx ./scripts/ci/set-env.mjs
  37. - name: Install Rustfmt
  38. if: ${{ inputs.rustfmt == 'true' }}
  39. uses: dtolnay/rust-toolchain@master
  40. with:
  41. toolchain: ${{ env.TOOLCHAIN_FORMAT }}
  42. components: rustfmt
  43. - name: Install Clippy
  44. if: ${{ inputs.clippy == 'true' }}
  45. uses: dtolnay/rust-toolchain@master
  46. with:
  47. toolchain: ${{ env.TOOLCHAIN_LINT }}
  48. components: clippy
  49. - name: Install Solana
  50. if: ${{ inputs.solana == 'true' }}
  51. uses: metaplex-foundation/actions/install-solana@v1
  52. with:
  53. version: ${{ env.SOLANA_VERSION }}
  54. cache: true
  55. - name: Cache Cargo Dependencies
  56. if: ${{ inputs.cargo-cache-key && !inputs.cargo-cache-fallback-key }}
  57. uses: actions/cache@v4
  58. with:
  59. path: |
  60. ~/.cargo/bin/
  61. ~/.cargo/registry/index/
  62. ~/.cargo/registry/cache/
  63. ~/.cargo/git/db/
  64. target/
  65. key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}
  66. restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-key }}
  67. - name: Cache Cargo Dependencies With Fallback
  68. if: ${{ inputs.cargo-cache-key && inputs.cargo-cache-fallback-key }}
  69. uses: actions/cache@v4
  70. with:
  71. path: |
  72. ~/.cargo/bin/
  73. ~/.cargo/registry/index/
  74. ~/.cargo/registry/cache/
  75. ~/.cargo/git/db/
  76. target/
  77. key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}
  78. restore-keys: |
  79. ${{ runner.os }}-${{ inputs.cargo-cache-key }}
  80. ${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}-${{ hashFiles('**/Cargo.lock') }}
  81. ${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}
  82. - name: Cache Local Cargo Dependencies
  83. if: ${{ inputs.cargo-cache-local-key }}
  84. uses: actions/cache@v4
  85. with:
  86. path: |
  87. .cargo/bin/
  88. .cargo/registry/index/
  89. .cargo/registry/cache/
  90. .cargo/git/db/
  91. key: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}-${{ hashFiles('**/Cargo.lock') }}
  92. restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}