-
Notifications
You must be signed in to change notification settings - Fork 1
feat: unit tests #20
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
HarishChandran3304
wants to merge
6
commits into
version-16-hotfix
Choose a base branch
from
feat/unit-tests-2
base: version-16-hotfix
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: unit tests #20
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3e20e70
chore: address pre-existing semgrep and ruff findings
HarishChandran3304 e9c57db
chore: sync tooling drift
HarishChandran3304 5d2a45d
test: add full suite for openapi spec generator and lifecycle hooks
HarishChandran3304 21237ba
ci: add unit tests workflow
HarishChandran3304 6afeeb2
fix: pin frappe branch on bench init and exercise multi-method decora…
HarishChandran3304 8d2e07d
ci: bump checkout, setup-python, and setup-node action versions
HarishChandran3304 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| ## Description | ||
|
|
||
| <!-- What do we want to achieve with this PR? --> | ||
|
|
||
| ## Relevant Technical Choices | ||
|
|
||
| <!-- For Code Reviewers: Please describe your changes. --> | ||
|
|
||
| ## Testing Instructions | ||
|
|
||
| <!-- For someone doing QA: How can the changes in this PR be tested? Please provide step-by-step instructions to test the changes. --> | ||
|
|
||
| ## Additional Information: | ||
|
|
||
| <!-- Include any other context, links, or references that reviewers or QA should be aware of. --> | ||
|
|
||
| ## Screenshot/Screencast | ||
|
|
||
| <!-- Add visual aids to demonstrate the changes made in this PR, if applicable. --> | ||
|
|
||
|
|
||
| ## Checklist | ||
|
|
||
| <!-- Check these after creating PR, use NA if something is not applicable --> | ||
|
|
||
| - [ ] I have carefully reviewed the code before submitting it for review. | ||
| - [ ] This code is adequately covered by unit tests to validate its functionality. | ||
| - [ ] I have conducted thorough testing to ensure it functions as intended. | ||
| - [ ] A member of the QA team has reviewed and tested this PR (To be checked by QA or code reviewer) | ||
|
|
||
| <!-- | ||
| Example: | ||
|
|
||
| Fixes #123 | ||
| Partially addresses #22 | ||
| See #834 | ||
| --> | ||
|
|
||
| Fixes # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| name: Bench Build Test | ||
|
|
||
| on: | ||
| pull_request: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.repository }}-${{ github.event.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| Bench-Build-Test: | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: docker.io/frappe/bench:latest | ||
| options: --user root | ||
|
|
||
| steps: | ||
| - name: Setup Github ENV | ||
| run: | | ||
| echo "HOME=/home/frappe" >> $GITHUB_ENV | ||
| echo "PATH=/home/frappe/.local/bin:$PATH" >> $GITHUB_ENV | ||
|
|
||
| - name: Create a new minimal bench | ||
| run: | | ||
| cd /home/frappe | ||
| su frappe bash -c "bench init frappe-bench --skip-redis-config-generation --no-procfile --skip-assets --frappe-branch version-16" | ||
|
|
||
| - name: Get Dependent Apps | ||
| run: | | ||
| cd /home/frappe/frappe-bench | ||
| # Use public URL for public repos, authenticated URL for private repos | ||
| if [ "${{ github.event.pull_request.head.repo.private }}" = "false" ]; then | ||
| # This is a public repository (could be a fork or not) | ||
| git clone https://github.com/${{ github.event.pull_request.head.repo.full_name }} -b ${{ github.event.pull_request.head.ref }} --depth=1 app_repo | ||
| else | ||
| # Private repository, use authentication | ||
| git clone https://rtbot:${{ secrets.RTBOT_TOKEN }}@github.com/${{ github.event.pull_request.head.repo.full_name }} -b ${{ github.event.pull_request.head.ref }} --depth=1 app_repo | ||
| fi | ||
| DEPS=$(grep -E "required_apps\s*=\s*\[" app_repo/*/hooks.py | sed 's/.*\[\(.*\)\]/\1/g' | tr -d '"' | tr -d "'" | tr ',' '\n' | awk '{$1=$1};1') | ||
| rm -rf app_repo | ||
| for dep in $DEPS; do | ||
| su frappe bash -c "bench get-app $dep" | ||
| done | ||
|
|
||
| - name: Get APP and Build | ||
| run: | | ||
| cd /home/frappe/frappe-bench | ||
| if [ "${{ github.event.pull_request.head.repo.private }}" = "false" ]; then | ||
| # Public fork | ||
| su frappe bash -c "bench get-app https://github.com/${{ github.event.pull_request.head.repo.full_name }} --branch ${{ github.event.pull_request.head.ref }}" | ||
| else | ||
| # Private fork (requires token) | ||
| su frappe bash -c "bench get-app https://rtbot:${{ secrets.RTBOT_TOKEN }}@github.com/${{ github.event.pull_request.head.repo.full_name }} --branch ${{ github.event.pull_request.head.ref }}" | ||
| fi | ||
|
|
||
| - name: Cleanup | ||
| if: ${{ always() }} | ||
| uses: rtCamp/action-cleanup@master | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| name: Linters | ||
|
|
||
| on: | ||
| pull_request: | ||
| workflow_dispatch: | ||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| pre-commit: | ||
| name: "Frappe Linter" | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: alpine:latest # latest used here for simplicity, not recommended | ||
| defaults: | ||
| run: | ||
| shell: sh | ||
| steps: | ||
| - name: fix tar dependency in alpine container image | ||
| run: | | ||
| apk --no-cache add tar nodejs npm python3 git bash py3-pip | ||
| npm install -g prettier | ||
| # check python modules installed versions | ||
| python3 -m pip freeze --local | ||
| pip install pre-commit --break-system-packages | ||
|
|
||
| - uses: actions/checkout@v6 | ||
| - run: | | ||
| git config --global --add safe.directory $GITHUB_WORKSPACE | ||
| git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* | ||
|
|
||
| - name: Get changed files | ||
| id: file_changes | ||
| run: | | ||
| export DIFF=$(git diff --name-only origin/${{ github.base_ref }} ${{ github.sha }}) | ||
| echo "Diff between ${{ github.base_ref }} and ${{ github.sha }}" | ||
| echo "files=$( echo "$DIFF" | xargs echo )" >> $GITHUB_OUTPUT | ||
|
|
||
|
|
||
| - name: Cache pre-commit since we use pre-commit from container | ||
| uses: actions/cache@v5 | ||
| with: | ||
| path: ~/.cache/pre-commit | ||
| key: pre-commit-3|${{ hashFiles('.pre-commit-config.yaml') }} | ||
|
|
||
| - name: Execute pre-commit | ||
| run: | | ||
| pre-commit run --color=always --show-diff-on-failure --files ${{ steps.file_changes.outputs.files }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| name: Unit Tests | ||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| push: | ||
| branches: [version-16, version-16-hotfix] | ||
| pull_request: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| Tests: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| services: | ||
| redis-cache: | ||
| image: redis:alpine | ||
| ports: ["13000:6379"] | ||
| redis-queue: | ||
| image: redis:alpine | ||
| ports: ["11000:6379"] | ||
| mariadb: | ||
| image: mariadb:10.6 | ||
| env: | ||
| MYSQL_ROOT_PASSWORD: root | ||
| ports: ["3306:3306"] | ||
| options: --health-cmd="mysqladmin ping -uroot -proot" --health-interval=5s --health-timeout=2s --health-retries=3 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v7 | ||
|
|
||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.14" | ||
|
|
||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 24 | ||
|
|
||
| - uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.cache/pip | ||
| key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} | ||
| restore-keys: ${{ runner.os }}-pip- | ||
|
|
||
| - name: Setup bench | ||
| run: | | ||
| pip install frappe-bench | ||
| bench init --skip-redis-config-generation --skip-assets --frappe-branch version-16 --python "$(which python)" ~/frappe-bench | ||
| mysql --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL character_set_server = 'utf8mb4'" | ||
| mysql --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'" | ||
|
|
||
| - name: Install | ||
| working-directory: /home/runner/frappe-bench | ||
| run: | | ||
| bench get-app frappe_openapi $GITHUB_WORKSPACE | ||
| bench new-site --db-root-password root --admin-password admin --no-mariadb-socket test_site | ||
| bench --site test_site install-app frappe_openapi | ||
| env: | ||
| CI: "Yes" | ||
|
|
||
| - name: Run tests | ||
| working-directory: /home/runner/frappe-bench | ||
| run: | | ||
| bench --site test_site set-config allow_tests true | ||
| bench --site test_site run-tests --app frappe_openapi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,5 +27,4 @@ test*.py | |
| .github/ | ||
|
|
||
| # Markdown files | ||
| *.md | ||
| frappe_skeleton/__init__.py | ||
| *.md | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.