feat/add-weather-analyzer #2
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: build-and-test | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| has_changes: ${{ steps.check.outputs.has_changes }} | |
| changed_files: ${{ steps.check.outputs.changed_files }} | |
| steps: | |
| # 1. Checkout the code from the repository | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| # 2. Get a list of changed .py files | |
| - name: Get changed files | |
| id: changed-files | |
| uses: tj-actions/changed-files@v44 | |
| with: | |
| files: | | |
| **.py | |
| # 3. Set outputs for changed files | |
| - name: Set change flag and files | |
| id: check | |
| run: | | |
| if [ "${{ steps.changed-files.outputs.any_changed }}" == "true" ]; then | |
| echo "has_changes=${{ steps.changed-files.outputs.any_changed }}" >> $GITHUB_OUTPUT | |
| echo "changed_files=${{ steps.changed-files.outputs.all_changed_files }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| echo "changed_files=" >> $GITHUB_OUTPUT | |
| fi | |
| tests: | |
| needs: [check] | |
| if: ${{ needs.check.outputs.has_changes == 'true' }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.10', '3.11', '3.12', '3.13'] | |
| steps: | |
| # 1. Checkout the code from the repository | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| # 2. Set up the Python environment | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| # 3. Install dependencies | |
| - name: Install Dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install ruff mypy pydantic | |
| # 4. Install missing stub packages | |
| - name: Install missing type stubs | |
| run: | | |
| mypy --install-types --non-interactive . | |
| # 5. Run Ruff Linter and show all errors | |
| - name: Run Ruff Linter | |
| run: | | |
| echo "${{ needs.check.outputs.changed_files }}" | xargs ruff check --output-format=github --config=pyproject.toml | |
| # 6. Run Mypy Type Checking and show all errors | |
| - name: Run Mypy Type Checking | |
| run: | | |
| echo "${{ needs.check.outputs.changed_files }}" | xargs mypy --config-file=pyproject.toml | |
| # 7. Run Pytest | |
| - name: Run Pytest | |
| run: | | |
| echo "${{ needs.check.outputs.changed_files }}" | xargs pytest --maxfail=10 --disable-warnings --tb=short |