Skip to content

Commit

Permalink
Update logic of tests execution
Browse files Browse the repository at this point in the history
  • Loading branch information
Mykhailo committed Nov 8, 2024
1 parent e7e6694 commit 8fbc9cb
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 25 deletions.
119 changes: 99 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,24 @@ on:
branches: [ "main", "develop" ]

jobs:
build-package:
uses: ./.github/workflows/build-and-check-python-package.yml
with:
path: ./r8s

tests:
needs: build-package
check_modified_files:
name: Check modified files in directories
runs-on: ubuntu-latest
outputs:
docker_files_changes_found: ${{ steps.check_docker_files.outputs.changes_found }}
r8s_files_changes_found: ${{ steps.check_r8s_files.outputs.changes_found }}
src_files_changes_found: ${{ steps.check_src_files.outputs.changes_found }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Check modified files
id: check_files
- name: Check modified files in r8s directory
id: check_r8s_files
shell: bash
run: |
git fetch origin ${{ github.pull_request_target }}
changed_files=$(git diff --name-only ${{ github.pull_request_target }})
git fetch origin ${{ github.event.pull_request.base.sha }}
changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }})
echo "Changed files: ${changed_files}"
checked_directory="r8s/"
for file in ${changed_files}
Expand All @@ -42,20 +37,81 @@ jobs:
echo "Target directory was not modified."
echo "changes_found=false" >>$GITHUB_OUTPUT
echo "dist=/tmp/bavp/dist" >>$GITHUB_OUTPUT
- name: Check modified files in docker directory
id: check_docker_files
shell: bash
run: |
git fetch origin ${{ github.event.pull_request.base.sha }}
changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }})
echo "Changed files: ${changed_files}"
checked_directory="docker/"
for file in ${changed_files}
do
if [[ ${file} == ${checked_directory}* ]]
then
echo "Target directory was modified."
echo "changes_found=true" >>$GITHUB_OUTPUT
exit 0
fi
done
echo "Target directory was not modified."
echo "changes_found=false" >>$GITHUB_OUTPUT
echo "dist=/tmp/bavp/dist" >>$GITHUB_OUTPUT
- name: Check modified files in src directory
id: check_src_files
shell: bash
run: |
git fetch origin ${{ github.event.pull_request.base.sha }}
changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }})
echo "Changed files: ${changed_files}"
checked_directory="src/"
for file in ${changed_files}
do
if [[ ${file} == ${checked_directory}* ]]
then
echo "Target directory was modified."
echo "changes_found=true" >>$GITHUB_OUTPUT
exit 0
fi
done
echo "Target directory was not modified."
echo "changes_found=false" >>$GITHUB_OUTPUT
echo "dist=/tmp/bavp/dist" >>$GITHUB_OUTPUT
build_package:
name: Build CLI package
needs: check_modified_files
if: ${{ needs.check_modified_files.outputs.r8s_files_changes_found == 'true' }}
uses: ./.github/workflows/build-and-check-python-package.yml
with:
path: ./r8s

test_python:
name: Run Python tests
needs: check_modified_files
if: ${{ needs.check_modified_files.outputs.src_files_changes_found == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Setup test env
if: steps.check_files.outputs.changes_found == 'true'
run: |
python -VV
pip install virtualenv
virtualenv .venv
source .venv/bin/activate
pip --cache-dir=.cache/pip --quiet install tox
- name: tests
if: steps.check_files.outputs.changes_found == 'true'
- name: Run tests
run:
source .venv/bin/activate
tox -e py310-lambdas
Expand All @@ -76,7 +132,30 @@ jobs:
path: report.xml
retention-days: 1

- name: docker-tests
test_docker:
name: Run Docker tests
needs: check_modified_files
if: ${{ needs.check_modified_files.outputs.docker_files_changes_found == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Setup test env
run: |
python -VV
pip install virtualenv
virtualenv .venv
source .venv/bin/activate
pip --cache-dir=.cache/pip --quiet install tox
- name: Run docker tests
if: steps.check_files.outputs.changes_found == 'true'
run: |
source .venv/bin/activate
Expand Down
2 changes: 1 addition & 1 deletion docker/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
modular-sdk>=6.0.0,<7.0.0
modular-sdk>=6.0.0,<7.0.0
boto3==1.26.80
botocore==1.29.80
certifi==2023.7.22
Expand Down
4 changes: 2 additions & 2 deletions r8s/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Install
## Install

pip install r8s/

Expand Down Expand Up @@ -438,4 +438,4 @@ _Manages R8s Recommendation entity_

[`describe`](#recommendation-describe) Describes Recommendation entities.

[`update`](#recommendation-update) Updates Recommendation entity.
[`update`](#recommendation-update) Updates Recommendation entity.
4 changes: 2 additions & 2 deletions src/deployment_resources.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"lambda-basic-execution": {
"policy_content": {
"Statement": [
Expand Down Expand Up @@ -3145,4 +3145,4 @@
}
}
}
}
}

0 comments on commit 8fbc9cb

Please sign in to comment.