-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor dependencies and improve Docker integration #4
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
Changes from all commits
af740ba
b8bbcef
7f44dc8
7379a1b
f207cba
4a305d6
aaf1474
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,33 @@ | ||
| name: CI/CD Pipeline | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| tags: | ||
| - 'v*' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| # Run tests first | ||
| tests: | ||
| uses: ./.github/workflows/tests.yml | ||
|
|
||
| # Build and push Docker images (only on main or tags) | ||
| docker: | ||
| needs: tests | ||
| if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository | ||
| uses: ./.github/workflows/docker.yml | ||
| with: | ||
| push_images: ${{ github.event_name != 'pull_request' }} | ||
| secrets: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| # Publish to PyPI (only on main branch) | ||
| pypi: | ||
| needs: tests | ||
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | ||
| uses: ./.github/workflows/publish-pypi.yml | ||
| secrets: | ||
| semantic_release_token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }} | ||
| pypi_token: ${{ secrets.PYPI_TOKEN }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| name: Build and Push Docker Images (Reusable) | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| push_images: | ||
| description: 'Whether to push images to registry' | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
| secrets: | ||
| github_token: | ||
| description: 'GitHub token for container registry' | ||
| required: true | ||
|
|
||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: ${{ github.repository }} | ||
|
|
||
| jobs: | ||
| build-and-push: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| # Define dbt-core version range | ||
| # Update these versions as new releases become available | ||
| dbt_version: | ||
| - '1.8.0' | ||
| - '1.8.7' | ||
| - '1.9.0' | ||
| - '1.9.1' | ||
| - '1.10.0' | ||
| - '1.10.13' | ||
| - '1.11.0' | ||
| - '1.11.5' | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Log in to Container Registry | ||
| if: inputs.push_images | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.github_token }} | ||
|
|
||
| - name: Extract metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
| tags: | | ||
| type=raw,value=dbt-${{ matrix.dbt_version }} | ||
| type=raw,value=latest,enable=${{ matrix.dbt_version == '1.10.13' }} | ||
| type=sha,prefix=dbt-${{ matrix.dbt_version }}- | ||
|
|
||
| - name: Build and push Docker image | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| push: ${{ inputs.push_images }} | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| build-args: | | ||
| DBT_CORE_VERSION=${{ matrix.dbt_version }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
|
|
||
| - name: Test Docker image | ||
| run: | | ||
| docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dbt-${{ matrix.dbt_version }} --help | ||
|
|
||
| summary: | ||
| runs-on: ubuntu-latest | ||
| needs: build-and-push | ||
| if: always() | ||
| steps: | ||
| - name: Check build status | ||
| run: | | ||
| if [ "${{ needs.build-and-push.result }}" == "success" ]; then | ||
| echo "✅ All Docker images built successfully!" | ||
| else | ||
| echo "❌ Some Docker image builds failed" | ||
| exit 1 | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| name: Tests | ||
| name: Tests (Reusable) | ||
|
|
||
| on: | ||
| workflow_call: | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,16 +1,15 @@ | ||||||||||
| FROM ghcr.io/dbt-labs/dbt-core:1.11.3 | ||||||||||
| FROM python:3.12-slim | ||||||||||
|
|
||||||||||
| RUN pip install dbt-duckdb | ||||||||||
| # Build argument for dbt-core version | ||||||||||
| ARG DBT_CORE_VERSION=1.10.13 | ||||||||||
|
|
||||||||||
| # Copy dbt project (or mount at runtime with -v) | ||||||||||
| COPY dbt /dbt | ||||||||||
| WORKDIR /dbt | ||||||||||
| WORKDIR /app | ||||||||||
| COPY . /app | ||||||||||
|
|
||||||||||
| # Install dbt dependencies | ||||||||||
| RUN dbt deps | ||||||||||
| # Install dependencies excluding dbt-core, then install specific dbt-core version | ||||||||||
| RUN grep -v "^dbt-core" requirements.txt > /tmp/requirements.txt && \ | ||||||||||
|
Comment on lines
+9
to
+10
|
||||||||||
| # Install dependencies excluding dbt-core, then install specific dbt-core version | |
| RUN grep -v "^dbt-core" requirements.txt > /tmp/requirements.txt && \ | |
| # Install dependencies excluding all dbt-* packages, then install specific dbt-core version | |
| RUN grep -v "^dbt-" requirements.txt > /tmp/requirements.txt && \ |
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.
The matrix builds images across multiple
dbt_versionvalues, but the build context uses a single pinnedrequirements.txtand only variesdbt-corevia build arg. Unless the non-core dbt packages are also varied, this matrix is likely to fail or produce inconsistent images for versions other than the one the pins were generated for. Consider generating constraints per dbt version, or simplifying the install todbt-core==${{ matrix.dbt_version }}(+ adapter) so dependencies stay consistent.