Add integration test coverage for PR validation #368
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 . | |
| snapshot-tests: | |
| name: Snapshot 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.13' | |
| 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 all integration tests | |
| run: pytest -v tests/integration/ | |
| integration-test-real-api: | |
| name: Integration Test (Real GitHub 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 and validate output | |
| 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 ===" | |
| # Validation 1: Check exit code | |
| if [ $exit_code -ne 0 ]; then | |
| echo "❌ Action failed with exit code $exit_code" | |
| exit 1 | |
| fi | |
| echo "✅ Action completed with exit code 0" | |
| # Validation 2: Check for markdown chapter headers | |
| if grep -qE '^### (Breaking Changes 💥|New Features 🎉|Bugfixes 🛠)' output.txt; then | |
| echo "✅ Found expected chapter headers in output" | |
| else | |
| echo "❌ No expected chapter headers found in output" | |
| exit 1 | |
| fi | |
| # Validation 3: Check for issue/PR references (e.g., #123) | |
| if grep -qE '#[0-9]+' output.txt; then | |
| echo "✅ Found issue/PR references in output" | |
| else | |
| echo "❌ No issue/PR references found in output" | |
| exit 1 | |
| fi | |
| # Validation 4: Check for developer mentions (e.g., @username) | |
| if grep -qE '@[a-zA-Z0-9_-]+' output.txt; then | |
| echo "✅ Found developer mentions in output" | |
| else | |
| echo "❌ No developer mentions found in output" | |
| exit 1 | |
| fi | |
| # Validation 5: Check for completion message | |
| if grep -q "completed successfully" output.txt; then | |
| echo "✅ Found completion success message in logs" | |
| else | |
| echo "❌ No completion success message found in logs" | |
| exit 1 | |
| fi | |
| # Validation 6: Check for DEBUG log level (verbose mode) | |
| if grep -q "DEBUG" output.txt; then | |
| echo "✅ Verbose logging is working (DEBUG level found)" | |
| else | |
| echo "❌ No DEBUG log messages found (verbose mode may not be working)" | |
| exit 1 | |
| fi | |
| # Validation 7: Verify generated release notes block | |
| if grep -q "Generated release notes:" output.txt; then | |
| echo "✅ Found 'Generated release notes:' marker in output" | |
| else | |
| echo "❌ No 'Generated release notes:' marker found" | |
| exit 1 | |
| fi | |
| echo "" | |
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | |
| echo "✅ All smoke E2E validations passed!" | |
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |