Skip to content
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

Setting up allure for integration tests #491

Merged
merged 54 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
e6a8cea
First draft
swetha1654 Dec 2, 2024
849d974
Merge branch 'main' into ISD-2620-allure
swetha1654 Dec 2, 2024
c39ab8b
Edits
swetha1654 Dec 2, 2024
b2208a0
upload allure results
swetha1654 Dec 4, 2024
b9ad38a
added allure-pytest
swetha1654 Dec 4, 2024
9d26d45
debug lines
swetha1654 Dec 4, 2024
4f456bc
debug lines
swetha1654 Dec 4, 2024
399c7dc
debug lines
swetha1654 Dec 4, 2024
5904407
debug lines
swetha1654 Dec 4, 2024
7434888
debug lines
swetha1654 Dec 4, 2024
facf0c1
getting integ to run
swetha1654 Dec 4, 2024
76b8b13
getting integ to run
swetha1654 Dec 4, 2024
fe89621
getting integ to run
swetha1654 Dec 5, 2024
f7c81be
getting integ to run
swetha1654 Dec 5, 2024
06ae0c6
getting integ to run
swetha1654 Dec 5, 2024
b46d2be
getting integ to run
swetha1654 Dec 5, 2024
0c6c4c9
getting integ to run
swetha1654 Dec 5, 2024
cba2819
getting integ to run
swetha1654 Dec 5, 2024
fec66c7
adding default result
swetha1654 Dec 6, 2024
a8f2e7c
adding default result
swetha1654 Dec 6, 2024
bd05b70
adding default result
swetha1654 Dec 6, 2024
72aec57
adding default result
swetha1654 Dec 6, 2024
bb9a889
adding default result
swetha1654 Dec 6, 2024
4ddf4a2
adding default result
swetha1654 Dec 9, 2024
9726ee0
adding default result
swetha1654 Dec 9, 2024
ee58e40
adding default result
swetha1654 Dec 9, 2024
cbc8ace
adding default result
swetha1654 Dec 9, 2024
e31c150
adding default result
swetha1654 Dec 9, 2024
cb3a9cc
adding default result
swetha1654 Dec 9, 2024
8da2658
adding default result
swetha1654 Dec 9, 2024
3baff1f
adding default result
swetha1654 Dec 9, 2024
d7eee35
adding default result
swetha1654 Dec 9, 2024
c691921
adding default result
swetha1654 Dec 9, 2024
b2ef7ae
testing operator workflows
swetha1654 Dec 9, 2024
ba02d19
testing
swetha1654 Dec 10, 2024
08e2a7d
testing #
swetha1654 Dec 10, 2024
3bf15ca
testing
swetha1654 Dec 10, 2024
b3c486a
testing
swetha1654 Dec 10, 2024
177f6f4
testing
swetha1654 Dec 10, 2024
53e0331
Update integration_test_allure.md
swetha1654 Dec 10, 2024
5d1b21c
Merge branch 'main' into ISD-2620-allure
swetha1654 Dec 10, 2024
d8b4254
remove python folder
swetha1654 Dec 10, 2024
4c74d54
address review comments
swetha1654 Dec 10, 2024
163d735
address review comments
swetha1654 Dec 11, 2024
b285aaf
address review comments
swetha1654 Dec 11, 2024
aeac64b
address review comments
swetha1654 Dec 11, 2024
1fde840
update tox and add check allure
swetha1654 Dec 11, 2024
a0da652
update tox and add check allure
swetha1654 Dec 11, 2024
4202ba7
update tox and add check allure
swetha1654 Dec 11, 2024
cb41e52
update tox and add check allure
swetha1654 Dec 11, 2024
89c33f4
update tox and add check allure
swetha1654 Dec 11, 2024
90c4f66
test
swetha1654 Dec 11, 2024
27f038a
test
swetha1654 Dec 11, 2024
d4b0c25
test
swetha1654 Dec 11, 2024
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
89 changes: 89 additions & 0 deletions .github/workflows/allure_report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Allure Report Generation
swetha1654 marked this conversation as resolved.
Show resolved Hide resolved

on: [workflow_call]

jobs:
allure-report:
name: (beta) Publish Allure report
runs-on: ubuntu-latest
timeout-minutes: 5
yanksyoon marked this conversation as resolved.
Show resolved Hide resolved
if: always() && !cancelled()
steps:
- name: Download Allure from allure-framwork
# Following instructions from https://allurereport.org/docs/gettingstarted-installation/#install-via-the-system-package-manager-for-linux
run: gh release download --repo allure-framework/allure2 --pattern 'allure_*.deb'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Allure
run: |
sudo apt-get update
sudo apt-get install ./allure_*.deb -y
# For first run, manually create branch with no history
# (e.g.
# git checkout --orphan gh-pages-beta
# git rm -rf .
# touch .nojekyll
# git add .nojekyll
# git commit -m "Initial commit"
# git push origin gh-pages-beta
# )
- name: Checkout GitHub pages branch
uses: actions/checkout@v4
with:
ref: gh-pages
path: repo/
swetha1654 marked this conversation as resolved.
Show resolved Hide resolved
- name: Download first test results
uses: actions/download-artifact@v4
with:
path: allure-results/
pattern: allure-results*
merge-multiple: true
- name: Load test report history
run: |
if [[ -d repo/_latest/history/ ]]
then
echo 'Loading history'
cp -r repo/_latest/history/ allure-results/
fi
- name: Create executor.json
shell: python
run: |
# Reverse engineered from https://github.com/simple-elf/allure-report-action/blob/eca283b643d577c69b8e4f048dd6cd8eb8457cfd/entrypoint.sh
swetha1654 marked this conversation as resolved.
Show resolved Hide resolved
import json

DATA = {
"name": "GitHub Actions",
"type": "github",
"buildOrder": ${{ github.run_number }}, # TODO future improvement: use run ID
"buildName": "Run ${{ github.run_id }}",
"buildUrl": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"reportUrl": "../${{ github.run_number }}/",
}
with open("allure-results/executor.json", "w") as file:
json.dump(DATA, file)
- name: Generate Allure report
run: allure generate
- name: Create index.html
shell: python
run: |
DATA = f"""<!DOCTYPE html>
yanksyoon marked this conversation as resolved.
Show resolved Hide resolved
<meta charset="utf-8">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="refresh" content="0; url=${{ github.run_number }}">
"""
with open("repo/index.html", "w") as file:
file.write(DATA)
- name: Update GitHub pages branch
working-directory: repo/
# TODO future improvement: commit message
swetha1654 marked this conversation as resolved.
Show resolved Hide resolved
run: |
mkdir '${{ github.run_number }}'
rm -f _latest
ln -s '${{ github.run_number }}' _latest
yanksyoon marked this conversation as resolved.
Show resolved Hide resolved
cp -r ../allure-report/. _latest/
git add .
git config user.name "GitHub Actions"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
swetha1654 marked this conversation as resolved.
Show resolved Hide resolved
git commit -m "Allure report ${{ github.run_number }}"
# Uses token set in checkout step
git push origin gh-pages
swetha1654 marked this conversation as resolved.
Show resolved Hide resolved
swetha1654 marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
description: Label for building the charm
type: string
default: ubuntu-latest
calling-job-name:
description: Name of the job that is calling this reusable workflow
type: string
required: true
charmcraft-channel:
description: Charmcraft channel to use for the integration test
type: string
Expand Down Expand Up @@ -316,6 +320,7 @@ jobs:
if: always() && needs.plan.result == 'success' && (needs.build.result == 'success' || toJSON(fromJSON(needs.plan.outputs.plan).build) == '[]')
secrets: inherit
with:
calling-job-name: ${{ inputs.calling-job-name }}
channel: ${{ inputs.channel }}
charmcraft-ref: ${{ inputs.charmcraft-ref }}
charmcraft-repository: ${{ inputs.charmcraft-repository }}
Expand Down
35 changes: 33 additions & 2 deletions .github/workflows/integration_test_run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ name: Run integration tests
on:
workflow_call:
inputs:
calling-job-name:
description: Name of the job that is calling this reusable workflow
type: string
required: true
charmcraft-ref:
description: Used in conjunction with charmcraft-repository to pull and build charmcraft from source instead of using snapstore version.
type: string
Expand Down Expand Up @@ -152,6 +156,9 @@ on:
description: Rules file to ignore any alerts from the ZAP scan
type: string

permissions:
contents: write

jobs:
integration-test:
name: Integration tests
Expand Down Expand Up @@ -294,16 +301,40 @@ jobs:
module="-k ${{ matrix.modules }}"
fi
echo "MODULE=$module" >> $GITHUB_ENV
swetha1654 marked this conversation as resolved.
Show resolved Hide resolved
- name: (beta) Get Allure option
id: allure-option
shell: python
run: |
import os
output = "option=--alluredir=allure-results"
with open(os.environ["GITHUB_OUTPUT"], "a") as file:
file.write(output)
- name: Run k8s integration tests
working-directory: ${{ inputs.working-directory }}
if: ${{ inputs.provider == 'microk8s' }}
run: |
tox -e ${{ inputs.test-tox-env }} -- --model testing --keep-models ${{ env.SERIES }} ${{ env.MODULE }} ${{ env.ARGS }} ${{ inputs.extra-arguments }} ${{ secrets.INTEGRATION_TEST_ARGS }}
pwd
tox -e ${{ inputs.test-tox-env }} -- --model testing --keep-models ${{ env.SERIES }} ${{ env.MODULE }} ${{ env.ARGS }} ${{ steps.allure-option.outputs.option }} ${{ inputs.extra-arguments }} ${{ secrets.INTEGRATION_TEST_ARGS }}
- name: Run lxd integration tests
working-directory: ${{ inputs.working-directory }}
if: ${{ inputs.provider == 'lxd' }}
run: |
tox -e ${{ inputs.test-tox-env }} -- --keep-models ${{ env.SERIES }} ${{ env.MODULE }} ${{ env.ARGS }} ${{ inputs.extra-arguments }} ${{ secrets.INTEGRATION_TEST_ARGS }}
pwd
tox -e ${{ inputs.test-tox-env }} -- --keep-models ${{ env.SERIES }} ${{ env.MODULE }} ${{ env.ARGS }} ${{ steps.allure-option.outputs.option }} ${{ inputs.extra-arguments }} ${{ secrets.INTEGRATION_TEST_ARGS }}
- name: Check Allure directory
working-directory: ${{ inputs.working-directory }}
run: |
pwd
ls -la
ls -la allure-results/
- name: Upload Allure results
timeout-minutes: 3
if: always() && !cancelled()
uses: actions/upload-artifact@v4
with:
name: allure-results-${{ inputs.calling-job-name }}-${{ matrix.modules }}
path: ${{ inputs.working-directory }}allure-results/
if-no-files-found: error
- name: Tmate debugging session (self-hosted)
if: ${{ failure() && (inputs.tmate-debug || runner.debug) && inputs.self-hosted-runner }}
uses: canonical/action-tmate@main
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/workflow_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
working-directory: "tests/workflows/integration/test-upload-charm/"
trivy-image-config: "tests/workflows/integration/test-upload-charm/trivy.yaml"
trivy-severity-config: "CRITICAL,HIGH"
calling-job-name: integration
integration-juju3:
uses: ./.github/workflows/integration_test.yaml
secrets: inherit
Expand All @@ -38,6 +39,7 @@ jobs:
channel: 1.30-strict/stable
provider: microk8s
test-tox-env: "integration-juju3.1"
calling-job-name: integration-juju3
integration-artifact:
uses: ./.github/workflows/integration_test.yaml
secrets: inherit
Expand All @@ -51,6 +53,7 @@ jobs:
test-tox-env: "integration-juju3.1"
upload-image: artifact
microk8s-addons: "dns ingress rbac storage registry"
calling-job-name: integration-artifact
integration-self-hosted:
uses: ./.github/workflows/integration_test.yaml
secrets: inherit
Expand All @@ -59,12 +62,14 @@ jobs:
trivy-image-config: "tests/workflows/integration/test-upload-charm/trivy.yaml"
self-hosted-runner: true
self-hosted-runner-label: "edge"
calling-job-name: integration-self-hosted
integration-rock:
uses: ./.github/workflows/integration_test.yaml
secrets: inherit
with:
working-directory: "tests/workflows/integration/test-rock/"
trivy-image-config: "tests/workflows/integration/test-rock/trivy.yaml"
calling-job-name: integration-rock
integration-rock-artifact:
uses: ./.github/workflows/integration_test.yaml
secrets: inherit
Expand All @@ -73,6 +78,7 @@ jobs:
upload-image: artifact
microk8s-addons: "dns ingress rbac storage registry"
trivy-image-config: "tests/workflows/integration/test-rock/trivy.yaml"
calling-job-name: integration-rock-artifact
integration-craft:
uses: ./.github/workflows/integration_test.yaml
secrets: inherit
Expand All @@ -83,6 +89,7 @@ jobs:
charmcraft-ref: main
rockcraft-repository: canonical/rockcraft
rockcraft-ref: main
calling-job-name: integration-craft
publish:
uses: ./.github/workflows/publish_charm.yaml
secrets: inherit
Expand Down Expand Up @@ -132,3 +139,14 @@ jobs:
[ '${{ needs.integration-craft.result }}' = 'success' ] || (echo integration-craft failed && false)
[ '${{ needs.publish.result }}' != 'failure' ] || (echo publish failed && false)
[ '${{ needs.publish-artifact.result }}' != 'failure' ] || (echo publish failed && false)
allure-report:
if: always() && !cancelled()
needs:
- integration
- integration-juju3
- integration-artifact
- integration-self-hosted
- integration-rock
- integration-rock-artifact
- integration-craft
uses: ./.github/workflows/allure_report.yaml
1 change: 1 addition & 0 deletions tests/workflows/integration/test-rock/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ops
allure-pytest>=2.8.18

Check warning on line 2 in tests/workflows/integration/test-rock/requirements.txt

View workflow job for this annotation

GitHub Actions / simple / Style checker

[vale] reported by reviewdog 🐶 [Canonical.012-Date-format] Use the '1 January 1970' format instead of '2.8.18' Raw Output: {"message": "[Canonical.012-Date-format] Use the '1 January 1970' format instead of '2.8.18'", "location": {"path": "tests/workflows/integration/test-rock/requirements.txt", "range": {"start": {"line": 2, "column": 16}}}, "severity": "WARNING"}

Check warning on line 2 in tests/workflows/integration/test-rock/requirements.txt

View workflow job for this annotation

GitHub Actions / simple-self-hosted / Style checker

[vale] reported by reviewdog 🐶 [Canonical.012-Date-format] Use the '1 January 1970' format instead of '2.8.18' Raw Output: {"message": "[Canonical.012-Date-format] Use the '1 January 1970' format instead of '2.8.18'", "location": {"path": "tests/workflows/integration/test-rock/requirements.txt", "range": {"start": {"line": 2, "column": 16}}}, "severity": "WARNING"}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ops >= 1.5.0
allure-pytest>=2.8.18

Check warning on line 2 in tests/workflows/integration/test-upload-charm/requirements.txt

View workflow job for this annotation

GitHub Actions / simple / Style checker

[vale] reported by reviewdog 🐶 [Canonical.012-Date-format] Use the '1 January 1970' format instead of '2.8.18' Raw Output: {"message": "[Canonical.012-Date-format] Use the '1 January 1970' format instead of '2.8.18'", "location": {"path": "tests/workflows/integration/test-upload-charm/requirements.txt", "range": {"start": {"line": 2, "column": 16}}}, "severity": "WARNING"}

Check warning on line 2 in tests/workflows/integration/test-upload-charm/requirements.txt

View workflow job for this annotation

GitHub Actions / simple-self-hosted / Style checker

[vale] reported by reviewdog 🐶 [Canonical.012-Date-format] Use the '1 January 1970' format instead of '2.8.18' Raw Output: {"message": "[Canonical.012-Date-format] Use the '1 January 1970' format instead of '2.8.18'", "location": {"path": "tests/workflows/integration/test-upload-charm/requirements.txt", "range": {"start": {"line": 2, "column": 16}}}, "severity": "WARNING"}
Loading