|
| 1 | +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +# SPDX-License-Identifier: MIT-0 |
| 3 | + |
| 4 | +name: Developer Tests |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - '**' # Run on PR open, update, or synchronize (i.e., any push to PR branch) |
| 10 | + |
| 11 | +# Global timeout for all jobs |
| 12 | +# Note: GitHub Actions uses minutes, GitLab uses duration strings |
| 13 | +jobs: |
| 14 | + developer_tests: |
| 15 | + name: Lint, Type Check, and Test |
| 16 | + runs-on: ubuntu-latest |
| 17 | + timeout-minutes: 120 # 2 hours |
| 18 | + |
| 19 | + # Use Python 3.13 to match GitLab configuration |
| 20 | + container: |
| 21 | + image: python:3.13-bookworm |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout code |
| 25 | + uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + fetch-depth: 0 # Fetch all history for git diff in typecheck-pr |
| 28 | + |
| 29 | + - name: Set up Git safe directory |
| 30 | + run: | |
| 31 | + git config --global --add safe.directory "$GITHUB_WORKSPACE" |
| 32 | + |
| 33 | + - name: Fetch base branch |
| 34 | + run: | |
| 35 | + git fetch origin ${{ github.base_ref || 'main' }}:refs/remotes/origin/${{ github.base_ref || 'main' }} |
| 36 | + git branch -a |
| 37 | + |
| 38 | + - name: Set up environment |
| 39 | + run: | |
| 40 | + python --version |
| 41 | + apt-get update -y |
| 42 | + apt-get install make curl -y |
| 43 | + |
| 44 | + - name: Install uv |
| 45 | + run: | |
| 46 | + curl -LsSf https://astral.sh/uv/install.sh | sh |
| 47 | + echo "$HOME/.cargo/bin" >> $GITHUB_PATH |
| 48 | + |
| 49 | + - name: Create virtual environment |
| 50 | + run: | |
| 51 | + uv venv .venv |
| 52 | + echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH |
| 53 | + |
| 54 | + - name: Install Node.js and basedpyright |
| 55 | + run: | |
| 56 | + curl -fsSL https://deb.nodesource.com/setup_20.x | bash - |
| 57 | + apt-get install -y nodejs |
| 58 | + npm install -g basedpyright |
| 59 | + |
| 60 | + - name: Install Python dependencies |
| 61 | + run: | |
| 62 | + uv pip install ruff |
| 63 | + uv pip install typer rich boto3 |
| 64 | + cd lib/idp_common_pkg && uv pip install -e ".[test]" && cd ../.. |
| 65 | + |
| 66 | + - name: Run linting checks |
| 67 | + run: make lint-cicd |
| 68 | + |
| 69 | + - name: Run type checking |
| 70 | + run: | |
| 71 | + TARGET_BRANCH="${{ github.base_ref }}" |
| 72 | + echo "=== Type Checking Configuration ===" |
| 73 | + echo "PR target branch (github.base_ref): $TARGET_BRANCH" |
| 74 | + echo "Comparing: origin/$TARGET_BRANCH...HEAD" |
| 75 | + echo "====================================" |
| 76 | + echo "" |
| 77 | + |
| 78 | + python3 scripts/typecheck_pr_changes.py "$TARGET_BRANCH" |
| 79 | + |
| 80 | + - name: Run tests |
| 81 | + id: run-tests |
| 82 | + run: make test-cicd -C lib/idp_common_pkg |
| 83 | + continue-on-error: false |
| 84 | + |
| 85 | + - name: Upload coverage reports |
| 86 | + uses: actions/upload-artifact@v4 |
| 87 | + if: always() && steps.run-tests.outcome != 'skipped' |
| 88 | + with: |
| 89 | + name: test-reports |
| 90 | + path: | |
| 91 | + lib/idp_common_pkg/test-reports/coverage.xml |
| 92 | + lib/idp_common_pkg/test-reports/test-results.xml |
| 93 | + retention-days: 7 |
| 94 | + |
| 95 | + - name: Publish test results |
| 96 | + uses: EnricoMi/publish-unit-test-result-action@v2 |
| 97 | + if: always() && hashFiles('lib/idp_common_pkg/test-reports/test-results.xml') != '' |
| 98 | + with: |
| 99 | + files: lib/idp_common_pkg/test-reports/test-results.xml |
| 100 | + check_name: Test Results |
| 101 | + |
| 102 | + - name: Code Coverage Report |
| 103 | + uses: irongut/CodeCoverageSummary@v1.3.0 |
| 104 | + if: always() && hashFiles('lib/idp_common_pkg/test-reports/coverage.xml') != '' |
| 105 | + with: |
| 106 | + filename: lib/idp_common_pkg/test-reports/coverage.xml |
| 107 | + badge: true |
| 108 | + fail_below_min: false |
| 109 | + format: markdown |
| 110 | + hide_branch_rate: false |
| 111 | + hide_complexity: true |
| 112 | + indicators: true |
| 113 | + output: both |
| 114 | + thresholds: '60 80' |
| 115 | + |
| 116 | + - name: Add Coverage PR Comment |
| 117 | + uses: marocchino/sticky-pull-request-comment@v2 |
| 118 | + if: github.event_name == 'pull_request' && hashFiles('code-coverage-results.md') != '' |
| 119 | + with: |
| 120 | + recreate: true |
| 121 | + path: code-coverage-results.md |
0 commit comments