[pub] Bump package_info_plus in /app/resident_manager #347
Workflow file for this run
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); | |
python: | |
name: Web application test | |
needs: checkout | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.10", "3.11", "3.12"] | |
env: | |
ODBC_CONNECTION_STRING: ${{ secrets.ODBC_CONNECTION_STRING}} | |
VNPAY_TMN_CODE: ${{ secrets.VNPAY_TMN_CODE }} | |
VNPAY_SECRET_KEY: ${{ secrets.VNPAY_SECRET_KEY }} | |
PRIVATE_KEY_SEED: ${{ secrets.PRIVATE_KEY_SEED }} | |
PORT: 8000 | |
steps: | |
- name: Download repository | |
uses: actions/download-artifact@v4 | |
with: | |
name: repository | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: pip install -r dev-requirements.txt | |
- name: Install ODBC driver 18 | |
run: | | |
chmod +x scripts/odbc.sh | |
scripts/odbc.sh | |
- name: Run tests | |
run: coverage run -m pytest -v . | |
- name: Collect coverage data | |
run: coverage combine | |
- name: Report coverage | |
run: coverage report -m | |
- name: Rename coverage report | |
run: mv .coverage .coverage.python-${{ matrix.python-version }} | |
- name: Upload coverage report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-python-${{ matrix.python-version }} | |
path: .coverage.python-${{ matrix.python-version }} | |
include-hidden-files: true | |
flutter-integration: | |
name: Client integration test | |
needs: checkout | |
runs-on: ubuntu-latest | |
env: | |
ODBC_CONNECTION_STRING: ${{ secrets.ODBC_CONNECTION_STRING}} | |
VNPAY_TMN_CODE: ${{ secrets.VNPAY_TMN_CODE }} | |
VNPAY_SECRET_KEY: ${{ secrets.VNPAY_SECRET_KEY }} | |
PRIVATE_KEY_SEED: ${{ secrets.PRIVATE_KEY_SEED }} | |
PORT: 8000 | |
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.11" | |
- name: Install dependencies | |
run: pip install -r dev-requirements.txt | |
- name: Install ODBC driver 18 | |
run: | | |
chmod +x scripts/odbc.sh | |
scripts/odbc.sh | |
- 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 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 | |
path: .coverage.flutter-integration | |
include-hidden-files: true | |
performance-test: | |
name: Server performance test | |
needs: checkout | |
runs-on: ubuntu-latest | |
env: | |
ODBC_CONNECTION_STRING: ${{ secrets.ODBC_CONNECTION_STRING}} | |
VNPAY_TMN_CODE: ${{ secrets.VNPAY_TMN_CODE }} | |
VNPAY_SECRET_KEY: ${{ secrets.VNPAY_SECRET_KEY }} | |
PRIVATE_KEY_SEED: ${{ secrets.PRIVATE_KEY_SEED }} | |
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.11" | |
- name: Install dependencies | |
run: pip install -r dev-requirements.txt | |
- name: Install ODBC driver 18 | |
run: | | |
chmod +x scripts/odbc.sh | |
scripts/odbc.sh | |
- name: Start API server | |
run: | | |
uvicorn main:app --host 0.0.0.0 --port $PORT --log-level warning & | |
echo $! > /tmp/serverpid.txt | |
sleep 5 | |
- name: Measure performance | |
working-directory: scripts/wrk | |
run: | | |
command="wrk --script root.lua -d 20s 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 -d 20s 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 | |
- 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: [python, 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.11" | |
- 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, python, 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.python.result == 'success' && 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 wrapped = `- \`/\`\n\`\`\`\n${wrk_root}\`\`\`\n\n- \`/api/v1/admin/login\`\n\`\`\`\n${wrk_api_v1_admin_login}\`\`\``; | |
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.`; | |
} | |
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, | |
}); | |
} |