diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0227b14..940f4e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,31 +13,7 @@ on: - "**.py" jobs: - check_python_changes: - runs-on: ubuntu-latest - outputs: - run_tests: ${{ steps.check_files.outputs.run_tests }} - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Check if Python files changed - id: check_files - run: | - git fetch origin ${{ github.event.before }} - if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q '\.py$'; then - echo "Python files changed" - echo "run_tests=true" >> $GITHUB_ENV - echo "::set-output name=run_tests::true" - else - echo "No Python files changed, skipping tests" - echo "run_tests=false" >> $GITHUB_ENV - echo "::set-output name=run_tests::false" - test: - needs: check_python_changes - if: needs.check_python_changes.outputs.run_tests == 'true' runs-on: ubuntu-latest strategy: @@ -58,6 +34,14 @@ jobs: python -m pip install --upgrade pip pip install -r server/src/requirements.txt + - name: Configure AWS Credentials for Tests + run: | + echo "Setting AWS region and mock credentials..." + export AWS_REGION=us-east-1 + export AWS_ACCESS_KEY_ID=fake_access_key + export AWS_SECRET_ACCESS_KEY=fake_secret_key + export AWS_DEFAULT_REGION=us-east-1 + - name: Run tests with coverage run: | export PYTHONPATH=$(pwd)/server/src @@ -80,14 +64,15 @@ jobs: - name: Show coverage summary run: cat coverage.xml + deploy: - needs: test - if: success() || needs.check_python_changes.outputs.run_tests == 'false' # Deploy if tests pass OR no Python changes + needs: test # Ensures deployment happens only if tests pass runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' # Deploy only from main branch strategy: matrix: - function_name: [fetch_permanent_data, return_luas_data, return_station_data, fetch_transient_data, return_permanent_data, return_transient_data] + function_name: [fetch_permanent_data, return_luas_data, return_station_data, fetch_transient_data __pycache__ return_permanent_data return_transient_data] steps: - name: Checkout repository @@ -98,6 +83,7 @@ jobs: with: python-version: '3.13' + # ✅ Check if AWS CLI is installed and update it instead of reinstalling - name: Check AWS CLI version run: aws --version || echo "AWS CLI not found"