-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add GitLab Autofix support and build infrastructure #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
24d46cd
0cc980a
20e563a
f13844e
a8c9b21
d6852ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| name: Build Kencove Sentry Image | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| workflow_dispatch: | ||
| inputs: | ||
| tag: | ||
| description: 'Image tag (e.g., v26.1.0-gitlab)' | ||
| required: false | ||
| default: '' | ||
|
|
||
| env: | ||
| REGION: us-central1 | ||
| PROJECT_ID: kencove-prod | ||
| REPOSITORY: kencove-docker-repo | ||
| IMAGE_NAME: sentry | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-24.04 | ||
| permissions: | ||
| contents: read | ||
| id-token: write # For Workload Identity Federation | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.node-version' | ||
|
|
||
| - uses: pnpm/action-setup@v4 | ||
|
|
||
| - uses: astral-sh/setup-uv@v4 | ||
| with: | ||
| version: '0.8.2' | ||
|
|
||
| - name: Setup Python venv | ||
| run: | | ||
| uv venv | ||
| source .venv/bin/activate | ||
| echo "PATH=$PWD/.venv/bin:$PATH" >> $GITHUB_ENV | ||
|
|
||
| - name: Cache webpack | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: .webpack_cache | ||
| key: webpack-${{ hashFiles('rspack.config.ts') }} | ||
|
|
||
| - name: Cache node_modules | ||
| uses: actions/cache@v4 | ||
| id: node-cache | ||
| with: | ||
| path: node_modules | ||
| key: node-modules-${{ hashFiles('pnpm-lock.yaml') }} | ||
|
|
||
| - name: Install Node dependencies | ||
| if: steps.node-cache.outputs.cache-hit != 'true' | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Build frontend | ||
| run: | | ||
| python3 -m tools.fast_editable --path . | ||
| python3 -m sentry.build.main | ||
| env: | ||
| WEBPACK_CACHE_PATH: .webpack_cache | ||
| NODE_OPTIONS: '--max-old-space-size=4096' | ||
|
|
||
| - name: Authenticate to Google Cloud | ||
| uses: google-github-actions/auth@v2 | ||
| with: | ||
| workload_identity_provider: 'projects/103143301688/locations/global/workloadIdentityPools/github-pool/providers/github-provider' | ||
| service_account: 'github-actions@kencove-prod.iam.gserviceaccount.com' | ||
|
|
||
| - name: Set up Cloud SDK | ||
| uses: google-github-actions/setup-gcloud@v2 | ||
|
|
||
| - name: Configure Docker for Artifact Registry | ||
| run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet | ||
|
|
||
| - name: Determine image tag | ||
| id: tag | ||
| run: | | ||
| if [ -n "${{ github.event.inputs.tag }}" ]; then | ||
| echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "tag=${{ github.sha }}" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Build and push Docker image | ||
| run: | | ||
| docker build \ | ||
| -t ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }} \ | ||
| -t ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}:latest \ | ||
| -f self-hosted/Dockerfile \ | ||
| --build-arg SOURCE_COMMIT=${{ github.sha }} \ | ||
| . | ||
|
|
||
| docker push ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }} | ||
| docker push ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}:latest | ||
|
|
||
| - name: Output image info | ||
| run: | | ||
| echo "## Build Complete" >> $GITHUB_STEP_SUMMARY | ||
| echo "Image: \`${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }}\`" >> $GITHUB_STEP_SUMMARY | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,75 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Build and push Kencove Sentry image to Google Artifact Registry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Usage: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ./build-and-push.sh # Build with commit SHA tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ./build-and-push.sh v26.1.0-gitlab # Build with custom tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ./build-and-push.sh --local # Build locally without pushing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Configuration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PROJECT_ID="${PROJECT_ID:-kencove-prod}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| REGION="${REGION:-us-central1}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| REPOSITORY="${REPOSITORY:-kencove-docker-repo}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| IMAGE_NAME="${IMAGE_NAME:-sentry}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TAG="${1:-$(git rev-parse --short HEAD)}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FULL_IMAGE="${REGION}-docker.pkg.dev/${PROJECT_ID}/${REPOSITORY}/${IMAGE_NAME}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "=== Kencove Sentry Build ===" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Image: ${FULL_IMAGE}:${TAG}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Commit: $(git rev-parse HEAD)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "${1:-}" == "--local" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Building locally (not pushing)..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| docker build \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -t "${IMAGE_NAME}:${TAG}" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -t "${IMAGE_NAME}:latest" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -f self-hosted/Dockerfile.kencove \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --build-arg SOURCE_COMMIT="$(git rev-parse HEAD)" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --progress=plain \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Local build complete: ${IMAGE_NAME}:${TAG}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+16
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: When the user runs Proposed fix-TAG="${1:-$(git rev-parse --short HEAD)}"
+# Handle --local flag first, then determine tag
+LOCAL_BUILD=false
+if [[ "${1:-}" == "--local" ]]; then
+ LOCAL_BUILD=true
+ TAG="${2:-$(git rev-parse --short HEAD)}"
+else
+ TAG="${1:-$(git rev-parse --short HEAD)}"
+fi
FULL_IMAGE="${REGION}-docker.pkg.dev/${PROJECT_ID}/${REPOSITORY}/${IMAGE_NAME}"
echo "=== Kencove Sentry Build ==="
echo "Image: ${FULL_IMAGE}:${TAG}"
echo "Commit: $(git rev-parse HEAD)"
echo ""
-if [[ "${1:-}" == "--local" ]]; then
+if [[ "$LOCAL_BUILD" == "true" ]]; then
echo "Building locally (not pushing)..."📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Check if using Cloud Build or local Docker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if command -v gcloud &> /dev/null && [[ "${USE_CLOUD_BUILD:-true}" == "true" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Using Cloud Build..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gcloud builds submit \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --config=cloudbuild.yaml \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --substitutions="_TAG=${TAG}" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --project="${PROJECT_ID}" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Using local Docker build + push..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Configure Docker for GAR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gcloud auth configure-docker "${REGION}-docker.pkg.dev" --quiet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| docker build \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -t "${FULL_IMAGE}:${TAG}" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -t "${FULL_IMAGE}:latest" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -f self-hosted/Dockerfile.kencove \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --build-arg SOURCE_COMMIT="$(git rev-parse HEAD)" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --progress=plain \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Push | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| docker push "${FULL_IMAGE}:${TAG}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| docker push "${FULL_IMAGE}:latest" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "=== Build Complete ===" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Image: ${FULL_IMAGE}:${TAG}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "To use in Helm values:" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo " images:" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo " sentry:" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo " repository: ${FULL_IMAGE}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo " tag: \"${TAG}\"" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # Cloud Build configuration for kencove/sentry | ||
| # Builds custom Sentry image with GitLab Autofix support | ||
| # | ||
| # Usage: | ||
| # gcloud builds submit --config=cloudbuild.yaml . | ||
| # | ||
| # Or with custom tag: | ||
| # gcloud builds submit --config=cloudbuild.yaml --substitutions=_TAG=v26.1.0-gitlab . | ||
| # | ||
| # Trigger on push: | ||
| # gcloud builds triggers create github \ | ||
| # --repo-name=sentry --repo-owner=kencove \ | ||
| # --branch-pattern="^master$" \ | ||
| # --build-config=cloudbuild.yaml | ||
|
|
||
| substitutions: | ||
| _REGION: us-central1 | ||
| _REPOSITORY: kencove-docker-repo | ||
| _IMAGE_NAME: sentry | ||
| _TAG: ${COMMIT_SHA} | ||
|
|
||
| options: | ||
| machineType: E2_HIGHCPU_32 | ||
| diskSizeGb: 200 | ||
| logging: CLOUD_LOGGING_ONLY | ||
|
|
||
| steps: | ||
| # Build using multi-stage Dockerfile that handles both frontend and runtime | ||
| - name: 'gcr.io/cloud-builders/docker' | ||
| id: 'build-image' | ||
| args: | ||
| - 'build' | ||
| - '-t' | ||
| - '${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPOSITORY}/${_IMAGE_NAME}:${_TAG}' | ||
| - '-t' | ||
| - '${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPOSITORY}/${_IMAGE_NAME}:latest' | ||
| - '-f' | ||
| - 'self-hosted/Dockerfile.kencove' | ||
| - '--build-arg' | ||
| - 'SOURCE_COMMIT=${COMMIT_SHA}' | ||
| - '--progress=plain' | ||
| - '.' | ||
|
|
||
| # Push to Artifact Registry | ||
| - name: 'gcr.io/cloud-builders/docker' | ||
| id: 'push-image' | ||
| args: | ||
| - 'push' | ||
| - '--all-tags' | ||
| - '${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPOSITORY}/${_IMAGE_NAME}' | ||
| waitFor: ['build-image'] | ||
|
|
||
| images: | ||
| - '${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPOSITORY}/${_IMAGE_NAME}:${_TAG}' | ||
| - '${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPOSITORY}/${_IMAGE_NAME}:latest' | ||
|
|
||
| timeout: 3600s # 1 hour - Sentry build is slow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect Dockerfile path: should be
Dockerfile.kencove.Line 97 references
self-hosted/Dockerfile, but the PR introducesself-hosted/Dockerfile.kencovefor building the Kencove image. The workflow also builds frontend assets (lines 63-69), butDockerfile.kencovehas its own frontend-builder stage—leading to redundant builds or inconsistency.Proposed fix
Either use
Dockerfile.kencove(and remove the frontend build steps since it builds internally):docker build \ -t ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }} \ -t ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}:latest \ - -f self-hosted/Dockerfile \ + -f self-hosted/Dockerfile.kencove \ --build-arg SOURCE_COMMIT=${{ github.sha }} \ .Or verify that
self-hosted/Dockerfileexists and expects the pre-built frontend from the workflow steps.📝 Committable suggestion
🤖 Prompt for AI Agents