source-candidate.yml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. os: [ubuntu-latest, macos-latest, windows-latest]
  60. steps:
  61. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
  62. with:
  63. ref: ${{ env.MCODE_CANDIDATE_REVISION }}
  64. - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
  65. - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
  66. with:
  67. node-version: "24"
  68. cache: pnpm
  69. - run: pnpm install --frozen-lockfile
  70. - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
  71. with:
  72. name: unverified-source-${{ env.MCODE_CANDIDATE_REVISION }}
  73. path: ${{ runner.temp }}/candidate
  74. - name: Authenticate and unpack into a fresh directory
  75. shell: bash
  76. run: node scripts/source-candidate.mjs unpack --archive "$RUNNER_TEMP/candidate/minimax-code-source.tar.gz" --revision "$REVISION" --destination "$RUNNER_TEMP/candidate-source"
  77. env:
  78. REVISION: ${{ env.MCODE_CANDIDATE_REVISION }}
  79. - name: Cold install from the exported source
  80. working-directory: ${{ runner.temp }}/candidate-source/minimax-code
  81. shell: bash
  82. run: pnpm install --frozen-lockfile --store-dir "$RUNNER_TEMP/candidate-store" --registry https://registry.npmjs.org/
  83. - name: Verify the exported source
  84. working-directory: ${{ runner.temp }}/candidate-source/minimax-code
  85. run: pnpm verify --profile archive
  86. env:
  87. MCODE_VERIFY_REPORT_DIR: ${{ runner.temp }}/candidate-report
  88. MCODE_VERIFY_REVISION: ${{ env.MCODE_CANDIDATE_REVISION }}
  89. - uses: ./.github/actions/setup-gitleaks
  90. if: runner.os == 'Linux'
  91. - name: Scan the candidate Linux distribution
  92. if: runner.os == 'Linux'
  93. shell: bash
  94. run: gitleaks dir "$RUNNER_TEMP/candidate-source/minimax-code/dist" --redact --config .gitleaks.toml
  95. - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
  96. if: ${{ always() }}
  97. timeout-minutes: 2
  98. with:
  99. name: candidate-validation-${{ matrix.os }}
  100. path: ${{ runner.temp }}/candidate-report/
  101. retention-days: 14
  102. overwrite: true
  103. publish:
  104. needs: [export, validate]
  105. runs-on: ubuntu-latest
  106. timeout-minutes: 10
  107. steps:
  108. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
  109. with:
  110. ref: ${{ env.MCODE_CANDIDATE_REVISION }}
  111. - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
  112. - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
  113. with:
  114. node-version: "24"
  115. cache: pnpm
  116. - run: pnpm install --frozen-lockfile
  117. - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
  118. with:
  119. name: unverified-source-${{ env.MCODE_CANDIDATE_REVISION }}
  120. path: ${{ runner.temp }}/candidate
  121. - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
  122. with:
  123. pattern: candidate-validation-*
  124. path: ${{ runner.temp }}/candidate/reports
  125. - name: Require three matching validation reports
  126. shell: bash
  127. run: node scripts/source-candidate.mjs finalize --archive "$RUNNER_TEMP/candidate/minimax-code-source.tar.gz" --revision "$REVISION" --reports "$RUNNER_TEMP/candidate/reports"
  128. env:
  129. REVISION: ${{ env.MCODE_CANDIDATE_REVISION }}
  130. - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
  131. with:
  132. name: source-candidate-${{ env.MCODE_CANDIDATE_REVISION }}
  133. path: ${{ runner.temp }}/candidate/
  134. retention-days: 14
  135. overwrite: true
  136. if-no-files-found: error