[pip] Bump starlette from 0.41.3 to 0.45.2 #644
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: Run tests | |
on: | |
push: | |
workflow_run: | |
workflows: Trigger PR sensitive workflows | |
types: completed | |
permissions: | |
actions: read | |
contents: read | |
pull-requests: write | |
jobs: | |
checkout: | |
name: Checkout repository | |
if: | | |
( | |
github.event_name == 'push' && | |
github.actor != 'dependabot[bot]' | |
) || ( | |
github.event_name == 'workflow_run' && | |
github.event.workflow_run.conclusion == 'success' && | |
github.event.workflow_run.actor != 'dependabot[bot]' | |
) | |
runs-on: ubuntu-latest | |
outputs: | |
comment_id: ${{ steps.comment.outputs.comment_id }} | |
number: ${{ steps.pr-info-output.outputs.number }} | |
sha: ${{ steps.pr-info-output.outputs.sha }} | |
steps: | |
- name: Checkout repository | |
if: ${{ github.event_name == 'push' }} | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Get pull request HEAD SHA | |
if: ${{ github.event_name == 'workflow_run' }} | |
uses: actions/download-artifact@v4 | |
with: | |
name: pull-request-info | |
path: /tmp/ | |
github-token: ${{ github.token }} | |
run-id: ${{ github.event.workflow_run.id }} | |
- name: Save info to output | |
id: pr-info-output | |
if: ${{ github.event_name == 'workflow_run' }} | |
run: cat /tmp/pr.txt > $GITHUB_OUTPUT | |
- name: Checkout pull request directory | |
if: ${{ github.event_name == 'workflow_run' }} | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ steps.pr-info-output.outputs.sha }} | |
submodules: recursive | |
- name: Upload repository | |
uses: actions/upload-artifact@v4 | |
with: | |
name: repository | |
path: . | |
- name: Create comment | |
id: comment | |
if: ${{ github.event_name == 'workflow_run' }} | |
uses: actions/github-script@v7 | |
with: | |
retries: 3 | |
script: | | |
const url = "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"; | |
const sha = "${{ steps.pr-info-output.outputs.sha }}".substr(0, 7); | |
const body = `🔄 [Testing workflow #${{ github.run_attempt }}](${url}) of \`${sha}\` is running`; | |
const response = await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: ${{ steps.pr-info-output.outputs.number }}, | |
body: body, | |
}); | |
core.setOutput("comment_id", response.data.id); | |
flutter-integration: | |
name: Client integration test | |
needs: checkout | |
runs-on: ubuntu-22.04 | |
env: | |
ODBC_CONNECTION_STRING: "Driver={ODBC Driver 18 for SQL Server};Server=localhost,1433;Uid=sa;Pwd=Password1234!;Encrypt=yes;TrustServerCertificate=yes;Connection Timeout=30;" | |
VNPAY_TMN_CODE: ${{ secrets.VNPAY_TMN_CODE }} | |
VNPAY_SECRET_KEY: ${{ secrets.VNPAY_SECRET_KEY }} | |
PORT: 8000 | |
strategy: | |
fail-fast: false | |
matrix: | |
resolution: [375x667x24, 1024x768x24, 1920x1080x24] | |
steps: | |
- name: Download repository | |
uses: actions/download-artifact@v4 | |
with: | |
name: repository | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: 3.24.3 | |
channel: stable | |
- name: Install extra apt dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y ninja-build libgtk-3-dev | |
- name: View Flutter status | |
run: | | |
flutter --version | |
flutter doctor -v | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install dependencies | |
run: pip install -r dev-requirements.txt | |
- name: Install and run local SQL server | |
run: | | |
chmod +x scripts/sql-server-ubuntu-22.04.sh | |
scripts/sql-server-ubuntu-22.04.sh | |
- name: Install ODBC driver 18 | |
run: | | |
chmod +x scripts/odbc.sh | |
scripts/odbc.sh | |
- name: Create sample data | |
run: python scripts/sample.py | |
- name: Start API server | |
run: | | |
uvicorn main:app --host 0.0.0.0 --port $PORT --log-level warning & | |
echo $! > /tmp/serverpid.txt | |
- name: Run integration tests | |
timeout-minutes: 30 | |
working-directory: app/resident_manager | |
run: xvfb-run -e /dev/stdout --server-args="-screen 0 ${{ matrix.resolution }}" flutter test integration_test | |
- name: Stop API server | |
run: | | |
kill $(cat /tmp/serverpid.txt) | |
sleep 5 | |
- name: Collect coverage data | |
run: coverage combine | |
- name: Report coverage | |
run: coverage report -m | |
- name: Rename coverage report | |
run: mv .coverage .coverage.flutter-integration | |
- name: Upload coverage report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-flutter-integration-${{ matrix.resolution }} | |
path: .coverage.flutter-integration | |
include-hidden-files: true | |
performance-test: | |
name: Server performance test | |
needs: checkout | |
runs-on: ubuntu-22.04 | |
env: | |
ODBC_CONNECTION_STRING: "Driver={ODBC Driver 18 for SQL Server};Server=localhost,1433;Uid=sa;Pwd=Password1234!;Encrypt=yes;TrustServerCertificate=yes;Connection Timeout=30;" | |
VNPAY_TMN_CODE: ${{ secrets.VNPAY_TMN_CODE }} | |
VNPAY_SECRET_KEY: ${{ secrets.VNPAY_SECRET_KEY }} | |
PORT: 8000 | |
steps: | |
- name: Download repository | |
uses: actions/download-artifact@v4 | |
with: | |
name: repository | |
- name: Install extra apt dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y build-essential libssl-dev | |
- name: Fetch cached wrk | |
id: wrk-cache | |
uses: actions/cache@v4 | |
with: | |
key: wrk-ubuntu-latest-${{ hashFiles('extern/wrk') }} | |
path: extern/wrk/wrk | |
- name: Build wrk | |
if: ${{ steps.wrk-cache.outputs.cache-hit != 'true' }} | |
working-directory: extern/wrk | |
run: sudo make | |
- name: Copy wrk to /usr/local/bin | |
working-directory: extern/wrk | |
run: sudo cp wrk /usr/local/bin | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install dependencies | |
run: pip install -r dev-requirements.txt | |
- name: Install and run local SQL server | |
run: | | |
chmod +x scripts/sql-server-ubuntu-22.04.sh | |
scripts/sql-server-ubuntu-22.04.sh | |
- name: Install ODBC driver 18 | |
run: | | |
chmod +x scripts/odbc.sh | |
scripts/odbc.sh | |
- name: Create sample data | |
run: python scripts/sample.py | |
- name: Start API server | |
run: | | |
uvicorn main:app --host 0.0.0.0 --port $PORT --log-level warning --workers 12 & | |
echo $! > /tmp/serverpid.txt | |
sleep 5 | |
- name: Measure performance | |
working-directory: scripts/wrk | |
run: | | |
config="-t 12 -c 100 -d 30s -R 10000" | |
command="wrk --script root.lua $config http://localhost:$PORT" | |
echo "$ $command" > $GITHUB_WORKSPACE/wrk-root.txt | |
$command | tee --append $GITHUB_WORKSPACE/wrk-root.txt | |
command="wrk --script api/v1/admin/login.lua $config http://localhost:$PORT/api/v1/admin/login" | |
echo "$ $command" > $GITHUB_WORKSPACE/wrk-api-v1-admin-login.txt | |
$command | tee --append $GITHUB_WORKSPACE/wrk-api-v1-admin-login.txt | |
command="wrk --script api/v1/login.lua $config http://localhost:$PORT/api/v1/login" | |
echo "$ $command" > $GITHUB_WORKSPACE/wrk-api-v1-login.txt | |
$command | tee --append $GITHUB_WORKSPACE/wrk-api-v1-login.txt | |
- name: Stop API server | |
run: | | |
kill $(cat /tmp/serverpid.txt) | |
sleep 5 | |
- name: Upload performance report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wrk | |
path: wrk-*.txt | |
python-coverage: | |
name: Combine coverage reports | |
needs: flutter-integration | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download repository | |
uses: actions/download-artifact@v4 | |
with: | |
name: repository | |
- name: Download coverage reports | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: coverage-* | |
path: . | |
merge-multiple: true | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install dependencies | |
run: pip install -r dev-requirements.txt | |
- name: Combine coverage reports | |
run: coverage combine | |
- name: Report coverage | |
run: coverage report -m | |
- name: Save coverage report | |
run: coverage report -m > textcov.txt | |
- name: Upload coverage report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-txt | |
path: textcov.txt | |
- name: Generate HTML coverage report | |
run: coverage html -d htmlcov | |
- name: Upload HTML coverage report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-html | |
path: htmlcov | |
notification: | |
name: Comment in pull request | |
needs: [checkout, flutter-integration, python-coverage, performance-test] | |
if: ${{ always() && needs.checkout.result == 'success' && github.event_name == 'workflow_run' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download coverage report | |
if: ${{ needs.python-coverage.result == 'success' }} | |
uses: actions/download-artifact@v4 | |
with: | |
name: coverage-txt | |
- name: Download performance report | |
if: ${{ needs.performance-test.result == 'success' }} | |
uses: actions/download-artifact@v4 | |
with: | |
name: wrk | |
- name: Update initial comment | |
uses: actions/github-script@v7 | |
with: | |
retries: 3 | |
script: | | |
const fs = require("fs/promises"); | |
const url = "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"; | |
const sha = "${{ needs.checkout.outputs.sha }}".substr(0, 7); | |
let body = null; | |
if (${{ needs.flutter-integration.result == 'success' }}) { | |
body = `🎉 [All tests #${{ github.run_attempt }}](${url}) of \`${sha}\` passed successfully.`; | |
if (${{ needs.python-coverage.result == 'success' }}) { | |
const coverage = await fs.readFile("textcov.txt", { encoding: "utf8" }); | |
const wrapped = `\`\`\`\n${coverage}\`\`\``; | |
body += `\n<details>\n<summary>Coverage report</summary>\n\n${wrapped}\n\n</details>`; | |
} | |
if (${{ needs.performance-test.result == 'success' }}) { | |
const wrk_root = await fs.readFile("wrk-root.txt", { encoding: "utf8" }); | |
const wrk_api_v1_admin_login = await fs.readFile("wrk-api-v1-admin-login.txt", { encoding: "utf8" }); | |
const wrk_api_v1_login = await fs.readFile("wrk-api-v1-login.txt", { encoding: "utf8" }); | |
const reports = [ | |
`- \`/\`\n\`\`\`\n${wrk_root}\`\`\``, | |
`- \`/api/v1/admin/login\`\n\`\`\`\n${wrk_api_v1_admin_login}\`\`\``, | |
`- \`/api/v1/login\`\n\`\`\`\n${wrk_api_v1_login}\`\`\``, | |
]; | |
const wrapped = reports.join("\n\n"); | |
body += `\n<details>\n<summary>Performance report</summary>\n\n${wrapped}\n\n</details>`; | |
} | |
} else { | |
body = `❌ [One or more tests #${{ github.run_attempt }}](${url}) of \`${sha}\` failed.`; | |
} | |
body += "\n\n*Note that this workflow YAML is fetched from the `main` branch.*"; | |
try { | |
await github.rest.issues.updateComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: ${{ needs.checkout.outputs.comment_id }}, | |
body: body, | |
}); | |
} catch (error) { | |
core.warning(error); | |
core.warning("Unable to update initial comment, creating a new one."); | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: ${{ needs.checkout.outputs.number }}, | |
body: body, | |
}); | |
} |