|
| 1 | +name: Jaffle Shop Recce CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +jobs: |
| 8 | + check-pull-request: |
| 9 | + name: Check pull request by Recce CI |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout repository |
| 13 | + uses: actions/checkout@v3 |
| 14 | + with: |
| 15 | + fetch-depth: 0 |
| 16 | + - name: Set up Python |
| 17 | + uses: actions/setup-python@v4 |
| 18 | + with: |
| 19 | + python-version: "3.10.x" |
| 20 | + - name: Install dependencies |
| 21 | + run: | |
| 22 | + pip install -r requirements.txt |
| 23 | + - name: Install Recce - Nightly |
| 24 | + run: | |
| 25 | + pip install recce-nightly |
| 26 | + - name: Prepare dbt Base environment |
| 27 | + run: | |
| 28 | + if aws s3 cp s3://$AWS_S3_BUCKET/${{ github.event.pull_request.base.sha }}.tar.gz .; then |
| 29 | + echo "Base environment found in S3" |
| 30 | + tar -xvf ${{ github.event.pull_request.base.sha }}.tar.gz |
| 31 | + else |
| 32 | + echo "Base environment not found in S3. Running dbt to create base environment" |
| 33 | + git checkout ${{ github.event.pull_request.base.sha }} |
| 34 | + dbt deps |
| 35 | + dbt seed --target ${{ env.DBT_BASE_TARGET }} --target-path target-base |
| 36 | + dbt run --target ${{ env.DBT_BASE_TARGET }} --target-path target-base |
| 37 | + dbt docs generate --target ${{ env.DBT_BASE_TARGET }} --target-path target-base |
| 38 | + fi |
| 39 | + env: |
| 40 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 41 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 42 | + AWS_REGION: ${{ secrets.AWS_REGION }} |
| 43 | + AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} |
| 44 | + DBT_BASE_TARGET: "prod" |
| 45 | + |
| 46 | + - name: Prepare dbt Current environment |
| 47 | + run: | |
| 48 | + git checkout ${{ github.event.pull_request.head.sha }} |
| 49 | + dbt deps |
| 50 | + dbt seed --target ${{ env.DBT_CURRENT_TARGET}} |
| 51 | + dbt run --target ${{ env.DBT_CURRENT_TARGET}} |
| 52 | + dbt docs generate --target ${{ env.DBT_CURRENT_TARGET}} |
| 53 | + env: |
| 54 | + DBT_CURRENT_TARGET: "dev" |
| 55 | + |
| 56 | + - name: Run Recce CI |
| 57 | + run: | |
| 58 | + recce run --github-pull-request-url ${{ github.event.pull_request.html_url }} |
| 59 | +
|
| 60 | + - name: Archive Recce State File |
| 61 | + uses: actions/upload-artifact@v4 |
| 62 | + id: recce-artifact-uploader |
| 63 | + with: |
| 64 | + name: recce-state-file |
| 65 | + path: recce_state.json |
| 66 | + |
| 67 | + - name: Comment on pull request |
| 68 | + uses: thollander/actions-comment-pull-request@v2 |
| 69 | + with: |
| 70 | + message: | |
| 71 | + Recce `run` successfully completed. |
| 72 | + Please download the [artifact](${{ env.ARTIFACT_URL }}) for the state file. |
| 73 | + env: |
| 74 | + ARTIFACT_URL: ${{ steps.recce-artifact-uploader.outputs.artifact-url }} |
0 commit comments