|
| 1 | +name: Lean Evaluation Images |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - "containers/lean-checker/**" |
| 8 | + - "containers/lean-repl-agent/**" |
| 9 | + - ".github/workflows/lean-images.yml" |
| 10 | + push: |
| 11 | + branches: [main] |
| 12 | + paths: |
| 13 | + - "containers/lean-checker/**" |
| 14 | + - "containers/lean-repl-agent/**" |
| 15 | + - ".github/workflows/lean-images.yml" |
| 16 | + workflow_dispatch: |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: lean-images-${{ github.workflow }}-${{ github.ref }} |
| 20 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: read |
| 24 | + |
| 25 | +env: |
| 26 | + REGISTRY: ghcr.io |
| 27 | + PLATFORM: linux/amd64 |
| 28 | + |
| 29 | +jobs: |
| 30 | + build-pr: |
| 31 | + name: Build ${{ matrix.image }} |
| 32 | + if: github.event_name == 'pull_request' |
| 33 | + runs-on: ubuntu-latest |
| 34 | + timeout-minutes: 30 |
| 35 | + strategy: |
| 36 | + fail-fast: false |
| 37 | + matrix: |
| 38 | + image: [jacobian-lean-checker, jacobian-lean-repl-agent] |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 41 | + with: |
| 42 | + persist-credentials: false |
| 43 | + - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4 |
| 44 | + - name: Build and load image for measurement |
| 45 | + uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7 |
| 46 | + with: |
| 47 | + context: . |
| 48 | + file: containers/${{ matrix.image }}/Dockerfile |
| 49 | + platforms: ${{ env.PLATFORM }} |
| 50 | + load: true |
| 51 | + push: false |
| 52 | + tags: local/${{ matrix.image }}:${{ github.sha }} |
| 53 | + cache-from: type=gha,scope=${{ matrix.image }} |
| 54 | + cache-to: type=gha,mode=max,scope=${{ matrix.image }} |
| 55 | + - name: Record unpacked image size |
| 56 | + env: |
| 57 | + IMAGE: local/${{ matrix.image }}:${{ github.sha }} |
| 58 | + run: | |
| 59 | + bytes=$(docker image inspect "$IMAGE" --format '{{.Size}}') |
| 60 | + jq -n \ |
| 61 | + --arg image "$IMAGE" \ |
| 62 | + --arg source_sha "$GITHUB_SHA" \ |
| 63 | + --arg platform "$PLATFORM" \ |
| 64 | + --argjson unpacked_size_bytes "$bytes" \ |
| 65 | + '{image: $image, source_sha: $source_sha, platform: $platform, unpacked_size_bytes: $unpacked_size_bytes}' \ |
| 66 | + | tee "$RUNNER_TEMP/${{ matrix.image }}-size.json" \ |
| 67 | + >> "$GITHUB_STEP_SUMMARY" |
| 68 | + - name: Upload size evidence |
| 69 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 70 | + with: |
| 71 | + name: ${{ matrix.image }}-size-${{ github.sha }} |
| 72 | + path: ${{ runner.temp }}/${{ matrix.image }}-size.json |
| 73 | + if-no-files-found: error |
| 74 | + retention-days: 90 |
| 75 | + |
| 76 | + publish: |
| 77 | + name: Publish ${{ matrix.image }} |
| 78 | + if: github.event_name == 'push' |
| 79 | + runs-on: ubuntu-latest |
| 80 | + timeout-minutes: 30 |
| 81 | + permissions: |
| 82 | + contents: read |
| 83 | + packages: write |
| 84 | + strategy: |
| 85 | + fail-fast: false |
| 86 | + matrix: |
| 87 | + image: [jacobian-lean-checker, jacobian-lean-repl-agent] |
| 88 | + steps: |
| 89 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 90 | + with: |
| 91 | + persist-credentials: false |
| 92 | + - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4 |
| 93 | + - name: Log in to GHCR |
| 94 | + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4 |
| 95 | + with: |
| 96 | + registry: ${{ env.REGISTRY }} |
| 97 | + username: ${{ github.actor }} |
| 98 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 99 | + - id: meta |
| 100 | + uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6 |
| 101 | + with: |
| 102 | + images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.image }} |
| 103 | + tags: | |
| 104 | + type=raw,value=sha-${{ github.sha }} |
| 105 | + type=raw,value=main |
| 106 | + labels: | |
| 107 | + org.opencontainers.image.revision=${{ github.sha }} |
| 108 | + io.jacobian.source-dirty=false |
| 109 | + - id: build |
| 110 | + name: Build and publish |
| 111 | + uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7 |
| 112 | + with: |
| 113 | + context: . |
| 114 | + file: containers/${{ matrix.image }}/Dockerfile |
| 115 | + platforms: ${{ env.PLATFORM }} |
| 116 | + push: true |
| 117 | + tags: ${{ steps.meta.outputs.tags }} |
| 118 | + labels: ${{ steps.meta.outputs.labels }} |
| 119 | + cache-from: type=gha,scope=${{ matrix.image }} |
| 120 | + cache-to: type=gha,mode=max,scope=${{ matrix.image }} |
| 121 | + provenance: mode=max |
| 122 | + sbom: true |
| 123 | + - name: Record digest and unpacked size |
| 124 | + env: |
| 125 | + IMAGE: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.image }} |
| 126 | + DIGEST: ${{ steps.build.outputs.digest }} |
| 127 | + run: | |
| 128 | + docker pull "$IMAGE@$DIGEST" |
| 129 | + size=$(docker image inspect "$IMAGE@$DIGEST" --format '{{.Size}}') |
| 130 | + jq -n \ |
| 131 | + --arg source_sha "$GITHUB_SHA" \ |
| 132 | + --arg image "$IMAGE@$DIGEST" \ |
| 133 | + --arg image_digest "$DIGEST" \ |
| 134 | + --arg platform "$PLATFORM" \ |
| 135 | + --argjson unpacked_size_bytes "$size" \ |
| 136 | + '{source_sha: $source_sha, image: $image, image_digest: $image_digest, platform: $platform, unpacked_size_bytes: $unpacked_size_bytes}' \ |
| 137 | + | tee "$RUNNER_TEMP/${{ matrix.image }}-publication.json" \ |
| 138 | + >> "$GITHUB_STEP_SUMMARY" |
| 139 | + - name: Upload publication evidence |
| 140 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 141 | + with: |
| 142 | + name: ${{ matrix.image }}-publication-${{ github.sha }} |
| 143 | + path: ${{ runner.temp }}/${{ matrix.image }}-publication.json |
| 144 | + if-no-files-found: error |
| 145 | + retention-days: 90 |
0 commit comments