Skip to content

Commit d50202e

Browse files
committed
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
1 parent aa23604 commit d50202e

File tree

6 files changed

+42
-28
lines changed

6 files changed

+42
-28
lines changed

.github/workflows/deploy-vue-storefront-cloud.yml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,43 @@ jobs:
1717
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
1818
steps:
1919
- name: Determine environment-specific variables
20-
id: determine-environment
2120
shell: bash
2221
run: |
2322
REF=${{ github.ref }}
2423
2524
if [ $REF = 'refs/heads/main' ]; then
26-
ENVNAME='production'
27-
ENVCODE='demo-magento2'
28-
MIDDLEWARE_URL='https://demo-magento2.europe-west1.gcp.vuestorefront.cloud/api/'
25+
ENVINFO_FILE=production
2926
3027
elif [ $REF = 'refs/heads/develop' ]; then
31-
ENVNAME='dev'
32-
ENVCODE='demo-magento2-dev'
33-
MIDDLEWARE_URL='https://demo-magento2-dev.europe-west1.gcp.storefrontcloud.io/api/'
28+
ENVINFO_FILE=dev
3429
3530
elif [[ $REF = refs/heads/release* ]]; then
36-
ENVNAME='canary'
37-
ENVCODE='demo-magento2-canary'
38-
MIDDLEWARE_URL='https://demo-magento2-canary.europe-west1.gcp.storefrontcloud.io/api/'
31+
ENVINFO_FILE=canary
3932
4033
elif [ $REF = 'refs/heads/enterprise' ]; then
41-
ENVNAME='enterprise'
42-
ENVCODE='demo-magento2-enterprise'
43-
MIDDLEWARE_URL='https://demo-magento2-enterprise.europe-west1.gcp.storefrontcloud.io/api/'
34+
ENVINFO_FILE=enterprise
4435
4536
else
46-
echo 'unrecognized branch name'
47-
exit 1
37+
echo 'unrecognized branch name'
38+
exit 1
4839
fi
4940
50-
echo ::set-output name=name::$ENVNAME
51-
echo ::set-output name=code::$ENVCODE
52-
echo ::set-output name=middleware-url::$MIDDLEWARE_URL
41+
cat .github/workflows/public_env_info/$ENVINFO_FILE >> $GITHUB_ENV
42+
43+
- id: determine-environment
44+
run: |
45+
echo ::set-output name=name::${{ env.ENVNAME }}
46+
echo ::set-output name=code::${{ env.ENVCODE }}
47+
echo ::set-output name=middleware-url::${{ env.MIDDLEWARE_URL }}
5348
5449
- name: Create GitHub deployment
5550
id: deployment
5651
uses: chrnorm/deployment-action@v2
5752
with:
5853
token: ${{ secrets.DEPLOYMENT_PERSONAL_ACCESS_TOKEN }}
59-
environment: ${{ steps.determine-environment.outputs.name }}
54+
environment: ${{ env.ENVNAME }}
6055
initial-status: in_progress
56+
6157
build:
6258
needs: create-deployment
6359
runs-on: ubuntu-latest
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ENVNAME=canary
2+
ENVCODE=demo-magento2-canary
3+
BASE_URL=https://demo-magento2-canary.europe-west1.gcp.storefrontcloud.io
4+
MIDDLEWARE_URL=https://demo-magento2-canary.europe-west1.gcp.storefrontcloud.io/api
5+
MAGENTO_GRAPHQL_URL=https://magento2-instance.vuestorefront.io:8443/graphql
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ENVNAME=dev
2+
ENVCODE=demo-magento2-dev
3+
BASE_URL=https://demo-magento2-dev.europe-west1.gcp.storefrontcloud.io
4+
MIDDLEWARE_URL=https://demo-magento2-dev.europe-west1.gcp.storefrontcloud.io/api
5+
MAGENTO_GRAPHQL_URL=https://magento2-dev-instance.vuestorefront.io:8443/graphql
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ENVNAME=enterprise
2+
ENVCODE=demo-magento2-enterprise
3+
BASE_URL=https://demo-magento2-enterprise.europe-west1.gcp.storefrontcloud.io
4+
MIDDLEWARE_URL=https://demo-magento2-enterprise.europe-west1.gcp.storefrontcloud.io/api
5+
MAGENTO_GRAPHQL_URL=https://magento2-instance.vuestorefront.io:8443/graphql
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ENVNAME=production
2+
ENVCODE=demo-magento2
3+
BASE_URL=https://demo-magento2.europe-west1.gcp.vuestorefront.cloud
4+
MIDDLEWARE_URL=https://demo-magento2.europe-west1.gcp.vuestorefront.cloud/api
5+
MAGENTO_GRAPHQL_URL=https://magento2-instance.vuestorefront.io:8443/graphql

.github/workflows/run-k6-load-test.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,8 @@ on:
1717
environment:
1818
description: The full URL of the environment on which load tests will be ran
1919
required: true
20-
default: 'https://demo-magento2-canary.europe-west1.gcp.storefrontcloud.io'
21-
type: choice
22-
options:
23-
- 'https://demo-magento2-canary.europe-west1.gcp.storefrontcloud.io'
24-
- 'https://demo-magento2-dev.europe-west1.gcp.storefrontcloud.io'
25-
- 'https://demo-magento2.europe-west1.gcp.storefrontcloud.cloud'
26-
- 'https://demo-magento2-enterprise.europe-west1.gcp.storefrontcloud.io'
20+
default: canary
21+
type: environment
2722

2823
flags:
2924
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:
4035
- name: Checkout
4136
uses: actions/checkout@v3
4237

43-
- name: Run k6 cloud test
38+
- run: |
39+
cat .github/workflows/public_env_info/${{ inputs.environment }} >> $GITHUB_ENV
40+
41+
- name: Run k6 test
4442
uses: grafana/[email protected]
4543
with:
4644
cloud: ${{ github.event.inputs.cloud }}
4745
token: ${{ secrets.K6_CLOUD_API_TOKEN }}
4846
filename: ${{ github.event.inputs.filename }}
49-
flags: -e BASE_URL=${{ github.event.inputs.environment }} ${{ github.event.inputs.flags }}
47+
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 }}

0 commit comments

Comments
 (0)