Skip to content

@feature/unit tests #413

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

Open
wants to merge 49 commits into
base: integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
379c9b4
Added js unit tests boilerplating (not working currently)
dimittal Jul 29, 2024
d43b798
Fixed npm run test
dimittal Jul 31, 2024
c8cebd8
Merge branch 'main' of github.com:DrDroidLab/PlayBooks into @feature/…
dimittal Jul 31, 2024
691e085
Merge branch 'integration' of github.com:DrDroidLab/PlayBooks into @f…
dimittal Jul 31, 2024
2928363
Added configs for .tsx tests execution
dimittal Jul 31, 2024
7e594c7
Merge branch 'integration' of github.com:DrDroidLab/PlayBooks into @f…
dimittal Jul 31, 2024
09cd1d5
Added render wrapper over mocked component
dimittal Aug 1, 2024
288ec1c
Merge branch 'integration' of github.com:DrDroidLab/PlayBooks into @f…
dimittal Aug 1, 2024
972fb78
Added js unit tests framework
dimittal Aug 1, 2024
5ba5ef0
Merge branch 'integration' of https://github.com/DrDroidLab/PlayBooks…
jayeshsadhwani99 Aug 3, 2024
e6e44b7
Merge branch 'main' of https://github.com/DrDroidLab/PlayBooks into @…
jayeshsadhwani99 Aug 3, 2024
242b453
unit test for checking for unauthenticatedRoutes
jayeshsadhwani99 Aug 3, 2024
6f6de50
add basic tests for more functions and write doc strings for them
jayeshsadhwani99 Aug 3, 2024
a47ae4d
Added config for js tests
dimittal Aug 5, 2024
4a42ad6
Merge branch 'integration' of https://github.com/DrDroidLab/PlayBooks…
jayeshsadhwani99 Aug 6, 2024
15a4233
add gh workflow
jayeshsadhwani99 Aug 6, 2024
b82870c
add gh workflow yml file
jayeshsadhwani99 Aug 6, 2024
72d242f
just test for frontend
jayeshsadhwani99 Aug 6, 2024
ad4b1dc
change node version
jayeshsadhwani99 Aug 6, 2024
5c6f2a0
give write permissions
jayeshsadhwani99 Aug 6, 2024
d895dd9
remove backend files
jayeshsadhwani99 Aug 6, 2024
493b767
Merge branch 'integration' of https://github.com/DrDroidLab/PlayBooks…
jayeshsadhwani99 Aug 7, 2024
654d735
Merge branch 'integration' of https://github.com/DrDroidLab/PlayBooks…
jayeshsadhwani99 Aug 7, 2024
c98bf8e
Merge branch 'main' of https://github.com/DrDroidLab/PlayBooks into @…
jayeshsadhwani99 Aug 8, 2024
51ac767
Merge branch 'main' of https://github.com/DrDroidLab/PlayBooks into @…
jayeshsadhwani99 Aug 12, 2024
2e18692
Merge branch 'integration' of https://github.com/DrDroidLab/PlayBooks…
jayeshsadhwani99 Aug 12, 2024
21053b3
change deploying after root directory preparation
jayeshsadhwani99 Aug 12, 2024
890a66f
add a coverage folder
jayeshsadhwani99 Aug 12, 2024
080f6ac
add backend coverage
jayeshsadhwani99 Aug 12, 2024
d6559d9
install system dependencies
jayeshsadhwani99 Aug 12, 2024
cce1c3a
always generate report and continue
jayeshsadhwani99 Aug 12, 2024
38de8af
echo links for reports at the end of actions
jayeshsadhwani99 Aug 12, 2024
5443129
sidebar modified with small animations
jayeshsadhwani99 Aug 12, 2024
9a0477e
sidebar animation added
jayeshsadhwani99 Aug 12, 2024
5301317
modify button
jayeshsadhwani99 Aug 12, 2024
7c6ad38
change height
jayeshsadhwani99 Aug 12, 2024
ce8968f
version info ui changes
jayeshsadhwani99 Aug 12, 2024
471d19c
Merge pull request #450 from DrDroidLab/@enhancement/minor-ui-improve…
jayeshsadhwani99 Aug 12, 2024
f9daec7
Merge pull request #451 from DrDroidLab/integration
dimittal Aug 12, 2024
6fcdce2
change input to multi line
jayeshsadhwani99 Aug 12, 2024
f5aa9a7
Merge pull request #452 from DrDroidLab/@hotfix/kubectl-cmd-input-type
dimittal Aug 12, 2024
a0a7276
Merge branch 'main' of https://github.com/DrDroidLab/PlayBooks into @…
jayeshsadhwani99 Aug 12, 2024
ea3fd61
add links to checks and comments
jayeshsadhwani99 Aug 12, 2024
1fefcc6
remove context varibaale
jayeshsadhwani99 Aug 12, 2024
658ff1b
checks addition
jayeshsadhwani99 Aug 12, 2024
99ead7f
try to comment
jayeshsadhwani99 Aug 12, 2024
71b8f93
enable testing
jayeshsadhwani99 Aug 12, 2024
833d3dd
change reports links
jayeshsadhwani99 Aug 12, 2024
d3969b1
Merge pull request #453 from DrDroidLab/@feature/better-link-visibility
dimittal Sep 4, 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
129 changes: 129 additions & 0 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: CI Pipeline

on:
push:
branches:
- "@feature/unit_tests"
pull_request:
branches:
- "@feature/unit_tests"

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

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

# Backend Setup and Testing
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential python3-dev

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

- name: Install Backend Dependencies
run: pip install -r requirements.txt

- name: Run Backend Unit Tests
run: |
pytest --html=report.html --self-contained-html --cov=. --cov-report=html || true
continue-on-error: true

- name: Ensure Report is Generated
run: |
if [ ! -f report.html ]; then
echo "<html><body><h1>No report generated</h1></body></html>" > report.html
fi

# Frontend Setup and Testing
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "19"

- name: Install Frontend Dependencies
working-directory: ./web
run: npm install

- name: Run Frontend Unit Tests
working-directory: ./web
run: npm run test

- name: Generate Frontend Coverage Report
working-directory: ./web
run: npm run test:coverage

- name: Prepare Report Directory
run: |
mkdir -p ./public/reports/frontend
mkdir -p ./public/reports/frontend/coverage

mv ./web/reports/test-report.html ./public/reports/frontend/
mv ./web/coverage/lcov-report/* ./public/reports/frontend/coverage/

mkdir -p ./public/reports/backend
mkdir -p ./public/reports/backend/coverage

mv report.html ./public/reports/backend/
mv htmlcov/* ./public/reports/backend/coverage/

# Deploy reports to GitHub Pages
- name: Deploy to GitHub Pages
if: success()
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public/reports

# Create a GitHub Check Run with Report Links
- name: Create Check Run with Report Links
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { repo, owner } = context.repo;

const reportComment = `
### Test Reports:
- [Frontend Coverage](https://DrDroidLab.github.io/PlayBooks/frontend/coverage/index.html)
- [Frontend Report](https://DrDroidLab.github.io/PlayBooks/frontend/test-report.html)
- [Backend Coverage](https://DrDroidLab.github.io/PlayBooks/backend/coverage/index.html)
- [Backend Report](https://DrDroidLab.github.io/PlayBooks/backend/report.html)
`;

// Create a Check Run using github object
await github.rest.checks.create({
owner: owner,
repo: repo,
name: 'Test Report Links',
head_sha: context.sha,
status: 'completed',
conclusion: 'success',
output: {
title: 'Test Reports',
summary: reportComment,
text: 'Click the links above to view the test coverage and report details.'
}
});

// Comment on the Pull Request if it exists
if (context.payload.pull_request) {
const pr_number = context.payload.pull_request.number;
await github.rest.issues.createComment({
owner: owner,
repo: repo,
issue_number: pr_number,
body: reportComment
});
}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ __pycache__/
*.py[cod]
*$py.class

.gitignore

media/assets/files/*.csv
media/assets/images/*.png

# C extensions
*.so

Expand Down Expand Up @@ -41,6 +46,7 @@ pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
web/coverage/*
.tox/
.nox/
.coverage
Expand Down
2 changes: 1 addition & 1 deletion executor/source_managers/eks_source_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __init__(self):
FormField(key_name=StringValue(value="command"),
display_name=StringValue(value="Kubectl Command"),
data_type=LiteralType.STRING,
form_field_type=FormFieldType.TYPING_DROPDOWN_FT),
form_field_type=FormFieldType.MULTILINE_FT),
]
},
}
Expand Down
2 changes: 1 addition & 1 deletion executor/source_managers/gke_source_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __init__(self):
FormField(key_name=StringValue(value="command"),
display_name=StringValue(value="Kubectl Command"),
data_type=LiteralType.STRING,
form_field_type=FormFieldType.TYPING_DROPDOWN_FT),
form_field_type=FormFieldType.MULTILINE_FT),
]
},
}
Expand Down
26 changes: 26 additions & 0 deletions web/jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export default {
preset: "ts-jest/presets/js-with-ts-esm",
testEnvironment: "jest-environment-jsdom",
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "mjs"],
transform: {
"^.+\\.tsx?$": "ts-jest",
},
reporters: [
"default",
["jest-html-reporter", {
pageTitle: "Test Suite Report",
outputPath: "./reports/test-report.html",
includeFailureMsg: true,
includeConsoleLog: true,
}]
],
testMatch: ["**/?(*.)+(spec|test).{ts,tsx}"],
collectCoverage: false,
collectCoverageFrom: ["src/**/*.{ts,tsx}", "!src/**/*.d.ts"],
extensionsToTreatAsEsm: [".ts", ".tsx"],
moduleNameMapper: {
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy",
"^@/(.*)$": "<rootDir>/src/$1",
"^@components/(.*)$": "<rootDir>/src/components/$1",
},
};
Loading
Loading