From 2061aae36f50c3b6ecd251cfcc2431839ef3c3a1 Mon Sep 17 00:00:00 2001 From: Artur Tagisow Date: Wed, 20 Jul 2022 10:17:18 +0200 Subject: [PATCH] ci: unify environment-related env vars update k6 action to select environments instead of urls, because with K6 we'll probably need 3 separate urls (middleware, frontend app and graphql endpoint) which would be painful to type in manually now you just input the env name and it selects the 3 urls on its own M2-1033 ci: update k6 script with new variables ci: update envs with new naming convention --- .../workflows/deploy-vue-storefront-cloud.yml | 34 ++++++++----------- .github/workflows/public_env_info/canary | 5 +++ .github/workflows/public_env_info/dev | 5 +++ .github/workflows/public_env_info/enterprise | 5 +++ .github/workflows/public_env_info/production | 5 +++ .github/workflows/run-k6-load-test.yml | 16 ++++----- 6 files changed, 42 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/public_env_info/canary create mode 100644 .github/workflows/public_env_info/dev create mode 100644 .github/workflows/public_env_info/enterprise create mode 100644 .github/workflows/public_env_info/production diff --git a/.github/workflows/deploy-vue-storefront-cloud.yml b/.github/workflows/deploy-vue-storefront-cloud.yml index fdd14e225..89cb59d49 100644 --- a/.github/workflows/deploy-vue-storefront-cloud.yml +++ b/.github/workflows/deploy-vue-storefront-cloud.yml @@ -17,47 +17,43 @@ jobs: deployment_id: ${{ steps.deployment.outputs.deployment_id }} steps: - name: Determine environment-specific variables - id: determine-environment shell: bash run: | REF=${{ github.ref }} if [ $REF = 'refs/heads/main' ]; then - ENVNAME='production' - ENVCODE='demo-magento2' - MIDDLEWARE_URL='https://demo-magento2.europe-west1.gcp.vuestorefront.cloud/api/' + ENVINFO_FILE=production elif [ $REF = 'refs/heads/develop' ]; then - ENVNAME='dev' - ENVCODE='demo-magento2-dev' - MIDDLEWARE_URL='https://demo-magento2-dev.europe-west1.gcp.storefrontcloud.io/api/' + ENVINFO_FILE=dev elif [[ $REF = refs/heads/release* ]]; then - ENVNAME='canary' - ENVCODE='demo-magento2-canary' - MIDDLEWARE_URL='https://demo-magento2-canary.europe-west1.gcp.storefrontcloud.io/api/' + ENVINFO_FILE=canary elif [ $REF = 'refs/heads/enterprise' ]; then - ENVNAME='enterprise' - ENVCODE='demo-magento2-enterprise' - MIDDLEWARE_URL='https://demo-magento2-enterprise.europe-west1.gcp.storefrontcloud.io/api/' + ENVINFO_FILE=enterprise else - echo 'unrecognized branch name' - exit 1 + echo 'unrecognized branch name' + exit 1 fi - echo ::set-output name=name::$ENVNAME - echo ::set-output name=code::$ENVCODE - echo ::set-output name=middleware-url::$MIDDLEWARE_URL + cat .github/workflows/public_env_info/$ENVINFO_FILE >> $GITHUB_ENV + + - id: determine-environment + run: | + echo ::set-output name=name::${{ env.ENVNAME }} + echo ::set-output name=code::${{ env.ENVCODE }} + echo ::set-output name=middleware-url::${{ env.MIDDLEWARE_URL }} - name: Create GitHub deployment id: deployment uses: chrnorm/deployment-action@v2 with: token: ${{ secrets.DEPLOYMENT_PERSONAL_ACCESS_TOKEN }} - environment: ${{ steps.determine-environment.outputs.name }} + environment: ${{ env.ENVNAME }} initial-status: in_progress + build: needs: create-deployment runs-on: ubuntu-latest diff --git a/.github/workflows/public_env_info/canary b/.github/workflows/public_env_info/canary new file mode 100644 index 000000000..fddb3b3d7 --- /dev/null +++ b/.github/workflows/public_env_info/canary @@ -0,0 +1,5 @@ +ENVNAME=canary +ENVCODE=demo-magento2-canary +BASE_URL=https://demo-magento2-canary.europe-west1.gcp.storefrontcloud.io +MIDDLEWARE_URL=https://demo-magento2-canary.europe-west1.gcp.storefrontcloud.io/api +MAGENTO_GRAPHQL_URL=https://magento2-instance.vuestorefront.io:8443/graphql diff --git a/.github/workflows/public_env_info/dev b/.github/workflows/public_env_info/dev new file mode 100644 index 000000000..e3aec0cb5 --- /dev/null +++ b/.github/workflows/public_env_info/dev @@ -0,0 +1,5 @@ +ENVNAME=dev +ENVCODE=demo-magento2-dev +BASE_URL=https://demo-magento2-dev.europe-west1.gcp.storefrontcloud.io +MIDDLEWARE_URL=https://demo-magento2-dev.europe-west1.gcp.storefrontcloud.io/api +MAGENTO_GRAPHQL_URL=https://magento2-instance.vuestorefront.io:8443/graphql diff --git a/.github/workflows/public_env_info/enterprise b/.github/workflows/public_env_info/enterprise new file mode 100644 index 000000000..4d7efada1 --- /dev/null +++ b/.github/workflows/public_env_info/enterprise @@ -0,0 +1,5 @@ +ENVNAME=enterprise +ENVCODE=demo-magento2-enterprise +BASE_URL=https://demo-magento2-enterprise.europe-west1.gcp.storefrontcloud.io +MIDDLEWARE_URL=https://demo-magento2-enterprise.europe-west1.gcp.storefrontcloud.io/api +MAGENTO_GRAPHQL_URL=https://magento2-instance.vuestorefront.io:8443/graphql diff --git a/.github/workflows/public_env_info/production b/.github/workflows/public_env_info/production new file mode 100644 index 000000000..d9696b5f6 --- /dev/null +++ b/.github/workflows/public_env_info/production @@ -0,0 +1,5 @@ +ENVNAME=production +ENVCODE=demo-magento2 +BASE_URL=https://demo-magento2.europe-west1.gcp.vuestorefront.cloud +MIDDLEWARE_URL=https://demo-magento2.europe-west1.gcp.vuestorefront.cloud/api +MAGENTO_GRAPHQL_URL=https://magento2-instance.vuestorefront.io:8443/graphql diff --git a/.github/workflows/run-k6-load-test.yml b/.github/workflows/run-k6-load-test.yml index 19388bf31..44e8501f0 100644 --- a/.github/workflows/run-k6-load-test.yml +++ b/.github/workflows/run-k6-load-test.yml @@ -17,13 +17,8 @@ on: environment: description: The full URL of the environment on which load tests will be ran required: true - default: 'https://demo-magento2-canary.europe-west1.gcp.storefrontcloud.io' - type: choice - options: - - 'https://demo-magento2-canary.europe-west1.gcp.storefrontcloud.io' - - 'https://demo-magento2-dev.europe-west1.gcp.storefrontcloud.io' - - 'https://demo-magento2.europe-west1.gcp.storefrontcloud.cloud' - - 'https://demo-magento2-enterprise.europe-west1.gcp.storefrontcloud.io' + default: canary + type: environment flags: description: Additional argument and flags to provide to the k6 CLI. See https://k6.io/docs/using-k6/options for details. @@ -40,10 +35,13 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Run k6 cloud test + - run: | + cat .github/workflows/public_env_info/${{ inputs.environment }} >> $GITHUB_ENV + + - name: Run k6 test uses: grafana/k6-action@v0.2.0 with: cloud: ${{ github.event.inputs.cloud }} token: ${{ secrets.K6_CLOUD_API_TOKEN }} filename: ${{ github.event.inputs.filename }} - flags: -e BASE_URL=${{ github.event.inputs.environment }} ${{ github.event.inputs.flags }} + flags: -e BASE_URL=${{ env.BASE_URL }} -e MIDDLEWARE_URL=${{ env.MIDDLEWARE_URL }} -e MAGENTO_GRAPHQL_URL=${{ env.MAGENTO_GRAPHQL_URL }} ${{ github.event.inputs.flags }}