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

feat(tests): setup qase integration #209

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
89b5e4e
feat(tests): setup qase integration
mirekys Aug 28, 2024
1b501f4
feat(tests): setup qase gh actions env
mirekys Aug 28, 2024
840b1e4
feat(tests): set secrets inherit
mirekys Aug 28, 2024
ce9e2cc
Update build.yaml - set qase environment
mirekys Aug 28, 2024
d88e7f0
feat(tests): remove conflicting qase id
mirekys Aug 29, 2024
213bf2d
Merge remote-tracking branch 'origin/mirekys/qase-integration' into m…
mirekys Aug 29, 2024
b090227
feat(tests): add failing http request
mirekys Aug 29, 2024
fc378ba
Update build.yaml
brablcp Sep 4, 2024
a2e0f62
Update build.yaml
brablcp Sep 4, 2024
d56d356
Update build.yaml
brablcp Sep 4, 2024
efdbc76
Update build.yaml
brablcp Sep 5, 2024
9b7ba98
fix(qase): link wrkflow run with qase
mirekys Sep 5, 2024
fd23f8a
fix(qase): pass full env
mirekys Sep 5, 2024
624a954
fix(qase): add back missing secrets inherit
mirekys Sep 5, 2024
e215c6c
Merge pull request #212 from oarepo/detached2
mirekys Sep 5, 2024
e300da1
fix(qase): use different linking gh action
mirekys Sep 5, 2024
9e507e6
fix(qase): set required qase api url
mirekys Sep 5, 2024
810e760
feat(qase): add manual qase workflow dispatch
mirekys Sep 9, 2024
311e078
feat(qase): extract link job from buildsx
mirekys Sep 9, 2024
fc70fee
feat(qase): hotfix for gh to recognize new workflow
mirekys Sep 9, 2024
cabc4bc
feat(qase): hotfix roll back
mirekys Sep 9, 2024
b09e945
Merge branch 'mirekys/qase-integration' into detached
mirekys Sep 9, 2024
0945532
Merge pull request #211 from oarepo/detached
mirekys Sep 9, 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
73 changes: 59 additions & 14 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,34 @@ name: Build and test
on:
workflow_call:
inputs:
qase_api_base_url:
description: 'Qase API URL'
required: true
qase_report:
description: 'Enabled/disabled reporting to Qase'
required: true
qase_project_code:
description: 'Qase project code'
required: true
qase_run_id:
description: 'Qase Run ID'
required: true
qase_run_complete:
description: 'Qase Run autocomplete'
required: true
oarepo:
description: OARepo version (11, 12, ...)
description: 'OARepo version (11, 12, ...)'
required: true
default: "12"
type: string

env:
OAREPO_VERSION: ${{ inputs.oarepo }}
QASE_API_BASE_URL: ${{ inputs.qase_api_base_url }}
QASE_TESTOPS_PROJECT: ${{ inputs.qase_project_code }}
QASE_TESTOPS_RUN_ID: ${{ inputs.qase_run_id }}
QASE_TESTOPS_RUN_COMPLETE: ${{ inputs.qase_run_complete }}
QASE_TESTOPS_API_TOKEN: ${{ secrets.QASE_TESTOPS_API_TOKEN }}

jobs:
build:
Expand All @@ -26,65 +46,90 @@ jobs:
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
- "5432:5432"

steps:
- name: Show oarepo version
run: |
# Checkout code
- uses: actions/checkout@v4

# Set up Node.js
- uses: actions/setup-node@v4

# Link with Qase
- uses: cskmnrpt/qase-link-run@v2
env:
QASE_API_TOKEN: ${{ env.QASE_API_TOKEN }}

# Install npm dependencies and run tests
- run: npm install
- run: npm test

# Ensure environment variables and initial setup
- name: Set up environment and initial configuration
run: |
echo "Setting up environment..."
echo "OAREPO_VERSION: >>>$OAREPO_VERSION<<< >>>${{ inputs.oarepo }}<<<"
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3

# Set up Python
- uses: actions/setup-python@v3
with:
python-version: "3.10"

# Cache pip dependencies
- name: Cache pip
uses: actions/cache@v3
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-

# Configure sysctl limits
- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144

- name: Runs Opensearch
# Run Opensearch
- name: Run Opensearch
uses: ankane/setup-opensearch@v1
with:
plugins: analysis-icu

# Start Redis
- name: Start Redis
uses: supercharge/[email protected]
with:
redis-version: ${{ matrix.redis-version }}

- name: Run tests
env:
QASE_TESTOPS_API_TOKEN: ${{ secrets.QASE_TESTOPS_API_TOKEN }}
QASE_TESTOPS_PROJECT: ${{ secrets.QASE_TESTOPS_PROJECT }}
QASE_ENVIRONMENT: gh-ci
run: |
./run-tests.sh


# Build Python package
- name: Build package to publish
run: |
.venv/bin/python setup.py sdist bdist_wheel

# Freeze Python packages
- name: Freeze packages
run: |
.venv/bin/pip freeze > requirements.txt

- name: Archive production artifacts
# Archive production artifacts
- name: Archive production artifacts (dist)
uses: actions/upload-artifact@v3
with:
name: dist
path: dist

- name: Archive production artifacts
- name: Archive production artifacts (requirements)
uses: actions/upload-artifact@v3
with:
name: requirements.txt
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/manual-qase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build and test from Qase
on:
workflow_dispatch:
inputs:
qase_api_base_url:
description: 'Qase API URL'
required: true
qase_report:
description: 'Enabled/disabled reporting to Qase'
required: true
qase_project_code:
description: 'Qase project code'
required: true
qase_run_id:
description: 'Qase Run ID'
required: true
qase_run_complete:
description: 'Qase Run autocomplete'
required: true
oarepo:
description: OARepo version (11, 12, ...)
required: true
default: "12"
type: string
env:
QASE_API_BASE_URL: ${{ inputs.qase_api_base_url }}
QASE_TESTOPS_PROJECT: ${{ inputs.qase_project_code }}
QASE_TESTOPS_RUN_ID: ${{ inputs.qase_run_id }}
QASE_TESTOPS_RUN_COMPLETE: true
QASE_TESTOPS_API_TOKEN: ${{ secrets.QASE_TESTOPS_API_TOKEN }}
QASE_ENVIRONMENT: gh-ci

jobs:
link:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: cskmnrpt/qase-link-run@v2
name: Link workflow run with Qase
env:
QASE_TESTOPS_API_TOKEN: ${{ secrets.QASE_TESTOPS_API_TOKEN }}
QASE_API_TOKEN: ${{ secrets.QASE_TESTOPS_API_TOKEN }}
QASE_TESTOPS_PROJECT: ${{ secrets.QASE_TESTOPS_PROJECT }}
QASE_ENVIRONMENT: gh-ci
build:
uses: ./.github/workflows/build.yaml
secrets: inherit
with:
oarepo: ${{ github.event.inputs.oarepo }}
1 change: 1 addition & 0 deletions .github/workflows/manual.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ on:
jobs:
build:
uses: ./.github/workflows/build.yaml
secrets: inherit
with:
oarepo: ${{ github.event.inputs.oarepo }}
1 change: 1 addition & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ permissions:
jobs:
build12:
uses: ./.github/workflows/build.yaml
secrets: inherit
with:
oarepo: "12"

Expand Down
32 changes: 32 additions & 0 deletions qase.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"mode": "testops",
"fallback": "report",
"report": {
"driver": "local",
"connection": {
"local": {
"path": "./build/qase-report",
"format": "json"
}
}
},
"testops": {
"project": "NRPP",
"run": {
"title": "Automated PyTest run",
"complete": true
},
"defect": true,
"bulk": true,
"chunk": 200
},
"framework": {
"pytest": {
"capture": {
"logs": true,
"http": true
}
}
},
"environment": "local"
}
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dev =
autoflake
oarepo-tools
tests =
qase-pytest
pytest>=7.1.2
psutil

Expand Down
135 changes: 135 additions & 0 deletions tests/test_quase_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
from qase.pytest import qase
import requests


@qase.step("Step 01")
def step01():
step02()
pass


@qase.step("Step 02")
def step02():
pass


def test_with_steps_success():
step01()
with qase.step("Step 03"):
pass
assert 1 == 1


def test_with_steps_failed():
step01()
with qase.step("Step 03"):
pass
assert 1 == 2

def test_with_qase_id_success():
assert 1 == 1


def test_with_qase_id_failed():
assert 1 == 2


@qase.title("Simple test success")
def test_with_title_success():
assert 1 == 1


@qase.title("Simple test failed")
def test_with_title_failed():
assert 1 == 2


@qase.description("Try to login to Qase TestOps using login and password 1")
def test_with_description_success():
assert 1 == 1


@qase.description("Try to login to Qase TestOps using login and password")
def test_with_description_failed():
assert 1 == 2


@qase.preconditions("*Precondition 1*. Markdown is supported.")
def test_with_preconditions_success():
assert 1 == 1


@qase.preconditions("*Precondition 1*. Markdown is supported.")
def test_with_preconditions_failed():
assert 1 == 2


@qase.postconditions("*Postcondition 1*. Markdown is supported.")
def test_with_postconditions_success():
assert 1 == 1


@qase.postconditions("*Postcondition 1*. Markdown is supported.1")
def test_with_postconditions_failed():
assert 1 == 2


@qase.severity("normal")
def test_with_severity_success():
assert 1 == 1


@qase.severity("normal")
def test_with_severity_failed():
assert 1 == 2


@qase.priority("high")
def test_with_priority_success():
assert 1 == 1


@qase.priority("high")
def test_with_priority_failed():
assert 1 == 2


@qase.layer("unit")
def test_with_layer_success():
assert 1 == 1


@qase.layer("unit")
def test_with_layer_failed():
assert 1 == 2

@qase.layer("unit")
def test_request_with_failed():
url = f"http://localhost/api/health"
response = requests.get(url)
assert response.status_code == 200


@qase.fields(
("severity", "normal"),
("custom_field", "value"),
("priority", "high"),
("layer", "unit"),
("description", "Try to login to Qase TestOps using login and password"),
("preconditions", "*Precondition 1*. Markdown is supported."),
("postconditions", "*Postcondition 1*. Markdown is supported."),
)
def test_with_fields_success():
assert 1 == 1


@qase.fields(
("severity", "normal"),
("priority", "high"),
("layer", "unit"),
("description", "Try to login to Qase TestOps using login and password"),
("preconditions", "*Precondition 1*. Markdown is supported."),
("postconditions", "*Postcondition 1*. Markdown is supported."),
)
def test_with_fields_failed():
assert 1 == 2