Conversation
6b27634 to
0cfd527
Compare
Adds end-to-end coverage ensuring the executable successfully generates a passing Rails build.
8599182 to
4c28b7a
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds end-to-end testing for the Staples executable by creating a new CI job that generates a Rails application, runs its tests, and verifies it can start successfully.
Key changes:
- Adds a new
test-templatejob to the GitHub Actions workflow with PostgreSQL service - Implements complete lifecycle testing: app generation, database setup, test execution, and server startup verification
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| staples test_app | ||
| - name: Set up generated app | ||
| env: | ||
| DATABASE_URL: postgres://postgres:postgres@localhost:5432 |
There was a problem hiding this comment.
The DATABASE_URL is missing the database name. PostgreSQL connection URLs should include the database name: postgres://postgres:postgres@localhost:5432/test_app_development (or appropriate database name).
| - name: Run tests in generated app | ||
| env: | ||
| RAILS_ENV: test | ||
| DATABASE_URL: postgres://postgres:postgres@localhost:5432 |
There was a problem hiding this comment.
The DATABASE_URL is missing the database name. For the test environment, this should be postgres://postgres:postgres@localhost:5432/test_app_test (or appropriate test database name).
| run: bin/rails test:all | ||
| - name: Verify app can start | ||
| env: | ||
| DATABASE_URL: postgres://postgres:postgres@localhost:5432 |
There was a problem hiding this comment.
The DATABASE_URL is missing the database name. PostgreSQL connection URLs should include the database name: postgres://postgres:postgres@localhost:5432/test_app_development (or appropriate database name).
|
|
||
| steps: | ||
| - name: Checkout template | ||
| uses: actions/checkout@v4 |
There was a problem hiding this comment.
The checkout action is missing persist-credentials: false which is a security best practice used in the build job (line 23). This prevents the GITHUB_TOKEN from persisting in the git config, reducing the risk of credential exposure.
| uses: actions/checkout@v4 | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false |
| sleep 5 | ||
| curl -f http://localhost:3000 || exit 1 |
There was a problem hiding this comment.
The timeout command will terminate the server after 10 seconds, but the subsequent curl request happens after only 5 seconds. The timeout approach is fragile. Consider using a more robust verification that waits for the server to be ready, such as a retry loop with curl until the port responds or the server logs indicate readiness.
| sleep 5 | |
| curl -f http://localhost:3000 || exit 1 | |
| for i in {1..30}; do | |
| if curl -fs http://localhost:3000 > /dev/null; then | |
| echo "Server is up!" | |
| break | |
| fi | |
| sleep 1 | |
| done | |
| # Final check, fail if not up | |
| curl -f http://localhost:3000 || (echo "Server did not start in time" && exit 1) |
Adds end-to-end coverage ensuring the executable successfully generates
a passing Rails build.