Add seed and new model #8
This file contains 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: Recce CI PR Branch | |
on: | |
pull_request: | |
branches: [main] | |
jobs: | |
check-pull-request: | |
name: Check pull request by Recce CI | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Install dependencies | |
run: | | |
pip install dbt-bigquery | |
pip install recce | |
# Checkout artifacts branch and copy files | |
- name: Checkout Artifacts Branch | |
uses: actions/checkout@v3 | |
with: | |
ref: artifacts | |
path: artifacts | |
- name: Copy Artifacts | |
run: | | |
mkdir -p ./target-base | |
cp artifacts/artifacts/manifest.json ./target-base/ | |
cp artifacts/artifacts/catalog.json ./target-base/ | |
# Update this below step to generate docs for the current PR's branch | |
- name: Set up environment variables and write service account key | |
env: | |
CICD_SERVICE_ACCOUNT: ${{ secrets.CICD_SERVICE_ACCOUNT }} | |
run: | | |
printf "%s" "${CICD_SERVICE_ACCOUNT}" > /tmp/service_account.json | |
- name: Create dbt profiles directory | |
run: mkdir -p ~/.dbt | |
- name: Generate profiles.yml | |
env: | |
CICD_DATASET: ${{ secrets.CICD_DATASET }} | |
CICD_LOCATION: ${{ secrets.CICD_LOCATION }} | |
CICD_PRIORITY: ${{ secrets.CICD_PRIORITY }} | |
CICD_PROJECT: ${{ secrets.CICD_PROJECT }} | |
run: | | |
cat <<EOF > ~/.dbt/profiles.yml | |
sethbox: | |
target: ci | |
outputs: | |
ci: | |
dataset: "$CICD_DATASET" | |
keyfile: "/tmp/service_account.json" | |
location: "$CICD_LOCATION" | |
priority: "$CICD_PRIORITY" | |
project: "$CICD_PROJECT" | |
type: bigquery | |
method: service-account | |
job_execution_timeout_seconds: 300 | |
job_retries: 1 | |
threads: 16 | |
EOF | |
- name: Display profiles.yml for debugging | |
run: | | |
cat ~/.dbt/profiles.yml | |
- name: Run dbt to generate artifacts | |
run: | | |
dbt deps --profiles-dir ~/.dbt | |
dbt run --empty --profiles-dir ~/.dbt | |
dbt docs generate --profiles-dir ~/.dbt | |
- name: Run Recce CI | |
run: | | |
recce run --github-pull-request-url ${{ github.event.pull_request.html_url }} | |
- name: Upload DBT Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: target | |
path: target/ | |
- name: Upload Recce State File | |
uses: actions/upload-artifact@v4 | |
id: recce-artifact-uploader | |
with: | |
name: recce-state-file | |
path: recce_state.json | |
- name: Prepare Recce Summary | |
id: recce-summary | |
run: | | |
recce summary recce_state.json > recce_summary.md | |
cat recce_summary.md >> $GITHUB_STEP_SUMMARY | |
echo '${{ env.NEXT_STEP_MESSAGE }}' >> recce_summary.md | |
# Handle the case when the recce summary is too long to be displayed in the GitHub PR comment | |
if [[ `wc -c recce_summary.md | awk '{print $1}'` -ge '65535' ]]; then | |
echo '# Recce Summary | |
The recce summary is too long to be displayed in the GitHub PR comment. | |
Please check the summary detail in the [Job Summary](${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}) page. | |
${{ env.NEXT_STEP_MESSAGE }}' > recce_summary.md | |
fi | |
env: | |
NEXT_STEP_MESSAGE: | | |
## Next Steps | |
If you want to check more detail information about the recce result, please download the [artifact](${{ steps.recce-artifact-uploader.outputs.artifact-url }}) file and open it by [Recce](https://pypi.org/project/recce/) CLI. | |
### How to check the recce result | |
```bash | |
# Unzip the downloaded artifact file | |
tar -xf recce-state-file.zip | |
# Launch the recce server based on the state file | |
recce server --review recce_state.json | |
# Open the recce server http://localhost:8000 by your browser | |
``` | |
- name: Comment on pull request | |
uses: thollander/actions-comment-pull-request@v2 | |
with: | |
filePath: recce_summary.md | |
comment_tag: recce |