action.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. purge:
  16. description: Purge unused directories if `true`. Defaults to `false`.
  17. required: false
  18. rustfmt:
  19. description: Install Rustfmt if `true`. Defaults to `false`.
  20. required: false
  21. solana:
  22. description: Install Solana if `true`. Defaults to `false`.
  23. required: false
  24. runs:
  25. using: 'composite'
  26. steps:
  27. - name: Setup pnpm
  28. uses: pnpm/action-setup@v3
  29. - name: Setup Node.js
  30. uses: actions/setup-node@v4
  31. with:
  32. node-version: 20
  33. cache: 'pnpm'
  34. - name: Purge unused ubuntu runner directories
  35. if: ${{ inputs.purge == 'true' }}
  36. shell: bash
  37. run: |
  38. # If there are still disk space issues, try to add more packages from
  39. # https://github.com/jlumbroso/free-disk-space
  40. sudo rm -rf /usr/share/dotnet
  41. sudo rm -rf /usr/share/swift
  42. sudo rm -rf /usr/share/mysql
  43. sudo rm -rf /usr/share/az_*
  44. sudo rm -rf /usr/share/postgresql-common
  45. sudo rm -rf /opt/ghc
  46. sudo rm -rf /usr/local/.ghcup
  47. sudo rm -rf /opt/az
  48. sudo rm -rf /opt/pipx
  49. sudo rm -rf /opt/microsoft
  50. sudo rm -rf /opt/google
  51. sudo rm -rf /opt/hostedtoolcache
  52. sudo rm -rf /usr/local/lib/android
  53. sudo rm -rf /usr/local/lib/heroku
  54. sudo rm -rf /imagegeneration
  55. sudo rm -rf "$AGENT_TOOLSDIRECTORY"
  56. sudo docker image prune --all --force
  57. sudo docker system prune -af
  58. # Clear additional caches that might be large
  59. sudo rm -rf /tmp/*
  60. sudo rm -rf /var/tmp/*
  61. # This packages aren't that big, ~500MB total
  62. #sudo apt-get remove -y '^php.*' --fix-missing
  63. #sudo apt-get remove -y '^dotnet-.*' --fix-missing
  64. #sudo apt-get remove -y '^mongodb-.*' --fix-missing
  65. #sudo apt-get remove -y '^mysql-.*' --fix-missing
  66. sudo apt-get remove -y '^aspnetcore-.*' azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri google-cloud-cli --fix-missing
  67. sudo apt-get autoremove -y
  68. sudo apt-get clean
  69. #sudo swapoff -a
  70. #sudo rm -f /mnt/swapfile
  71. - name: Install Dependencies
  72. run: pnpm install --frozen-lockfile
  73. shell: bash
  74. - name: Set Environment Variables
  75. shell: bash
  76. run: pnpm zx ./scripts/ci/set-env.mjs
  77. - name: Install Rustfmt
  78. if: ${{ inputs.rustfmt == 'true' }}
  79. uses: dtolnay/rust-toolchain@master
  80. with:
  81. toolchain: ${{ env.TOOLCHAIN_FORMAT }}
  82. components: rustfmt
  83. - name: Install Clippy
  84. if: ${{ inputs.clippy == 'true' }}
  85. uses: dtolnay/rust-toolchain@master
  86. with:
  87. toolchain: ${{ env.TOOLCHAIN_LINT }}
  88. components: clippy
  89. - name: Install Solana
  90. if: ${{ inputs.solana == 'true' }}
  91. uses: solana-program/actions/install-solana@v1
  92. with:
  93. version: ${{ env.SOLANA_VERSION }}
  94. cache: true
  95. - name: Cache Cargo Dependencies
  96. if: ${{ inputs.cargo-cache-key && !inputs.cargo-cache-fallback-key }}
  97. uses: actions/cache@v4
  98. with:
  99. path: |
  100. ~/.cargo/bin/
  101. ~/.cargo/registry/index/
  102. ~/.cargo/registry/cache/
  103. ~/.cargo/git/db/
  104. target/
  105. key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}
  106. restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-key }}
  107. - name: Cache Cargo Dependencies With Fallback
  108. if: ${{ inputs.cargo-cache-key && inputs.cargo-cache-fallback-key }}
  109. uses: actions/cache@v4
  110. with:
  111. path: |
  112. ~/.cargo/bin/
  113. ~/.cargo/registry/index/
  114. ~/.cargo/registry/cache/
  115. ~/.cargo/git/db/
  116. target/
  117. key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}
  118. restore-keys: |
  119. ${{ runner.os }}-${{ inputs.cargo-cache-key }}
  120. ${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}-${{ hashFiles('**/Cargo.lock') }}
  121. ${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}
  122. - name: Cache Local Cargo Dependencies
  123. if: ${{ inputs.cargo-cache-local-key }}
  124. uses: actions/cache@v4
  125. with:
  126. path: |
  127. .cargo/bin/
  128. .cargo/registry/index/
  129. .cargo/registry/cache/
  130. .cargo/git/db/
  131. key: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}-${{ hashFiles('**/Cargo.lock') }}
  132. restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}