Repository navigation
Clarify auto-approve risk message and policy comment, add CI test workflow #136
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
1fa76ef
Clarify auto-approve risk message and policy comment, add CI test wor…
LinceMathew d12c171
Fix test data collisions and gemini test after Temperature removal
LinceMathew ae21f49
Run livereview-tests on a throwaway Postgres instead of staging
LinceMathew 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,59 @@ | ||
| name: livereview-tests | ||
|
|
||
| on: | ||
| workflow_dispatch: {} | ||
|
|
||
| permissions: | ||
| contents: read | ||
| statuses: write | ||
|
|
||
| jobs: | ||
| livereview-tests: | ||
| runs-on: ubuntu-24.04 | ||
| # Throwaway database per run, so tests never touch staging or collide with other runs. | ||
| services: | ||
| postgres: | ||
| image: postgres:18-alpine | ||
| env: | ||
| POSTGRES_USER: livereview | ||
| POSTGRES_PASSWORD: livereview_password_123 | ||
| POSTGRES_DB: livereview | ||
| ports: | ||
| - 5432:5432 | ||
| options: >- | ||
| --health-cmd "pg_isready -U livereview" | ||
| --health-interval 5s | ||
| --health-timeout 5s | ||
| --health-retries 10 | ||
| env: | ||
| DATABASE_URL: postgres://livereview:livereview_password_123@localhost:5432/livereview?sslmode=disable | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | ||
|
|
||
| - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e | ||
| with: | ||
| go-version-file: go.mod | ||
|
|
||
| - name: Install dbmate | ||
| run: sudo npm install -g dbmate | ||
|
|
||
| # Fails the job if the database isn't up, so DB tests can't silently skip. | ||
| - name: Run migrations | ||
| run: dbmate --url "$DATABASE_URL" --no-dump-schema up | ||
|
|
||
| - name: Run Go tests | ||
| run: make testall | ||
|
|
||
| - name: Report status to commit SHA | ||
| if: always() | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| STATE: ${{ job.status == 'success' && 'success' || 'failure' }} | ||
| run: | | ||
| gh api \ | ||
| --method POST \ | ||
| repos/${{ github.repository }}/statuses/${{ github.sha }} \ | ||
| -f state="$STATE" \ | ||
| -f context="livereview-tests" \ | ||
| -f description="LiveReview tests completed with status: $STATE" \ | ||
| -f target_url="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
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
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
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
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
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
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,11 @@ | ||
| package api | ||
|
|
||
| import "os" | ||
|
|
||
| // testDatabaseURL is the DB the integration tests use: DATABASE_URL, else the local dev default. | ||
| func testDatabaseURL() string { | ||
| if dsn := os.Getenv("DATABASE_URL"); dsn != "" { | ||
| return dsn | ||
| } | ||
| return "postgres://livereview:livereview_password_123@localhost:5432/livereview?sslmode=disable" | ||
| } |
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,32 @@ | ||
| package policyengine | ||
|
|
||
| import ( | ||
| "context" | ||
| "database/sql" | ||
| "testing" | ||
| ) | ||
|
|
||
| // If the approval count can't be read, the cap is skipped and approvals go on. | ||
| // This pins that current fail-open behavior; flip the assertion if it changes. | ||
| func TestDailyCapQueryErrorFailsOpen(t *testing.T) { | ||
| db, err := sql.Open("postgres", "") | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| db.Close() // every query now errors with "sql: database is closed" | ||
|
|
||
| limit := 1 | ||
| e := &Engine{db: db} | ||
| capped, reason := e.dailyCapExceeded(context.Background(), 1, &Policy{DailyApproveCap: &limit}) | ||
| if capped || reason != "" { | ||
| t.Fatalf("query error: got capped=%v reason=%q, want capped=false reason=\"\"", capped, reason) | ||
| } | ||
| } | ||
|
|
||
| // No cap set means unlimited, so the database is never asked. | ||
| func TestDailyCapNilIsUnlimited(t *testing.T) { | ||
| e := &Engine{db: nil} | ||
| if capped, _ := e.dailyCapExceeded(context.Background(), 1, &Policy{}); capped { | ||
| t.Fatal("nil cap should never block") | ||
| } | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Severity: warning
There is no concurrency group defined for this workflow. Consequently, parallel workflow runs can collide on the shared staging database.
Suggestions: