feat: init pytest workflow #12
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: Build And Test | |
on: | |
pull_request: | |
branches: [ "main" ] | |
paths: | |
- .github/workflows/aws-preview.yml | |
- server/** | |
- petercat_utils/** | |
- subscriber/** | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
env: | |
AWS_REGION: ap-northeast-1 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: production | |
strategy: | |
fail-fast: true | |
defaults: | |
run: | |
working-directory: ./server | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::654654285942:role/Github-OIDC | |
audience: sts.amazonaws.com | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12.0' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install ruff | |
pip install pytest pytest-cov pytest-md-report | |
- name: Lint with Ruff | |
run: | | |
ruff check --output-format=github . | |
- name: Test with pytest | |
env: | |
REPORT_OUTPUT: md_report.md | |
run: | | |
echo "REPORT_FILE=${REPORT_OUTPUT}" >> "$GITHUB_ENV" | |
pytest -v --md-report --md-report-flavor gfm --md-report-exclude-outcomes passed skipped xpassed --md-report-output "$REPORT_OUTPUT" | |
- name: Render the report to the PR when tests fail | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
header: test-report | |
recreate: true | |
path: ${{ env.REPORT_FILE }} |