Add integration test coverage for PR validation #364
Workflow file for this run
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
| # | |
| # Copyright 2023 ABSA Group Limited | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| # | |
| name: Build and Test | |
| on: | |
| pull_request: | |
| branches: | |
| - '**' | |
| types: [ opened, synchronize, reopened ] | |
| jobs: | |
| static-code-analysis: | |
| runs-on: ubuntu-latest | |
| name: Pylint Static Code Analysis | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Python | |
| uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| pip install -r requirements.txt | |
| - name: Analyze code with Pylint | |
| id: analyze-code | |
| run: | | |
| pylint_score=$(pylint $(git ls-files '*.py')| grep 'rated at' | awk '{print $7}' | cut -d'/' -f1) | |
| echo "score=$pylint_score" >> "$GITHUB_OUTPUT" | |
| - name: Check Pylint score | |
| run: | | |
| score=${{ steps.analyze-code.outputs.score }} | |
| echo "Pylint score is $score" | |
| if (( $(echo "$score < 9.5" | bc -l) )); then | |
| echo "Failure: Pylint score is below 9.5 (project score: $score)." | |
| exit 1 | |
| else | |
| echo "Success: Pylint score is above 9.5 (project score: $score)." | |
| fi | |
| code-format-check: | |
| runs-on: ubuntu-latest | |
| name: Black Format Check | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Python | |
| uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| pip install -r requirements.txt | |
| - name: Check code format with Black | |
| id: check-format | |
| run: | | |
| black --check $(git ls-files '*.py') | |
| unit-test: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install Python dependencies | |
| run: | | |
| pip install -r requirements.txt | |
| - name: Set PYTHONPATH environment variable | |
| run: echo "PYTHONPATH=${GITHUB_WORKSPACE}/release_notes_generator/release_notes_generator" >> $GITHUB_ENV | |
| - name: Check code coverage with Pytest | |
| run: pytest --cov=. -v tests/unit --cov-fail-under=80 | |
| mypy-check: | |
| runs-on: ubuntu-latest | |
| name: Mypy Type Check | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Python | |
| uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| pip install -r requirements.txt | |
| - name: Check types with Mypy | |
| id: check-types | |
| run: | | |
| mypy . | |
| integration-test: | |
| name: Integration Tests (Mocked) | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install Python dependencies | |
| run: | | |
| pip install -r requirements.txt | |
| - name: Set PYTHONPATH environment variable | |
| run: echo "PYTHONPATH=${GITHUB_WORKSPACE}" >> $GITHUB_ENV | |
| - name: Run mocked integration tests | |
| run: pytest -v tests/integration/test_action_integration.py | |
| smoke-e2e-test: | |
| name: Smoke E2E Test (Real API) | |
| runs-on: ubuntu-latest | |
| # Only run on PRs from same repo (not forks) | |
| if: github.event.pull_request.head.repo.full_name == github.repository | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install Python dependencies | |
| run: | | |
| pip install -r requirements.txt | |
| - name: Set PYTHONPATH environment variable | |
| run: echo "PYTHONPATH=${GITHUB_WORKSPACE}" >> $GITHUB_ENV | |
| - name: Run action against real repository | |
| env: | |
| INPUT_TAG_NAME: 'v0.2.0' | |
| INPUT_GITHUB_REPOSITORY: 'AbsaOSS/generate-release-notes' | |
| INPUT_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| INPUT_CHAPTERS: | | |
| [ | |
| { title: Breaking Changes 💥, label: breaking-change }, | |
| { title: New Features 🎉, label: enhancement }, | |
| { title: New Features 🎉, label: feature }, | |
| { title: Bugfixes 🛠, label: bug } | |
| ] | |
| INPUT_WARNINGS: 'true' | |
| INPUT_PRINT_EMPTY_CHAPTERS: 'false' | |
| INPUT_VERBOSE: 'true' | |
| INPUT_HIERARCHY: 'false' | |
| INPUT_DUPLICITY_SCOPE: 'both' | |
| INPUT_PUBLISHED_AT: 'false' | |
| INPUT_SKIP_RELEASE_NOTES_LABELS: 'skip-release-notes' | |
| run: | | |
| # Run the action with verbose/debug logging | |
| python main.py > output.txt 2>&1 | |
| exit_code=$? | |
| # Display output for debugging | |
| echo "=== Action Output ===" | |
| cat output.txt | |
| echo "=== End of Output ===" | |
| # Check exit code | |
| if [ $exit_code -ne 0 ]; then | |
| echo "❌ Action failed with exit code $exit_code" | |
| exit 1 | |
| fi | |
| # Check for actual generated release notes content (specific markdown chapters) | |
| if grep -qE '^### (Breaking Changes 💥|New Features 🎉|Bugfixes 🛠)' output.txt; then | |
| echo "✅ Action successfully generated release notes with chapters" | |
| else | |
| echo "❌ No release notes chapters found in output" | |
| exit 1 | |
| fi |