diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e79f964..82d368e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,31 +5,26 @@ 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: + cli_files_changes_found: ${{ steps.check_cli_files.outputs.changes_found }} + docker_files_changes_found: ${{ steps.check_docker_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 cli directory + id: check_cli_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/" + checked_directory="cli/" for file in ${changed_files} do if [[ ${file} == ${checked_directory}* ]] @@ -42,11 +37,73 @@ 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.cli_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 @@ -54,8 +111,7 @@ jobs: 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 @@ -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 diff --git a/docker/requirements.txt b/docker/requirements.txt index bd29d2d..e7be51b 100644 --- a/docker/requirements.txt +++ b/docker/requirements.txt @@ -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 diff --git a/r8s/README.md b/r8s/README.md index ff57bfe..dc8052d 100644 --- a/r8s/README.md +++ b/r8s/README.md @@ -1,4 +1,4 @@ -## Install +## Install pip install r8s/ @@ -438,4 +438,4 @@ _Manages R8s Recommendation entity_ [`describe`](#recommendation-describe) Describes Recommendation entities. -[`update`](#recommendation-update) Updates Recommendation entity. \ No newline at end of file +[`update`](#recommendation-update) Updates Recommendation entity. diff --git a/src/deployment_resources.json b/src/deployment_resources.json index f41bc93..b034c3c 100644 --- a/src/deployment_resources.json +++ b/src/deployment_resources.json @@ -1,4 +1,4 @@ -{ +{ "lambda-basic-execution": { "policy_content": { "Statement": [ @@ -3145,4 +3145,4 @@ } } } -} \ No newline at end of file +}