Use Docker images locally and in CI #158
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check Generated Files | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
check-generate: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Determine Docker image | |
id: docker-image | |
run: | | |
# Check if Dockerfile.ci or build workflow was modified | |
git fetch origin ${{ github.base_ref }} | |
if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -E '^(Dockerfile\.ci|\.github/workflows/build-ci-image\.yml)$'; then | |
echo "modified=true" >> $GITHUB_OUTPUT | |
echo "image=ghcr.io/flyteorg/flyte/ci:pr-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT | |
echo "📦 Dockerfile.ci modified - will use PR-specific image" | |
else | |
echo "modified=false" >> $GITHUB_OUTPUT | |
echo "image=ghcr.io/flyteorg/flyte/ci:v2" >> $GITHUB_OUTPUT | |
echo "📦 Using default v2 image" | |
fi | |
- name: Wait for Docker image (if modified) | |
if: steps.docker-image.outputs.modified == 'true' | |
run: | | |
echo "⏳ Waiting for Docker image to be built..." | |
IMAGE="${{ steps.docker-image.outputs.image }}" | |
MAX_ATTEMPTS=30 | |
ATTEMPT=0 | |
# Login to GHCR | |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do | |
if docker pull "$IMAGE" 2>/dev/null; then | |
echo "✅ Image is ready!" | |
exit 0 | |
fi | |
ATTEMPT=$((ATTEMPT + 1)) | |
echo "Attempt $ATTEMPT/$MAX_ATTEMPTS: Image not ready yet, waiting 20 seconds..." | |
sleep 20 | |
done | |
echo "❌ Timeout waiting for Docker image to be built" | |
exit 1 | |
- name: Run checks in container | |
run: | | |
IMAGE="${{ steps.docker-image.outputs.image }}" | |
echo "Using image: $IMAGE" | |
docker run --rm \ | |
-v ${{ github.workspace }}:/workspace \ | |
-w /workspace \ | |
-e SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0 \ | |
"$IMAGE" \ | |
bash -c " | |
cd gen/python && uv sync --all-groups --frozen && cd ../.. && | |
make download_tooling && | |
make gen && | |
git diff --exit-code || (echo 'Generated files are out of date. Run \`make gen\` and commit changes.' && exit 1) && | |
make build-crate | |
" | |