update github action #6
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
| name: Tests | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: hankcp/postgres-ext:17.6 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_HOST_AUTH_METHOD: trust | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Install Postgres extension | |
| run: | | |
| pig ext add pgtap -y | |
| pig ext add http -y | |
| pig ext add vector -y | |
| pig ext add pg_background -y | |
| - name: Start PostgreSQL | |
| run: | | |
| mkdir -p /var/lib/postgresql/data | |
| chown -R postgres:postgres /var/lib/postgresql/data | |
| gosu postgres /usr/lib/postgresql/17/bin/initdb -D /var/lib/postgresql/data | |
| gosu postgres /usr/lib/postgresql/17/bin/pg_ctl -D /var/lib/postgresql/data start -w | |
| - name: Start Mock Embedding Server | |
| run: | | |
| python3 test/mock_embedding_server.py 8080 & | |
| sleep 2 | |
| echo "Mock embedding server started on port 8080" | |
| - name: Setup test environment | |
| run: | | |
| cp test/.env.example test/.env | |
| sed -i "s|https://api.siliconflow.cn/v1/embeddings|http://localhost:8080/v1/embeddings|g" test/.env | |
| sed -i "s/your-api-key/mock-api-key/g" test/.env | |
| echo "Test environment configured" | |
| - name: Run test script | |
| id: test | |
| run: | | |
| chmod +x test/runner.sh | |
| ./test/runner.sh --host localhost --user postgres | tee test_output.log | |
| - name: Test Summary | |
| if: always() | |
| run: | | |
| if grep -q "=== Test completed successfully ===" test_output.log; then | |
| echo "✓ Tests passed" | |
| exit 0 | |
| elif grep -q "=== Tests FAILED ===" test_output.log; then | |
| echo "✗ Tests failed" | |
| exit 1 | |
| else | |
| echo "⚠ Test status unknown" | |
| exit 1 | |
| fi |