-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from milistu/feat/tests
Update tests workflow.
- Loading branch information
Showing
1 changed file
with
17 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,59 +1,28 @@ | ||
name: LegaBOt Tests | ||
name: LegaBot Tests | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
check_changes: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
run_database_tests: ${{ steps.filter_files.outputs.database_changed }} | ||
run_router_tests: ${{ steps.filter_files.outputs.router_changed }} | ||
run_llm_tests: ${{ steps.filter_files.outputs.llm_changed }} | ||
|
||
# ------------------------------------------------------------------------------------------------------------------------------------------------ | ||
# Event `pull_request`: Compare the last commit of the main branch or last remote commit of the PR branch -> to the current commit of a PR branch. | ||
# ------------------------------------------------------------------------------------------------------------------------------------------------ | ||
changed_files: | ||
runs-on: ubuntu-latest # windows-latest || macos-latest | ||
name: Test changed-files | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Detect Changes in Specific Directories | ||
id: filter_files | ||
- name: Get changed files in the docs folder | ||
id: changed-files-specific | ||
uses: tj-actions/changed-files@v44 | ||
with: | ||
files: | | ||
database/** | ||
router/** | ||
llm/** | ||
- name: Set Output Variables for Conditional Steps | ||
run: | | ||
echo "Setting output variables..." | ||
echo "::set-output name=database_changed::${{ contains(steps.filter_files.outputs.all_changed_files, 'database/') }}" | ||
echo "::set-output name=router_changed::${{ contains(steps.filter_files.outputs.all_changed_files, 'router/') }}" | ||
echo "::set-output name=llm_changed::${{ contains(steps.filter_files.outputs.all_changed_files, 'llm/') }}" | ||
run_tests: | ||
runs-on: ubuntu-latest | ||
needs: check_changes | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install Dependencies | ||
run: pip install -r requirements.txt | ||
|
||
- name: Run Database Tests | ||
if: ${{ needs.check_changes.outputs.run_database_tests == 'true' }} | ||
run: python -m unittest tests/test_database.py | ||
|
||
- name: Run Router Tests | ||
if: ${{ needs.check_changes.outputs.run_router_tests == 'true' }} | ||
run: python -m unittest tests/test_router.py | ||
|
||
- name: Run LLM Tests | ||
if: ${{ needs.check_changes.outputs.run_llm_tests == 'true' }} | ||
run: python -m unittest tests/test_llm.py | ||
files: router/** # *.{js,html} # Alternatively using: `docs/**` | ||
# files_ignore: docs/static.js | ||
|
||
- name: Run step if any file(s) in the router folder change | ||
if: steps.changed-files-specific.outputs.any_changed == 'true' | ||
env: | ||
ALL_CHANGED_FILES: ${{ steps.changed-files-specific.outputs.all_changed_files }} | ||
run: python -m unittest tests/test_router.py |