source-candidate.yml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. name: Source candidate
  2. on:
  3. workflow_dispatch:
  4. workflow_call:
  5. inputs:
  6. revision:
  7. type: string
  8. required: true
  9. env:
  10. MCODE_CANDIDATE_REVISION: ${{ inputs.revision || github.sha }}
  11. concurrency:
  12. group: ${{ github.workflow }}-${{ inputs.revision || github.sha }}
  13. cancel-in-progress: false
  14. permissions:
  15. contents: read
  16. jobs:
  17. export:
  18. runs-on: ubuntu-latest
  19. timeout-minutes: 10
  20. steps:
  21. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
  22. with:
  23. ref: ${{ env.MCODE_CANDIDATE_REVISION }}
  24. fetch-depth: 0
  25. - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
  26. - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
  27. with:
  28. node-version: "24"
  29. cache: pnpm
  30. - run: pnpm install --frozen-lockfile
  31. - name: Export committed source
  32. shell: bash
  33. run: |
  34. mkdir "$RUNNER_TEMP/candidate"
  35. node scripts/export-source-preview.mjs --out "$RUNNER_TEMP/candidate/minimax-code-source.tar.gz"
  36. node scripts/source-candidate.mjs unpack --archive "$RUNNER_TEMP/candidate/minimax-code-source.tar.gz" --revision "$REVISION" --destination "$RUNNER_TEMP/source-audit"
  37. env:
  38. REVISION: ${{ env.MCODE_CANDIDATE_REVISION }}
  39. - uses: ./.github/actions/setup-gitleaks
  40. - name: Scan history and the exact exported source
  41. shell: bash
  42. run: |
  43. gitleaks git --redact --config .gitleaks.toml --log-opts=--all
  44. gitleaks dir "$RUNNER_TEMP/source-audit" --redact --config .gitleaks.toml
  45. - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
  46. with:
  47. name: unverified-source-${{ env.MCODE_CANDIDATE_REVISION }}
  48. path: ${{ runner.temp }}/candidate/
  49. retention-days: 1
  50. overwrite: true
  51. if-no-files-found: error
  52. validate:
  53. needs: export
  54. runs-on: ${{ matrix.os }}
  55. timeout-minutes: 20
  56. strategy:
  57. fail-fast: false
  58. matrix:
  59. # Windows validation is temporarily paused until its checks are reliable.
  60. os: [ubuntu-latest, macos-latest]
  61. steps:
  62. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
  63. with:
  64. ref: ${{ env.MCODE_CANDIDATE_REVISION }}
  65. - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
  66. - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
  67. with:
  68. node-version: "24"
  69. cache: pnpm
  70. - run: pnpm install --frozen-lockfile
  71. - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
  72. with:
  73. name: unverified-source-${{ env.MCODE_CANDIDATE_REVISION }}
  74. path: ${{ runner.temp }}/candidate
  75. - name: Authenticate and unpack into a fresh directory
  76. shell: bash
  77. run: node scripts/source-candidate.mjs unpack --archive "$RUNNER_TEMP/candidate/minimax-code-source.tar.gz" --revision "$REVISION" --destination "$RUNNER_TEMP/candidate-source"
  78. env:
  79. REVISION: ${{ env.MCODE_CANDIDATE_REVISION }}
  80. - name: Cold install from the exported source
  81. working-directory: ${{ runner.temp }}/candidate-source/minimax-code
  82. shell: bash
  83. run: pnpm install --frozen-lockfile --store-dir "$RUNNER_TEMP/candidate-store" --registry https://registry.npmjs.org/
  84. - name: Verify the exported source
  85. working-directory: ${{ runner.temp }}/candidate-source/minimax-code
  86. run: pnpm verify --profile archive
  87. env:
  88. MCODE_VERIFY_REPORT_DIR: ${{ runner.temp }}/candidate-report
  89. MCODE_VERIFY_REVISION: ${{ env.MCODE_CANDIDATE_REVISION }}
  90. - uses: ./.github/actions/setup-gitleaks
  91. if: runner.os == 'Linux'
  92. - name: Scan the candidate Linux distribution
  93. if: runner.os == 'Linux'
  94. shell: bash
  95. run: gitleaks dir "$RUNNER_TEMP/candidate-source/minimax-code/dist" --redact --config .gitleaks.toml
  96. - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
  97. if: ${{ always() }}
  98. timeout-minutes: 2
  99. with:
  100. name: candidate-validation-${{ matrix.os }}
  101. path: ${{ runner.temp }}/candidate-report/
  102. retention-days: 14
  103. overwrite: true
  104. publish:
  105. needs: [export, validate]
  106. runs-on: ubuntu-latest
  107. timeout-minutes: 10
  108. steps:
  109. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
  110. with:
  111. ref: ${{ env.MCODE_CANDIDATE_REVISION }}
  112. - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
  113. - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
  114. with:
  115. node-version: "24"
  116. cache: pnpm
  117. - run: pnpm install --frozen-lockfile
  118. - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
  119. with:
  120. name: unverified-source-${{ env.MCODE_CANDIDATE_REVISION }}
  121. path: ${{ runner.temp }}/candidate
  122. - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
  123. with:
  124. pattern: candidate-validation-*
  125. path: ${{ runner.temp }}/candidate/reports
  126. - name: Require matching Linux and macOS validation reports
  127. shell: bash
  128. run: node scripts/source-candidate.mjs finalize --archive "$RUNNER_TEMP/candidate/minimax-code-source.tar.gz" --revision "$REVISION" --reports "$RUNNER_TEMP/candidate/reports"
  129. env:
  130. REVISION: ${{ env.MCODE_CANDIDATE_REVISION }}
  131. - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
  132. with:
  133. name: source-candidate-${{ env.MCODE_CANDIDATE_REVISION }}
  134. path: ${{ runner.temp }}/candidate/
  135. retention-days: 14
  136. overwrite: true
  137. if-no-files-found: error