Skip to content
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
68d7665
test: trigger CI workflow
shiningflash Nov 8, 2025
7ec325e
include path
shiningflash Nov 8, 2025
dcdf4aa
change allure path
shiningflash Nov 8, 2025
ff0ef6b
first generate the Allure report
shiningflash Nov 8, 2025
ba9b14a
Update ci.yml
shiningflash Nov 8, 2025
4e76868
Update ci.yml
shiningflash Nov 8, 2025
576d8d2
allure url message
shiningflash Nov 8, 2025
e255acf
message update
shiningflash Nov 8, 2025
7ce26da
Update ci.yml
shiningflash Nov 8, 2025
35fd8e5
wrong test
shiningflash Nov 8, 2025
8fa2fae
Update ci.yml
shiningflash Nov 8, 2025
6d5abb8
run always
shiningflash Nov 8, 2025
9547244
Update ci.yml
shiningflash Nov 8, 2025
1b830db
Update ci.yml
shiningflash Nov 8, 2025
74f655f
Update ci.yml
shiningflash Nov 8, 2025
d870555
Update ci.yml
shiningflash Nov 8, 2025
c3bb3a3
Update ci.yml
shiningflash Nov 9, 2025
9eb0dcf
Update ci.yml
shiningflash Nov 9, 2025
2fd4008
Update ci.yml
shiningflash Nov 9, 2025
fadf5de
Update ci.yml
shiningflash Nov 9, 2025
36ca6be
more error
shiningflash Nov 9, 2025
bd5c597
Update test_contacts_integration.py
shiningflash Nov 9, 2025
d0fa379
Update Allure report build info and fix test assertion
shiningflash Nov 9, 2025
043b55a
Update test_contacts_e2e.py
shiningflash Nov 9, 2025
600e588
Update ci.yml
shiningflash Nov 9, 2025
0a8d26b
Update test_contacts_e2e.py
shiningflash Nov 9, 2025
db54f8e
Update ci.yml
shiningflash Nov 9, 2025
297fe20
Update ci.yml
shiningflash Nov 9, 2025
6f3069e
Update test_contacts_e2e.py
shiningflash Nov 9, 2025
49920ec
Update ci.yml
shiningflash Nov 9, 2025
b4f45f9
Update test_contacts_e2e.py
shiningflash Nov 9, 2025
0b1fdcc
Update .github/workflows/ci.yml
shiningflash Nov 9, 2025
8cdf400
Update ci.yml
shiningflash Nov 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 103 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: CI - Code Testing Workflow

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- develop
- main
Expand All @@ -10,52 +11,133 @@ on:
paths:
- "src/**"
- "tests/**"

permissions:
contents: write
pull-requests: write
checks: write
- ".github/workflows/**"
push:
branches:
- develop
- main
paths:
- "src/**"
- "tests/**"
- ".github/workflows/**"

jobs:
test:
name: Run Tests and Post Coverage
concurrency:
group: allure-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest

env: # Load environment variables from repository secrets
permissions:
contents: write
pull-requests: write
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow is missing the checks: write permission that was present in the original version. This permission may be needed by the MishaKav/pytest-coverage-comment action to update check status. Consider adding it back:

permissions:
  contents: write
  pull-requests: write
  checks: write
Suggested change
pull-requests: write
pull-requests: write
checks: write

Copilot uses AI. Check for mistakes.
env:
BASE_URL: ${{ secrets.BASE_URL }}
API_KEY: ${{ secrets.API_KEY }}
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}

steps:
# Step 1: Checkout the repository code
- name: Checkout code
uses: actions/checkout@v3

# Step 2: Set up Python environment
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"

# Step 3: Install dependencies
- name: Set up Node (for Allure CLI)
uses: actions/setup-node@v4
with:
node-version: "18"

- name: Install dependencies
run: |
python -m venv venv # Create a virtual environment
source venv/bin/activate # Activate the virtual environment
pip install --upgrade pip # Upgrade pip
pip install pytest pytest-cov # Install coverage tools
pip install -r requirements.txt # Install project dependencies

# Step 4: Run tests with coverage
- name: Run tests with coverage
python -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install pytest pytest-cov allure-pytest
pip install -r requirements.txt
Comment on lines 53 to +59
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Python dependencies are installed on every run without caching, which is inefficient. Consider adding pip caching:

- name: Cache Python dependencies
  uses: actions/cache@v3
  with:
    path: |
      venv
      ~/.cache/pip
    key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
    restore-keys: |
      ${{ runner.os }}-pip-

- name: Install dependencies
  run: |
    python -m venv venv
    source venv/bin/activate
    pip install --upgrade pip
    pip install pytest pytest-cov allure-pytest
    pip install -r requirements.txt

Copilot uses AI. Check for mistakes.
npm install -g allure-commandline
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing allure-commandline globally via npm on every workflow run is inefficient. Consider using a cached installation or a pre-built Docker image with Allure already installed. For example:

- name: Cache Allure CLI
  uses: actions/cache@v3
  with:
    path: ~/.npm
    key: ${{ runner.os }}-allure-${{ hashFiles('**/package-lock.json') }}
    
- name: Install Allure CLI
  run: npm install -g allure-commandline

Copilot uses AI. Check for mistakes.

- name: Run tests (coverage + allure results)
id: run_tests
run: |
source venv/bin/activate
pytest --cov=src --cov-report=xml --cov-report=term > coverage.txt
pytest --junitxml=pytest.xml
pytest --cov=src --cov-report=xml --cov-report=term \
--alluredir=allure-results --junitxml=pytest.xml --tb=short > coverage.txt 2>&1 || echo "TESTS_FAILED=true" >> $GITHUB_ENV
continue-on-error: true

# Step 5: Post coverage summary to the pull request
- name: Pytest coverage comment
if: github.event_name == 'pull_request' && always()
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./coverage.txt
junitxml-path: ./pytest.xml

- name: Pull previous Allure history (if exists)
if: always()
run: |
git fetch origin allure-report || true
if git ls-remote --exit-code origin allure-report; then
git checkout origin/allure-report -- history || true
if [ -d history ]; then
mkdir -p allure-results/history
cp -r history/* allure-results/history/ || true
fi
Comment on lines +82 to +86
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The git checkout operation on line 82 may fail in some scenarios because it's trying to checkout a path from a remote branch without proper setup. Consider using a more robust approach:

run: |
  git fetch origin allure-report || true
  if git ls-remote --exit-code origin allure-report; then
    git checkout origin/allure-report || true
    if [ -d history ]; then
      mkdir -p allure-results/history
      cp -r history/* allure-results/history/ || true
    fi
    git checkout - || true
  fi

This ensures you return to the original branch after checking out the history.

Suggested change
git checkout origin/allure-report -- history || true
if [ -d history ]; then
mkdir -p allure-results/history
cp -r history/* allure-results/history/ || true
fi
git checkout origin/allure-report || true
if [ -d history ]; then
mkdir -p allure-results/history
cp -r history/* allure-results/history/ || true
fi
git checkout - || true

Copilot uses AI. Check for mistakes.
fi

- name: Generate Allure Report
if: always()
run: |
allure generate allure-results -o allure-report --clean || echo "No allure-results to generate"
echo "<!-- build: run-${{ github.run_number }} -->" >> allure-report/index.html
touch allure-report/.nojekyll

Comment on lines +93 to +95
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If allure generate fails and outputs the fallback message, the subsequent commands on lines 93-94 will fail because the allure-report directory won't exist. Consider adding a check:

run: |
  allure generate allure-results -o allure-report --clean || echo "No allure-results to generate"
  if [ -d allure-report ]; then
    echo "<!-- build: run-${{ github.run_number }} -->" >> allure-report/index.html
    touch allure-report/.nojekyll
  fi
Suggested change
echo "<!-- build: run-${{ github.run_number }} -->" >> allure-report/index.html
touch allure-report/.nojekyll
if [ -d allure-report ]; then
echo "<!-- build: run-${{ github.run_number }} -->" >> allure-report/index.html
touch allure-report/.nojekyll
fi

Copilot uses AI. Check for mistakes.
- name: Deploy Allure Report to GitHub Pages branch
if: always()
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: allure-report
publish_dir: ./allure-report
keep_files: true
force_orphan: false
commit_message: "docs(allure): update report for ${{ github.sha }} (run ${{ github.run_number }})"
Comment on lines +96 to +105
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The peaceiris/actions-gh-pages action will fail if the publish_dir (./allure-report) doesn't exist. Since the previous step may fail to generate the report, this step should check for the directory's existence:

- name: Deploy Allure Report to GitHub Pages branch
  if: always() && hashFiles('allure-report/index.html') != ''
  uses: peaceiris/actions-gh-pages@v3

Alternatively, add a condition to only deploy if the report was successfully generated.

Copilot uses AI. Check for mistakes.

- name: Comment PR with Allure Report URL
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const bust = `${context.runNumber}`;
const reportUrl = `https://${owner}.github.io/${repo}/?run=${bust}`;

// Determine test result color and icon
const testsFailed = process.env.TESTS_FAILED === 'true';
const badgeColor = testsFailed ? 'E63946' : '2EA44F'; // red : green
const testStatus = testsFailed ? '⚠️ (Some tests failed)' : '✅ All tests passed';

const body = `## 📊 Test Report ${testStatus}

Coverage trends • Module breakdown • Failure analysis • Execution timeline

[![View Allure Dashboard](https://img.shields.io/badge/View%20Dashboard-${badgeColor}?style=for-the-badge&logo=google-chrome&logoColor=white)](${reportUrl})

⚠️ NB: If the dashboard doesn't update immediately, try a hard reload (Cmd + Shift + R on Mac) or open in incognito mode.`;

Comment on lines +122 to +129
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The markdown body contains incorrect indentation that will render as a code block. The lines should not be indented. Update to:

const body = `## 📊 Test Report ${testStatus}

Coverage trends • Module breakdown • Failure analysis • Execution timeline

[![View Allure Dashboard](https://img.shields.io/badge/View%20Dashboard-${badgeColor}?style=for-the-badge&logo=google-chrome&logoColor=white)](${reportUrl})

⚠️ NB: If the dashboard doesn't update immediately, try a hard reload (Cmd + Shift + R on Mac) or open in incognito mode.`;

The current indentation will cause GitHub to render the content as preformatted code.

Suggested change
const body = `## 📊 Test Report ${testStatus}
Coverage trends • Module breakdown • Failure analysis • Execution timeline
[![View Allure Dashboard](https://img.shields.io/badge/View%20Dashboard-${badgeColor}?style=for-the-badge&logo=google-chrome&logoColor=white)](${reportUrl})
⚠️ NB: If the dashboard doesn't update immediately, try a hard reload (Cmd + Shift + R on Mac) or open in incognito mode.`;
const body = [
`## 📊 Test Report ${testStatus}`,
'',
'Coverage trends • Module breakdown • Failure analysis • Execution timeline',
'',
`[![View Allure Dashboard](https://img.shields.io/badge/View%20Dashboard-${badgeColor}?style=for-the-badge&logo=google-chrome&logoColor=white)](${reportUrl})`,
'',
'⚠️ NB: If the dashboard doesn\'t update immediately, try a hard reload (Cmd + Shift + R on Mac) or open in incognito mode.'
].join('\n');

Copilot uses AI. Check for mistakes.
const { data: comments } = await github.rest.issues.listComments({
owner, repo, issue_number: context.issue.number
});
const marker = '📊 Test Report';
const existing = comments.find(c => c.user.type === 'Bot' && c.body.includes(marker));
if (existing) {
await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body });
} else {
await github.rest.issues.createComment({ owner, repo, issue_number: context.issue.number, body });
}

- name: Fail job if tests failed
if: env.TESTS_FAILED == 'true'
run: exit 1