-
Notifications
You must be signed in to change notification settings - Fork 0
Workflows improvement #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
68d7665
7ec325e
dcdf4aa
ff0ef6b
ba9b14a
4e76868
576d8d2
e255acf
7ce26da
35fd8e5
8fa2fae
6d5abb8
9547244
1b830db
74f655f
d870555
c3bb3a3
9eb0dcf
2fd4008
fadf5de
36ca6be
bd5c597
d0fa379
043b55a
600e588
0a8d26b
db54f8e
297fe20
6f3069e
49920ec
b4f45f9
0b1fdcc
8cdf400
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ name: CI - Code Testing Workflow | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||||||||||
| types: [opened, synchronize, reopened, ready_for_review] | ||||||||||||||||||||||||||||||||||
| branches: | ||||||||||||||||||||||||||||||||||
| - develop | ||||||||||||||||||||||||||||||||||
| - main | ||||||||||||||||||||||||||||||||||
|
|
@@ -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 | ||||||||||||||||||||||||||||||||||
| 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
|
||||||||||||||||||||||||||||||||||
| npm install -g allure-commandline | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - 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
|
||||||||||||||||||||||||||||||||||
| 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
AI
Nov 9, 2025
There was a problem hiding this comment.
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| 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
AI
Nov 9, 2025
There was a problem hiding this comment.
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@v3Alternatively, add a condition to only deploy if the report was successfully generated.
Copilot
AI
Nov 9, 2025
There was a problem hiding this comment.
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
[](${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.
| const body = `## 📊 Test Report ${testStatus} | |
| Coverage trends • Module breakdown • Failure analysis • Execution timeline | |
| [](${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', | |
| '', | |
| `[](${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'); |
There was a problem hiding this comment.
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: writepermission that was present in the original version. This permission may be needed by theMishaKav/pytest-coverage-commentaction to update check status. Consider adding it back: