Skip to content

Integration Tests against Staging #70

Integration Tests against Staging

Integration Tests against Staging #70

name: Integration Tests against Staging
on:
schedule:
- cron: '00 20 * * *'
workflow_dispatch:
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
packages: read # Required for pulling packages/images to gcr
jobs:
test-integration:
name: Run Integration Tests against Staging
environment: staging
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- name: Check-out Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure AWS credentials
id: aws-creds
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.AWS_GITHUB_ACTIONS_ROLE }}
role-session-name: GithubWorkflow-Deployment-dev-staging
aws-region: ${{ vars.AWS_PRIMARY_REGION }}
output-credentials: true
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pre-init Devcontainer
run: |
echo "PWD=${GITHUB_WORKSPACE}" >> $GITHUB_ENV
rm .devcontainer/devcontainer.json
echo "Switching to devcontainer-ci.json which is built from the devcontainer image in ghcr, pushed in Pre-build DevContainer job"
cp .devcontainer/devcontainer-ci.json .devcontainer/devcontainer.json
- name: Run Code Validation in Devcontainer
uses: devcontainers/[email protected]
with:
env: |
AWS_ACCESS_KEY_ID=${{ steps.aws-creds.outputs.aws-access-key-id }}
AWS_SECRET_ACCESS_KEY=${{ steps.aws-creds.outputs.aws-secret-access-key }}
AWS_SESSION_TOKEN=${{ steps.aws-creds.outputs.aws-session-token }}
AWS_REGION=${{ vars.AWS_PRIMARY_REGION }}
AWS_ACCOUNT_ID=${{ vars.AWS_ACCOUNT_ID }}
AWS_PRIMARY_REGION=${{ vars.AWS_PRIMARY_REGION }}
AWS_GITHUB_ACTIONS_ROLE=${{ vars.AWS_GITHUB_ACTIONS_ROLE }}
SSM_INSTANCE_ID=${{ vars.SSM_INSTANCE_ID }}
runCmd: |
set -e
echo $"\nRunning detect-secrets..."
poetry run pre-commit run detect-secrets
echo $"\nRunning ruff..."
poetry run pre-commit run --hook-stage push ruff
# echo "\nRunning flake8..."
poetry run pre-commit run --hook-stage push flake8
# echo "\nRunning codespell..."
poetry run pre-commit run --hook-stage push codespell
echo $"\nRunning Unit tests..."
poetry run pre-commit run --hook-stage push unit-tests
echo $"\nVerifying AWS credentials..."
if ! aws sts get-caller-identity; then
echo "AWS authentication failed. Debug info:"
aws sts get-caller-identity --debug
exit 1
fi
echo "Successfully authenticated with AWS"
echo $"\nRunning Integration tests..."
poetry run pytest -m "integration or local_intergation" --durations=10 -vs
echo "Integration tests completed successfully!"