action.yml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. cli:
  22. description: Install CLI dependencies if `true`. Defaults to `false`.
  23. required: false
  24. purge:
  25. description: Purge unused directories if `true`. Defaults to `false`.
  26. required: false
  27. runs:
  28. using: 'composite'
  29. steps:
  30. - name: Setup pnpm
  31. uses: pnpm/action-setup@v4
  32. - name: Setup Node.js
  33. uses: actions/setup-node@v4
  34. with:
  35. node-version: 20
  36. cache: 'pnpm'
  37. - name: Purge unused ubuntu runner directories
  38. if: ${{ inputs.purge == 'true' }}
  39. shell: bash
  40. run: |
  41. # If there are still disk space issues, try to add more packages from
  42. # https://github.com/jlumbroso/free-disk-space
  43. sudo rm -rf /usr/share/dotnet
  44. sudo rm -rf /usr/share/swift
  45. sudo rm -rf /usr/share/mysql
  46. sudo rm -rf /usr/share/az_*
  47. sudo rm -rf /usr/share/postgresql-common
  48. sudo rm -rf /opt/ghc
  49. sudo rm -rf /opt/az
  50. sudo rm -rf /opt/pipx
  51. sudo rm -rf /opt/microsoft
  52. sudo rm -rf /opt/google
  53. sudo rm -rf /opt/hostedtoolcache
  54. sudo rm -rf /usr/local/lib/android
  55. sudo rm -rf /usr/local/lib/heroku
  56. sudo rm -rf /imagegeneration
  57. sudo rm -rf "$AGENT_TOOLSDIRECTORY"
  58. sudo docker image prune --all --force
  59. - name: Install Dependencies
  60. run: pnpm install --frozen-lockfile
  61. shell: bash
  62. - name: Set Environment Variables
  63. shell: bash
  64. run: pnpm zx ./scripts/ci/set-env.mjs
  65. - name: Install Rustfmt
  66. if: ${{ inputs.rustfmt == 'true' }}
  67. uses: dtolnay/rust-toolchain@master
  68. with:
  69. toolchain: ${{ env.TOOLCHAIN_FORMAT }}
  70. components: rustfmt
  71. - name: Install Clippy
  72. if: ${{ inputs.clippy == 'true' }}
  73. uses: dtolnay/rust-toolchain@master
  74. with:
  75. toolchain: ${{ env.TOOLCHAIN_LINT }}
  76. components: clippy
  77. - name: Install Solana
  78. if: ${{ inputs.solana == 'true' }}
  79. uses: solana-program/actions/install-solana@v1
  80. with:
  81. version: ${{ env.SOLANA_VERSION }}
  82. cache: true
  83. - name: Install CLI dependencies
  84. if: ${{ inputs.cli == 'true' }}
  85. shell: bash
  86. run: sudo apt update && sudo apt install libudev-dev protobuf-compiler -y
  87. - name: Cache Cargo Dependencies
  88. if: ${{ inputs.cargo-cache-key && !inputs.cargo-cache-fallback-key }}
  89. uses: actions/cache@v4
  90. with:
  91. path: |
  92. ~/.cargo/bin/
  93. ~/.cargo/registry/index/
  94. ~/.cargo/registry/cache/
  95. ~/.cargo/git/db/
  96. target/
  97. key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}
  98. restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-key }}
  99. - name: Cache Cargo Dependencies With Fallback
  100. if: ${{ inputs.cargo-cache-key && inputs.cargo-cache-fallback-key }}
  101. uses: actions/cache@v4
  102. with:
  103. path: |
  104. ~/.cargo/bin/
  105. ~/.cargo/registry/index/
  106. ~/.cargo/registry/cache/
  107. ~/.cargo/git/db/
  108. target/
  109. key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}
  110. restore-keys: |
  111. ${{ runner.os }}-${{ inputs.cargo-cache-key }}
  112. ${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}-${{ hashFiles('**/Cargo.lock') }}
  113. ${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}
  114. - name: Cache Local Cargo Dependencies
  115. if: ${{ inputs.cargo-cache-local-key }}
  116. uses: actions/cache@v4
  117. with:
  118. path: |
  119. .cargo/bin/
  120. .cargo/registry/index/
  121. .cargo/registry/cache/
  122. .cargo/git/db/
  123. key: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}-${{ hashFiles('**/Cargo.lock') }}
  124. restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}