|
| 1 | +name: Run e2e tests |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - VED-358-github-actions-for-int |
| 6 | + |
| 7 | +jobs: |
| 8 | + e2e-tests: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + permissions: |
| 11 | + id-token: write |
| 12 | + contents: read |
| 13 | + steps: |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - uses: aws-actions/configure-aws-credentials@v4 |
| 18 | + with: |
| 19 | + aws-region: eu-west-2 |
| 20 | + role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops |
| 21 | + role-session-name: github-actions |
| 22 | + |
| 23 | + - name: Whoami |
| 24 | + run: aws sts get-caller-identity |
| 25 | + |
| 26 | + - uses: hashicorp/setup-terraform@v3 |
| 27 | + with: |
| 28 | + terraform_version: "1.12.2" |
| 29 | + |
| 30 | + - name: Terraform Init |
| 31 | + working-directory: ${{ vars.TERRAFORM_DIR_PATH }} |
| 32 | + run: | |
| 33 | + export ENVIRONMENT=internal-dev |
| 34 | + export SUB_ENVIRONMENT=dev |
| 35 | + make init |
| 36 | +
|
| 37 | + - name: Set up Python |
| 38 | + uses: actions/setup-python@v5 |
| 39 | + with: |
| 40 | + python-version: "3.11" |
| 41 | + |
| 42 | + - name: Install Poetry |
| 43 | + run: | |
| 44 | + curl -sSL https://install.python-poetry.org | python3 - |
| 45 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 46 | +
|
| 47 | + - name: Set Poetry to use Python 3.11 |
| 48 | + working-directory: ${{ vars.E2E_DIR_PATH }} |
| 49 | + run: | |
| 50 | + poetry env use $(which python3.11) |
| 51 | +
|
| 52 | + - name: Install dependencies with Poetry |
| 53 | + working-directory: ${{ vars.E2E_DIR_PATH }} |
| 54 | + run: | |
| 55 | + poetry install --no-root |
| 56 | +
|
| 57 | + - name: Install oathtool |
| 58 | + run: sudo apt-get update && sudo apt-get install -y oathtool |
| 59 | + |
| 60 | + - name: Get JWT token for apigee |
| 61 | + env: |
| 62 | + APIGEE_USERNAME: ${{ vars.APIGEE_USERNAME }} |
| 63 | + APIGEE_PASSWORD: ${{ secrets.APIGEE_PASSWORD }} |
| 64 | + MFA_CODE: ${{ env.MFA_CODE }} |
| 65 | + APIGEE_OAUTH_TOKEN: ${{ secrets.APIGEE_OAUTH_TOKEN }} |
| 66 | + OTP_SECRET: ${{ secrets.APIGEE_OTP_KEY }} |
| 67 | + run: | |
| 68 | + CODE=$(oathtool --totp -b "$OTP_SECRET") |
| 69 | + echo "::add-mask::$CODE" |
| 70 | +
|
| 71 | + echo "Requesting access token from Apigee..." |
| 72 | +
|
| 73 | + response=$(curl -s -X POST "https://login.apigee.com/oauth/token" \ |
| 74 | + -H "Content-Type: application/x-www-form-urlencoded" \ |
| 75 | + -H "Accept: application/json;charset=utf-8" \ |
| 76 | + -H "Authorization: Basic $APIGEE_OAUTH_TOKEN" \ |
| 77 | + -d "username=$APIGEE_USERNAME&password=$APIGEE_PASSWORD&mfa_token=$CODE&grant_type=password") |
| 78 | +
|
| 79 | + token=$(echo "$response" | jq -r '.access_token // empty') |
| 80 | +
|
| 81 | + if [[ -z "$token" ]]; then |
| 82 | + echo "Failed to retrieve access token" |
| 83 | + exit 1 |
| 84 | + fi |
| 85 | +
|
| 86 | + echo "::add-mask::$token" |
| 87 | + echo "APIGEE_ACCESS_TOKEN=$token" >> $GITHUB_ENV |
| 88 | +
|
| 89 | + - name: Run e2e tests |
| 90 | + working-directory: ${{ vars.E2E_DIR_PATH }} |
| 91 | + env: |
| 92 | + APIGEE_ACCESS_TOKEN: ${{ env.APIGEE_ACCESS_TOKEN }} |
| 93 | + run: | |
| 94 | + export APIGEE_ENVIRONMENT=internal-dev |
| 95 | + export PROXY_NAME=immunisation-fhir-api-internal-dev |
| 96 | + export SERVICE_BASE_PATH=immunisation-fhir-api/FHIR/R4 |
| 97 | +
|
| 98 | + make run-immunization |
0 commit comments