Skip to content

Commit 5a93b93

Browse files
sethiddenFrodigo
authored andcommitted
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 00ee2c2 commit 5a93b93

File tree

6 files changed

+43
-29
lines changed

6 files changed

+43
-29
lines changed

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

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,43 @@ jobs:
2121
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
2222
steps:
2323
- name: Determine environment-specific variables
24-
id: determine-environment
2524
shell: bash
2625
run: |
2726
REF=${{ github.ref }}
2827
2928
if [ $REF = 'refs/heads/main' ]; then
30-
ENVNAME='production'
31-
ENVCODE='demo-magento2'
32-
MIDDLEWARE_URL='https://demo-magento2.europe-west1.gcp.vuestorefront.cloud/api/'
29+
ENVINFO_FILE=production
3330
3431
elif [ $REF = 'refs/heads/develop' ]; then
35-
ENVNAME='dev'
36-
ENVCODE='demo-magento2-dev'
37-
MIDDLEWARE_URL='https://demo-magento2-dev.europe-west1.gcp.storefrontcloud.io/api/'
32+
ENVINFO_FILE=dev
3833
3934
elif [[ $REF = refs/heads/release* ]]; then
40-
ENVNAME='canary'
41-
ENVCODE='demo-magento2-canary'
42-
MIDDLEWARE_URL='https://magento2stage.vuestorefront.io/api/'
35+
ENVINFO_FILE=canary
4336
4437
elif [ $REF = 'refs/heads/enterprise' ]; then
45-
ENVNAME='enterprise'
46-
ENVCODE='demo-magento2-enterprise'
47-
MIDDLEWARE_URL='https://demo-magento2-enterprise.europe-west1.gcp.storefrontcloud.io/api/'
38+
ENVINFO_FILE=enterprise
4839
4940
else
50-
echo 'unrecognized branch name'
51-
exit 1
41+
echo 'unrecognized branch name'
42+
exit 1
5243
fi
5344
54-
echo ::set-output name=name::$ENVNAME
55-
echo ::set-output name=code::$ENVCODE
56-
echo ::set-output name=middleware-url::$MIDDLEWARE_URL
45+
cat .github/workflows/public_env_info/$ENVINFO_FILE >> $GITHUB_ENV
46+
47+
- id: determine-environment
48+
run: |
49+
echo ::set-output name=name::${{ env.ENVNAME }}
50+
echo ::set-output name=code::${{ env.ENVCODE }}
51+
echo ::set-output name=middleware-url::${{ env.MIDDLEWARE_URL }}
5752
5853
- name: Create GitHub deployment
5954
id: deployment
6055
uses: chrnorm/deployment-action@v2
6156
with:
62-
token: ${{ github.token }}
63-
environment: ${{ steps.determine-environment.outputs.name }}
57+
token: ${{ secrets.DEPLOYMENT_PERSONAL_ACCESS_TOKEN }}
58+
environment: ${{ env.ENVNAME }}
6459
initial-status: in_progress
60+
6561
build:
6662
needs: create-deployment
6763
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-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)