-
Notifications
You must be signed in to change notification settings - Fork 121
Add Latest Fusion Compatibility Check #372
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
Open
akbog
wants to merge
16
commits into
main
Choose a base branch
from
bog/add-hubcap-gh-actions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
dc5c145
Migrate from heroku to github actions
akbog 0ce6d62
pre-commit fixes
akbog 0a5db9e
Add 'fusion-schema-compat' to index.json and version.json
akbog ebfd3c0
Add testing for UpdateTask and move tests into appropriate location
akbog c8f6c09
Fix uv deps
akbog aa5c227
Ensure dbt fusion is available
akbog bd19f0a
remove duplicate test
akbog cd8e11c
Run dry-run scheduler on PR
akbog 407b96d
Update to checkout v4
akbog 347f89f
artifacts
akbog 15e7a71
merge main
akbog eafc11f
Update to run with worktree since fusion can modify workspace when ch…
akbog a1a5f29
Fix record cleanup after fusion
akbog b7eb28d
further cleanup
akbog c3c3825
final fixes
akbog c455f13
found root cause
akbog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| name: Hubcap Scheduler | ||
|
|
||
| on: | ||
| schedule: | ||
| # Run every hour at :00 for production | ||
| - cron: '0 * * * *' | ||
| workflow_dispatch: | ||
| inputs: | ||
| environment: | ||
| description: 'Environment to run against' | ||
| required: true | ||
| default: 'test' | ||
| type: choice | ||
| options: | ||
| - 'test' | ||
| - 'production' | ||
| dry_run: | ||
| description: 'Run in dry-run mode (no PRs created)' | ||
| required: false | ||
| default: 'true' | ||
| type: choice | ||
| options: | ||
| - 'true' | ||
| - 'false' | ||
|
|
||
| jobs: | ||
| hubcap: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 45 | ||
| environment: ${{ github.event.inputs.environment || 'production' }} | ||
|
|
||
| steps: | ||
| - name: Check out the repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.9' | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install -r requirements.txt | ||
|
|
||
| - name: Configure environment | ||
| env: | ||
| HUBCAP_CONFIG: ${{ secrets.HUBCAP_CONFIG }} | ||
| INPUT_DRY_RUN: ${{ github.event.inputs.dry_run || 'false' }} | ||
| ENVIRONMENT: ${{ github.event.inputs.environment || 'production' }} | ||
| run: | | ||
| echo "Using $ENVIRONMENT environment configuration" | ||
| echo "$HUBCAP_CONFIG" > base_config.json | ||
|
|
||
| # Modify config for dry run if requested | ||
| if [ "$INPUT_DRY_RUN" = "true" ]; then | ||
| echo "Enabling dry-run mode (push_branches = false)" | ||
| jq '.push_branches = false' base_config.json > config.json | ||
| else | ||
| echo "Running in live mode (push_branches = true)" | ||
| cp base_config.json config.json | ||
| fi | ||
|
|
||
| # Set the CONFIG environment variable for hubcap.py | ||
| echo "CONFIG<<EOF" >> $GITHUB_ENV | ||
| cat config.json >> $GITHUB_ENV | ||
| echo "EOF" >> $GITHUB_ENV | ||
|
|
||
| # Log the configuration (without sensitive data) | ||
| echo "Configuration summary:" | ||
| jq 'del(.user.token)' config.json | ||
|
|
||
| - name: Run hubcap | ||
| run: | | ||
| echo "Starting hubcap execution..." | ||
| python3 hubcap.py 2>&1 | tee hubcap.log | ||
|
|
||
| - name: Check execution results | ||
| if: always() | ||
| run: | | ||
| echo "=== Execution Summary ===" | ||
|
|
||
| # Check for errors | ||
| if grep -q 'ERROR' hubcap.log; then | ||
| echo "❌ Found ERROR events in execution:" | ||
| grep 'ERROR' hubcap.log | ||
| echo "EXECUTION_STATUS=failed" >> $GITHUB_ENV | ||
| else | ||
| echo "✅ No ERROR-level log entries found" | ||
| fi | ||
|
|
||
| # Check for successful completion | ||
| if grep -q 'hubcap execution completed successfully' hubcap.log; then | ||
| echo "✅ Hubcap completed successfully" | ||
| echo "EXECUTION_STATUS=success" >> $GITHUB_ENV | ||
| elif grep -q 'No packages have new versions to update' hubcap.log; then | ||
| echo "✅ Hubcap completed successfully (no updates needed)" | ||
| echo "EXECUTION_STATUS=success" >> $GITHUB_ENV | ||
| else | ||
| echo "❌ Hubcap did not complete successfully" | ||
| echo "EXECUTION_STATUS=failed" >> $GITHUB_ENV | ||
| fi | ||
|
|
||
| # Summary of what was processed | ||
| if grep -q 'Pushing branches:' hubcap.log; then | ||
| echo "📝 Branches processed:" | ||
| grep 'Pushing branches:' hubcap.log | ||
| fi | ||
|
|
||
| - name: Upload execution artifacts | ||
| if: always() | ||
| uses: actions/upload-artifact@v3 | ||
| with: | ||
| name: hubcap-execution-${{ github.event.inputs.environment || 'production' }}-${{ github.run_number }} | ||
| path: | | ||
| hubcap.log | ||
| target/ | ||
| retention-days: 30 | ||
|
|
||
| - name: Fail job if execution failed | ||
| if: always() && env.EXECUTION_STATUS == 'failed' | ||
| run: | | ||
| echo "❌ Hubcap execution failed - check logs above" | ||
| exit 1 | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| # GitHub Actions Setup Guide | ||
|
|
||
| This guide explains how to set up hubcap.py to run on GitHub Actions instead of Heroku. | ||
|
|
||
| ## Overview | ||
|
|
||
| The GitHub Actions workflow (`hubcap-scheduler.yml`) supports: | ||
| - **Scheduled execution**: Runs every hour automatically in production | ||
| - **Manual execution**: Can be triggered manually for either test or production | ||
| - **Dry-run capability**: Can run without creating PRs for testing | ||
| - **Environment isolation**: Separate configurations for test and production | ||
|
|
||
| ## Setup Steps | ||
|
|
||
| ### 1. Create GitHub Environments | ||
|
|
||
| In your GitHub repository, go to **Settings > Environments** and create two environments: | ||
|
|
||
| #### Production Environment | ||
| - **Name**: `production` | ||
| - **Protection rules**: | ||
| - ✅ Required reviewers (recommended for production safety) | ||
| - ✅ Wait timer: 0 minutes | ||
| - **Environment secrets**: See step 2 below | ||
|
|
||
| #### Test Environment | ||
| - **Name**: `test` | ||
| - **Protection rules**: None (allows automatic execution) | ||
| - **Environment secrets**: See step 2 below | ||
|
|
||
| ### 2. Configure Environment Secrets | ||
|
|
||
| Each environment needs a `HUBCAP_CONFIG` secret with the appropriate configuration. | ||
|
|
||
| #### Production Environment Secret | ||
| **Secret name**: `HUBCAP_CONFIG` | ||
| **Secret value**: | ||
| ```json | ||
| { | ||
| "user": { | ||
| "name": "dbt-hubcap", | ||
| "email": "buildbot@fishtownanalytics.com", | ||
| "token": "ghp_your_production_token_here" | ||
| }, | ||
| "org": "dbt-labs", | ||
| "repo": "hub.getdbt.com", | ||
| "push_branches": true, | ||
| "one_branch_per_repo": true | ||
| } | ||
| ``` | ||
|
|
||
| #### Test Environment Secret | ||
| **Secret name**: `HUBCAP_CONFIG` | ||
| **Secret value**: | ||
| ```json | ||
| { | ||
| "user": { | ||
| "name": "dbt-hubcap-test", | ||
| "email": "buildbot+test@fishtownanalytics.com", | ||
| "token": "ghp_your_test_token_here" | ||
| }, | ||
| "org": "dbt-labs", | ||
| "repo": "hub.getdbt.com-test", | ||
| "push_branches": true, | ||
| "one_branch_per_repo": true | ||
| } | ||
| ``` | ||
|
|
||
| ### 3. GitHub Personal Access Tokens | ||
|
|
||
| Create two GitHub Personal Access Tokens: | ||
|
|
||
| #### Production Token | ||
| - **Scopes**: `repo`, `workflow` | ||
| - **Expiration**: Set appropriate expiration | ||
| - **Access**: Must have write access to `dbt-labs/hub.getdbt.com` | ||
|
|
||
| #### Test Token | ||
| - **Scopes**: `repo`, `workflow` | ||
| - **Expiration**: Set appropriate expiration | ||
| - **Access**: Must have write access to `dbt-labs/hub.getdbt.com-test` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Automatic Execution (Production) | ||
| The workflow runs automatically every hour at `:00` in production mode. | ||
|
|
||
| ### Manual Execution | ||
| You can manually trigger the workflow with different options: | ||
|
|
||
| #### Test Environment (Dry Run) | ||
| ```bash | ||
| gh workflow run "Hubcap Scheduler" \ | ||
| --field environment=test \ | ||
| --field dry_run=true | ||
| ``` | ||
|
|
||
| #### Test Environment (Live) | ||
| ```bash | ||
| gh workflow run "Hubcap Scheduler" \ | ||
| --field environment=test \ | ||
| --field dry_run=false | ||
| ``` | ||
|
|
||
| #### Production (Manual) | ||
| ```bash | ||
| gh workflow run "Hubcap Scheduler" \ | ||
| --field environment=production \ | ||
| --field dry_run=false | ||
| ``` | ||
|
|
||
| ### Via GitHub Web Interface | ||
| 1. Go to **Actions > Hubcap Scheduler** | ||
| 2. Click **Run workflow** | ||
| 3. Select: | ||
| - **Environment**: `test` or `production` | ||
| - **Dry run**: `true` (no PRs) or `false` (create PRs) | ||
| 4. Click **Run workflow** | ||
|
|
||
| ## Monitoring | ||
|
|
||
| ### Workflow Status | ||
| - View execution history in **Actions** tab | ||
| - Each run shows environment, duration, and status | ||
| - Failed runs will show error details in logs | ||
|
|
||
| ### Artifacts | ||
| Each execution saves: | ||
| - `hubcap.log`: Complete execution log | ||
| - `target/`: Cloned repositories and generated files | ||
| - Retention: 30 days | ||
|
|
||
| ### Notifications | ||
| Configure notifications in repository settings: | ||
| - **Settings > Notifications** | ||
| - Enable workflow failure notifications | ||
| - Set up Slack/email integration if needed | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Common Issues | ||
|
|
||
| **Token Permission Errors** | ||
| - Verify token has `repo` and `workflow` scopes | ||
| - Check token has write access to target repository | ||
| - Ensure token hasn't expired | ||
|
|
||
| **Configuration Errors** | ||
| - Validate JSON syntax in `HUBCAP_CONFIG` secrets | ||
| - Check repository names match intended targets | ||
| - Verify user email and name are correct | ||
|
|
||
| **Execution Failures** | ||
| - Check workflow logs for detailed error messages | ||
| - Review `hubcap.log` artifact for application-specific errors | ||
| - Verify target repository structure and accessibility | ||
|
|
||
| ### Getting Help | ||
| - Check workflow execution logs | ||
| - Review artifacts from failed runs | ||
| - Test with dry-run mode first | ||
| - Use test environment for debugging |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.