Skip to content

Commit

Permalink
Fix usage of input variable in workflows (#703)
Browse files Browse the repository at this point in the history
* remove unncessary build output

* Fix region in app signal e2e workflow

* Fix incorrect usage of env var

* fix nightly build wf also
  • Loading branch information
bryan-aguilar authored Jan 9, 2024
1 parent 2f29ec1 commit 41f4c50
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 44 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/appsignals-e2e-ec2-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ permissions:
contents: read

env:
AWS_DEFAULT_REGION: ${{ inputs.aws-region }} # Used by terraform and AWS CLI commands
TEST_ACCOUNT: ${{ secrets.APP_SIGNALS_E2E_TEST_ACC }}
SAMPLE_APP_FRONTEND_SERVICE_JAR: "s3://aws-appsignals-sample-app/main-service.jar"
SAMPLE_APP_REMOTE_SERVICE_JAR: "s3://aws-appsignals-sample-app/remote-service.jar"
Expand All @@ -40,10 +39,10 @@ jobs:

- name: Set CW Agent RPM environment variable
run: |
if [ ${{ env.AWS_DEFAULT_REGION }} == "us-east-1" ]; then
if [ ${{ inputs.aws-region }} == "us-east-1" ]; then
echo APP_SIGNALS_CW_AGENT_RPM="https://amazoncloudwatch-agent-us-east-1.s3.amazonaws.com/amazon_linux/amd64/1.300031.0b313/amazon-cloudwatch-agent.rpm" >> $GITHUB_ENV
else
echo APP_SIGNALS_CW_AGENT_RPM="https://amazoncloudwatch-agent-${{ env.AWS_DEFAULT_REGION }}.s3.${{ env.AWS_DEFAULT_REGION }}.amazonaws.com/amazon_linux/amd64/1.300031.0b313/amazon-cloudwatch-agent.rpm" >> $GITHUB_ENV
echo APP_SIGNALS_CW_AGENT_RPM="https://amazoncloudwatch-agent-${{ inputs.aws-region }}.s3.${{ inputs.aws-region }}.amazonaws.com/amazon_linux/amd64/1.300031.0b313/amazon-cloudwatch-agent.rpm" >> $GITHUB_ENV
fi
Expand All @@ -54,7 +53,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.E2E_TEST_ROLE_ARN }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
aws-region: ${{ inputs.aws-region }}

- name: Set up terraform
uses: hashicorp/setup-terraform@v3
Expand All @@ -77,7 +76,7 @@ jobs:
echo "Attempt $retry_counter"
deployment_failed=0
terraform apply -auto-approve \
-var="aws_region=${{ env.AWS_DEFAULT_REGION }}" \
-var="aws_region=${{ inputs.aws-region }}" \
-var="test_id=${{ env.TESTING_ID }}" \
-var="sample_app_jar=${{ env.SAMPLE_APP_FRONTEND_SERVICE_JAR }}" \
-var="sample_remote_app_jar=${{ env.SAMPLE_APP_REMOTE_SERVICE_JAR }}" \
Expand Down Expand Up @@ -171,7 +170,7 @@ jobs:
--testing-id ${{ env.TESTING_ID }}
--endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }}
--remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8080
--region ${{ env.AWS_DEFAULT_REGION }}
--region ${{ inputs.aws-region }}
--account-id ${{ env.TEST_ACCOUNT }}
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
Expand All @@ -188,7 +187,7 @@ jobs:
--testing-id ${{ env.TESTING_ID }}
--endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }}
--remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8080
--region ${{ env.AWS_DEFAULT_REGION }}
--region ${{ inputs.aws-region }}
--account-id ${{ env.TEST_ACCOUNT }}
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
Expand All @@ -205,7 +204,7 @@ jobs:
--testing-id ${{ env.TESTING_ID }}
--endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }}
--remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8080
--region ${{ env.AWS_DEFAULT_REGION }}
--region ${{ inputs.aws-region }}
--account-id ${{ env.TEST_ACCOUNT }}
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
Expand All @@ -223,13 +222,13 @@ jobs:
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ inputs.caller-workflow-name }} \
--value 0.0 \
--region ${{ env.AWS_DEFAULT_REGION }}
--region ${{ inputs.aws-region }}
else
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ inputs.caller-workflow-name }} \
--value 1.0 \
--region ${{ env.AWS_DEFAULT_REGION }}
--region ${{ inputs.aws-region }}
fi
Expand Down
35 changes: 17 additions & 18 deletions .github/workflows/appsignals-e2e-eks-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ permissions:
contents: read

env:
AWS_DEFAULT_REGION: ${{ inputs.aws-region }} # Used by terraform and AWS CLI commands
TEST_ACCOUNT: ${{ secrets.APP_SIGNALS_E2E_TEST_ACC }}
ENABLEMENT_SCRIPT_S3_BUCKET: ${{ secrets.APP_SIGNALS_E2E_ENABLEMENT_SCRIPT }}
SAMPLE_APP_NAMESPACE: sample-app-namespace
Expand All @@ -46,13 +45,13 @@ jobs:
distribution: temurin

- name: Generate testing id
run: echo TESTING_ID="${{ env.AWS_DEFAULT_REGION }}-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV
run: echo TESTING_ID="${{ inputs.aws-region }}-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.E2E_TEST_ROLE_ARN }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
aws-region: ${{ inputs.aws-region }}

# local directory to store the kubernetes config
- name: Create kubeconfig directory
Expand All @@ -62,7 +61,7 @@ jobs:
run: echo KUBECONFIG="${{ github.workspace }}/.kube/config" >> $GITHUB_ENV

- name: Set up kubeconfig
run: aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ env.AWS_DEFAULT_REGION }}
run: aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ inputs.aws-region }}

- name: Install eksctl
run: |
Expand All @@ -80,7 +79,7 @@ jobs:
--cluster ${{ inputs.test-cluster-name }} \
--role-name eks-s3-access-${{ env.TESTING_ID }} \
--attach-policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess \
--region ${{ env.AWS_DEFAULT_REGION }} \
--region ${{ inputs.aws-region }} \
--approve
- name: Set up terraform
Expand Down Expand Up @@ -118,7 +117,7 @@ jobs:
deployment_failed=0
terraform apply -auto-approve \
-var="test_id=${{ env.TESTING_ID }}" \
-var="aws_region=${{ env.AWS_DEFAULT_REGION }}" \
-var="aws_region=${{ inputs.aws-region }}" \
-var="kube_directory_path=${{ github.workspace }}/.kube" \
-var="eks_cluster_name=${{ inputs.test-cluster-name }}" \
-var="eks_cluster_context_name=$(kubectl config current-context)" \
Expand All @@ -138,7 +137,7 @@ jobs:
echo "Installing app signals to the sample app"
./enable-app-signals.sh \
${{ inputs.test-cluster-name }} \
${{ env.AWS_DEFAULT_REGION }} \
${{ inputs.aws-region }} \
${{ env.SAMPLE_APP_NAMESPACE }}
# If the workflow provides a specific ADOT image to test, patch the deployment and restart CW agent related pods
Expand Down Expand Up @@ -176,16 +175,16 @@ jobs:
echo "Cleaning up App Signal"
./clean-app-signals.sh \
${{ inputs.test-cluster-name }} \
${{ env.AWS_DEFAULT_REGION }} \
${{ inputs.aws-region }} \
${{ env.SAMPLE_APP_NAMESPACE }}
# Running clean-app-signal.sh removes the current cluster from the config. Update the cluster again for subsequent runs.
aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ env.AWS_DEFAULT_REGION }}
aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ inputs.aws-region }}
echo "Destroying terraform"
terraform destroy -auto-approve \
-var="test_id=${{ env.TESTING_ID }}" \
-var="aws_region=${{ env.AWS_DEFAULT_REGION }}" \
-var="aws_region=${{ inputs.aws-region }}" \
-var="kube_directory_path=${{ github.workspace }}/.kube" \
-var="eks_cluster_name=${{ inputs.test-cluster-name }}" \
-var="test_namespace=${{ env.SAMPLE_APP_NAMESPACE }}" \
Expand Down Expand Up @@ -255,7 +254,7 @@ jobs:
run: ./gradlew testing:validator:run --args='-c eks/log-validation.yml
--testing-id ${{ env.TESTING_ID }}
--endpoint http://${{ env.APP_ENDPOINT }}
--region ${{ env.AWS_DEFAULT_REGION }}
--region ${{ inputs.aws-region }}
--account-id ${{ env.TEST_ACCOUNT }}
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
Expand All @@ -272,7 +271,7 @@ jobs:
run: ./gradlew testing:validator:run --args='-c eks/metric-validation.yml
--testing-id ${{ env.TESTING_ID }}
--endpoint http://${{ env.APP_ENDPOINT }}
--region ${{ env.AWS_DEFAULT_REGION }}
--region ${{ inputs.aws-region }}
--account-id ${{ env.TEST_ACCOUNT }}
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
Expand All @@ -290,7 +289,7 @@ jobs:
run: ./gradlew testing:validator:run --args='-c eks/trace-validation.yml
--testing-id ${{ env.TESTING_ID }}
--endpoint http://${{ env.APP_ENDPOINT }}
--region ${{ env.AWS_DEFAULT_REGION }}
--region ${{ inputs.aws-region }}
--account-id ${{ env.TEST_ACCOUNT }}
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
Expand All @@ -309,13 +308,13 @@ jobs:
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ inputs.caller-workflow-name }} \
--value 0.0 \
--region ${{ env.AWS_DEFAULT_REGION }}
--region ${{ inputs.aws-region }}
else
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ inputs.caller-workflow-name }} \
--value 1.0 \
--region ${{ env.AWS_DEFAULT_REGION }}
--region ${{ inputs.aws-region }}
fi
# Clean up Procedures
Expand All @@ -327,7 +326,7 @@ jobs:
run: |
./clean-app-signals.sh \
${{ inputs.test-cluster-name }} \
${{ env.AWS_DEFAULT_REGION }} \
${{ inputs.aws-region }} \
${{ env.SAMPLE_APP_NAMESPACE }}
# This step also deletes lingering resources from previous test runs
Expand All @@ -344,7 +343,7 @@ jobs:
run: |
terraform destroy -auto-approve \
-var="test_id=${{ env.TESTING_ID }}" \
-var="aws_region=${{ env.AWS_DEFAULT_REGION }}" \
-var="aws_region=${{ inputs.aws-region }}" \
-var="kube_directory_path=${{ github.workspace }}/.kube" \
-var="eks_cluster_name=${{ inputs.test-cluster-name }}" \
-var="test_namespace=${{ env.SAMPLE_APP_NAMESPACE }}" \
Expand All @@ -359,4 +358,4 @@ jobs:
--name service-account-${{ env.TESTING_ID }} \
--namespace ${{ env.SAMPLE_APP_NAMESPACE }} \
--cluster ${{ inputs.test-cluster-name }} \
--region ${{ env.AWS_DEFAULT_REGION }}
--region ${{ inputs.aws-region }}
11 changes: 4 additions & 7 deletions .github/workflows/e2e-tests-app-with-java-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ on:
required: true
type: string

env:
AWS_DEFAULT_REGION: ${{ inputs.aws-region }}

permissions:
id-token: write
contents: read
Expand Down Expand Up @@ -56,7 +53,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
aws-region: ${{ inputs.aws-region }}

- name: Log in to AWS ECR
uses: docker/login-action@v3
Expand Down Expand Up @@ -88,7 +85,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
aws-region: ${{ inputs.aws-region }}
- name: Log in to AWS ECR
uses: docker/login-action@v3
with:
Expand Down Expand Up @@ -119,7 +116,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
aws-region: ${{ inputs.aws-region }}
- name: Log in to AWS ECR
uses: docker/login-action@v3
with:
Expand Down Expand Up @@ -150,7 +147,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
aws-region: ${{ inputs.aws-region }}
- name: Log in to AWS ECR
uses: docker/login-action@v3
with:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/e2e-tests-with-operator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ on:
type: string

env:
AWS_DEFAULT_REGION: ${{ inputs.aws-region }}
TESTING_FRAMEWORK_REPO: aws-observability/aws-otel-test-framework
NUM_BATCHES: 2
DDB_TABLE_NAME: BatchTestCache
Expand Down Expand Up @@ -62,7 +61,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
aws-region: ${{ inputs.aws-region }}

- name: Log in to AWS ECR
uses: docker/login-action@v3
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ jobs:
staging-image: ${{ steps.imageOutput.outputs.stagingImage }}
staging_registry: ${{ steps.imageOutput.outputs.stagingRegistry }}
staging_repository: ${{ steps.imageOutput.outputs.stagingRepository }}
aws_default_region: ${{ env.AWS_DEFAULT_REGION }}
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -156,7 +155,7 @@ jobs:
uses: ./.github/workflows/e2e-tests-with-operator.yml
secrets: inherit
with:
aws-region: ${{ needs.build.outputs.aws_default_region }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
image_tag: ${{ needs.build.outputs.java_agent_tag }}
image_uri: ${{ needs.build.outputs.staging_registry }}/${{ needs.build.outputs.staging_repository }}
test_ref: ${{ needs.create-test-ref.outputs.testRef }}
Expand All @@ -168,7 +167,7 @@ jobs:
uses: ./.github/workflows/e2e-tests-app-with-java-agent.yml
secrets: inherit
with:
aws-region: ${{ needs.build.outputs.aws_default_region }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
image_tag: ${{ github.sha }}
caller-workflow-name: 'main-build'

Expand Down Expand Up @@ -223,7 +222,7 @@ jobs:
uses: ./.github/workflows/appsignals-e2e-eks-test.yml
secrets: inherit
with:
aws-region: ${{ needs.build.outputs.aws_default_region }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
test-cluster-name: "e2e-adot-test"
appsignals-adot-image-name: ${{ needs.build.outputs.staging-image }}
caller-workflow-name: 'main-build'
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/nightly-upstream-snapshot-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
release-candidate-image: ${{ steps.imageOutput.outputs.rcImage }}
image_registry: ${{ steps.imageOutput.outputs.imageRegistry }}
image_name: ${{ steps.imageOutput.outputs.imageName }}
aws_default_region: ${{ env.AWS_DEFAULT_REGION }}
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -94,7 +93,7 @@ jobs:
uses: ./.github/workflows/e2e-tests-with-operator.yml
secrets: inherit
with:
aws-region: ${{ needs.build.outputs.aws_default_region }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
image_tag: ${{ needs.build.outputs.time_stamp_tag }}
image_uri: ${{ needs.build.outputs.image_registry }}/${{ needs.build.outputs.image_name }}
test_ref: 'terraform'
Expand Down Expand Up @@ -142,7 +141,7 @@ jobs:
uses: ./.github/workflows/appsignals-e2e-eks-test.yml
secrets: inherit
with:
aws-region: ${{ needs.build.outputs.aws_default_region }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
test-cluster-name: "e2e-adot-test"
appsignals-adot-image-name: ${{ needs.build.outputs.release-candidate-image }}
caller-workflow-name: 'nightly-upstream-snapshot-build'
Expand Down

0 comments on commit 41f4c50

Please sign in to comment.