Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2e instance assign and create #4350

Merged
merged 78 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 73 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
f3a0fde
E2e pool
andrzejewsky Oct 18, 2023
c11f06d
E2e pool
andrzejewsky Oct 18, 2023
773c6ee
E2e pool
andrzejewsky Oct 18, 2023
2c9841c
E2e pool
andrzejewsky Oct 18, 2023
023e0d2
E2e pool
andrzejewsky Oct 18, 2023
6346dd5
E2e pool
andrzejewsky Oct 18, 2023
b8d139c
E2e pool
andrzejewsky Oct 18, 2023
3c1c8c2
E2e pool
andrzejewsky Oct 18, 2023
aba9202
E2e pool
andrzejewsky Oct 18, 2023
24eb4c4
E2e pool
andrzejewsky Oct 18, 2023
aef988d
E2e pool
andrzejewsky Oct 18, 2023
8ed7b6e
E2e pool
andrzejewsky Oct 18, 2023
782d3e0
E2e pool
andrzejewsky Oct 18, 2023
2f0f952
E2e pool
andrzejewsky Oct 18, 2023
32d4694
E2e pool
andrzejewsky Oct 18, 2023
6f0a6d9
E2E pool
andrzejewsky Oct 19, 2023
0a6d500
bump workers to 4 on CI
wojteknowacki Oct 19, 2023
9315910
run single test with logs
wojteknowacki Oct 19, 2023
a7f8f87
store artifacts
wojteknowacki Oct 19, 2023
596a405
baseurl in e2e-pool - removed postfix dashboard
wojteknowacki Oct 19, 2023
4554b09
baseurl in e2e-pool - added postfix dashboard
wojteknowacki Oct 19, 2023
5d99faa
baseurl in e2e-pool - slash removed on the end
wojteknowacki Oct 19, 2023
2b33ce2
Revert "baseurl in e2e-pool - slash removed on the end"
wojteknowacki Oct 19, 2023
fa3b9e3
matrix run on ci
wojteknowacki Oct 19, 2023
877172c
matrix indexes fix
wojteknowacki Oct 19, 2023
4aef17c
Deployment
andrzejewsky Oct 19, 2023
cb2bdb7
Deployment
andrzejewsky Oct 19, 2023
e8b0359
Deployment
andrzejewsky Oct 19, 2023
854cb58
Deployment
andrzejewsky Oct 19, 2023
86b205a
base url fix
wojteknowacki Oct 19, 2023
6cf09d5
auth login method - base url from env var
wojteknowacki Oct 19, 2023
c775143
Deployment
andrzejewsky Oct 19, 2023
299c9e6
fix path in directions urls
wojteknowacki Oct 20, 2023
ee87b30
Trrigger 1
andrzejewsky Oct 20, 2023
4e5493e
Trigger 2
andrzejewsky Oct 20, 2023
12ba436
Concurenc
andrzejewsky Oct 20, 2023
be3cfe9
Trigger
andrzejewsky Oct 20, 2023
6f51c47
Workflows
andrzejewsky Oct 20, 2023
c062fdf
Workflows
andrzejewsky Oct 20, 2023
fb1cea7
Workflows
andrzejewsky Oct 23, 2023
5eea706
Workflows
andrzejewsky Oct 23, 2023
4986843
Workflows
andrzejewsky Oct 23, 2023
4fe09d5
Workflows
andrzejewsky Oct 23, 2023
7ca8caf
Workflows
andrzejewsky Oct 23, 2023
9efd6ce
Workflows
andrzejewsky Oct 23, 2023
16d16b9
Workflows
andrzejewsky Oct 23, 2023
f5f1f0e
Workflows
andrzejewsky Oct 23, 2023
b8ab240
Workflows
andrzejewsky Oct 23, 2023
81dfb2a
Merge branch 'main' into e2e-pool
andrzejewsky Oct 31, 2023
35994b8
Instances
andrzejewsky Oct 31, 2023
399cee0
trigger
andrzejewsky Oct 31, 2023
f395ed0
Instances
andrzejewsky Oct 31, 2023
525e90b
Instances
andrzejewsky Oct 31, 2023
ee46b37
Instances
andrzejewsky Oct 31, 2023
07b28ce
Instances
andrzejewsky Oct 31, 2023
f4711d6
Instances
andrzejewsky Oct 31, 2023
0ab869e
trigger
andrzejewsky Oct 31, 2023
6a5f84f
Separate storybook
andrzejewsky Oct 31, 2023
213e084
Backup list
andrzejewsky Nov 7, 2023
75779e0
Backup list
andrzejewsky Nov 7, 2023
3a83591
Annotations
andrzejewsky Nov 7, 2023
e244903
Annotations
andrzejewsky Nov 7, 2023
7f5dd7f
Annotations
andrzejewsky Nov 7, 2023
92e4130
Annotations
andrzejewsky Nov 7, 2023
d93b9a5
Annotations
andrzejewsky Nov 7, 2023
ad4b7e7
Annotations
andrzejewsky Nov 7, 2023
33db992
Annotations
andrzejewsky Nov 7, 2023
3070366
Merge remote-tracking branch 'origin/main' into e2e-pool
andrzejewsky Nov 7, 2023
e87f071
Changeset
andrzejewsky Nov 7, 2023
6ab9620
Annotations
andrzejewsky Nov 7, 2023
016f50c
Annotations
andrzejewsky Nov 7, 2023
6546116
Annotations
andrzejewsky Nov 7, 2023
2b215f0
instances
andrzejewsky Nov 8, 2023
3b6576a
Cr
andrzejewsky Nov 9, 2023
80d665d
Limit permissions
andrzejewsky Nov 9, 2023
fb78364
Merge branch 'main' into e2e-pool
andrzejewsky Nov 9, 2023
c4ede1f
Naming
andrzejewsky Nov 10, 2023
bb9d906
Merge branch 'main' into e2e-pool
andrzejewsky Nov 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/healthy-walls-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": minor
---

Implement the e2e instance managing
15 changes: 15 additions & 0 deletions .github/actions/cli-login/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Saleor CLI login
description: Saleor CLI login
inputs:
token:
description: "Cloud accces token"
required: true
runs:
using: "composite"
steps:
- name: Write config file
shell: bash
id: write-config-file
env:
ACCESS_TOKEN: ${{ inputs.token }}
run: jq --null-input --arg token "Token $ACCESS_TOKEN" '{"token":$token,"telemetry":"false","organization_slug":"saleor","organization_name":"Saleor"}' > ~/.config/saleor.json
302 changes: 302 additions & 0 deletions .github/workflows/e2e-instances.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,302 @@
name: Testing

on: [pull_request]

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
prepare_variables:
runs-on: ubuntu-22.04
outputs:
POOL_NAME: ${{ steps.generate.outputs.POOL_NAME }}
POOL_INSTANCE: ${{ steps.generate.outputs.POOL_INSTANCE }}
BASE_URL: ${{ steps.generate.outputs.BASE_URL }}
API_URI: ${{ steps.generate.outputs.API_URI }}
BACKUP_ID: ${{ steps.backup.outputs.BACKUP_ID }}
BACKUP_VER: ${{ steps.backup.outputs.BACKUP_VER }}
BACKUP_NAME: ${{ steps.backup.outputs.BACKUP_NAME }}

steps:
- uses: actions/checkout@v4
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved

- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved

- name: Generate
id: generate
run: |
echo "BASE_URL=${{ env.GITHUB_HEAD_REF_SLUG_URL }}.dashboard.saleor.rocks" >> $GITHUB_OUTPUT
echo "API_URI=https://${{ env.GITHUB_HEAD_REF_SLUG_URL }}.staging.saleor.cloud/graphql/" >> $GITHUB_OUTPUT
echo "POOL_NAME=${{ env.GITHUB_HEAD_REF_SLUG_URL }}" >> $GITHUB_OUTPUT
echo "POOL_INSTANCE=https://${{ env.GITHUB_HEAD_REF_SLUG_URL }}.staging.saleor.cloud" >> $GITHUB_OUTPUT
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved

- name: Saleor login
uses: ./.github/actions/cli-login
with:
token: ${{ secrets.STAGING_TOKEN }}

- name: Obtain backup id
id: backup
env:
SALEOR_CLI_ENV: staging
BACKUP_NAME: snapshot-automation-tests
run: |
BACKUPS=$(npx saleor backup list --name=snapshot-automation-tests --latest --json)
BACKUP_ID=$(echo $BACKUPS | jq -r '.[0].key')
BACKUP_VER=$(echo $BACKUPS | jq -r '.[0].saleor_version')
BACKUP_NAME=$(echo $BACKUPS | jq -r '.[0].name')
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved

echo "BACKUP_ID=$BACKUP_ID" >> $GITHUB_OUTPUT
echo "BACKUP_VER=$BACKUP_VER" >> $GITHUB_OUTPUT
echo "BACKUP_NAME=$BACKUP_NAME" >> $GITHUB_OUTPUT

- name: Print annotations
run: |
echo "::notice title=BASE_URL::${{ steps.generate.outputs.BASE_URL }}"
echo "::notice title=API_URI::${{ steps.generate.outputs.API_URI }}"
echo "::notice title=POOL_NAME::${{ steps.generate.outputs.POOL_NAME }}"
echo "::notice title=POOL_INSTANCE::${{ steps.generate.outputs.POOL_INSTANCE }}"
echo "::notice title=SNAPSHOT::backup_id=${{ steps.backup.outputs.BACKUP_ID }}, version=${{ steps.backup.outputs.BACKUP_VER }}, name=${{ steps.backup.outputs.BACKUP_NAME }}"
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved

prepare_instance:
runs-on: ubuntu-22.04
needs: prepare_variables
steps:
- uses: actions/checkout@v4
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved

- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved

- name: Saleor login
uses: ./.github/actions/cli-login
with:
token: ${{ secrets.STAGING_TOKEN }}

- name: Reload snapshot
if: ${{ github.event_name == 'pull_request' && github.event.action != 'opened' && github.event.action != 'closed' }}
env:
SALEOR_CLI_ENV: staging
BACKUP_ID: ${{ needs.prepare_variables.outputs.BACKUP_ID }}
INSTANCE_NAME: ${{ needs.prepare_variables.outputs.POOL_NAME }}
run: |
npx saleor backup restore "${{ env.BACKUP_ID }}" \
--environment="${{ env.INSTANCE_NAME }}" \
--skip-webhooks-update
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved

- name: Create new instance
if: ${{ github.event_name == 'pull_request' && github.event.action == 'opened' }}
env:
SALEOR_CLI_ENV: staging
BACKUP_ID: ${{ needs.prepare_variables.outputs.BACKUP_ID }}
INSTANCE_NAME: ${{ needs.prepare_variables.outputs.POOL_NAME }}
run: |
npx saleor env create "${{ env.INSTANCE_NAME }}" \
--project=project-for-pr-testing \
--database=snapshot \
--restore-from=${{ env.BACKUP_ID }} \
--saleor=saleor-master-staging \
--domain="${{ env.INSTANCE_NAME }}" \
--skip-restrict \
--skip-webhooks-update
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved


deploy_dashboard:
if: github.event.pull_request.head.repo.full_name == 'saleor/saleor-dashboard'
runs-on: ubuntu-22.04
needs: prepare_variables
steps:
- uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"

- name: Start deployment
uses: bobheadxi/deployments@v1
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ needs.prepare_variables.outputs.POOL_NAME }}
ref: ${{ github.head_ref }}

- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-qa-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-qa-${{ env.cache-name }}-
${{ runner.os }}-qa-
${{ runner.os }}-

- name: Install deps
run: npm ci

- name: Build dashbaord
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved
env:
API_URI: ${{ needs.prepare_variables.outputs.API_URI }}
APPS_MARKETPLACE_API_URI: "https://apps.staging.saleor.io/api/v2/saleor-apps"
APP_MOUNT_URI: /
STATIC_URL: /
IS_CLOUD_INSTANCE: true
run: npm run build

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}

- name: Deploy to S3
run: aws s3 sync ./build/dashboard s3://${{ secrets.AWS_TEST_DEPLOYMENT_BUCKET }}/${{ needs.prepare_variables.outputs.BASE_URL }}
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved

- name: Invalidate cache
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_TEST_CF_DIST_ID }} --paths "/${{ needs.prepare_variables.outputs.BASE_URL }}/*"
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved

- name: Update deployment status
uses: bobheadxi/deployments@v1
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved
status: ${{ job.status }}
env_url: https://${{ needs.prepare_variables.outputs.BASE_URL }}/
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env: ${{ needs.prepare_variables.outputs.POOL_NAME }}


deploy_storybook:
if: github.event.pull_request.head.repo.full_name == 'saleor/saleor-dashboard'
runs-on: ubuntu-22.04
needs: prepare_variables
steps:
- uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"

- name: Start storybook deployment
uses: bobheadxi/deployments@v1
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved
id: storybook-deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved
env: storybook ${{ needs.prepare_variables.outputs.POOL_NAME }}
ref: ${{ github.head_ref }}

- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-qa-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-qa-${{ env.cache-name }}-
${{ runner.os }}-qa-
${{ runner.os }}-

- name: Install deps
run: npm ci

- name: Build storybook
run: npm run build-storybook

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}

- name: Deploy to S3
run: aws s3 sync ./build/storybook s3://${{ secrets.AWS_TEST_DEPLOYMENT_BUCKET }}/${{ needs.prepare_variables.outputs.BASE_URL }}/storybook
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved

- name: Invalidate cache
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_TEST_CF_DIST_ID }} --paths "/${{ needs.prepare_variables.outputs.BASE_URL }}/*"
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved

- name: Update storybook deployment status
uses: bobheadxi/deployments@v1
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved
status: ${{ job.status }}
env_url: https://${{ needs.prepare_variables.outputs.BASE_URL }}/storybook/index.html
deployment_id: ${{ steps.storybook-deployment.outputs.deployment_id }}
env: storybook ${{ needs.prepare_variables.outputs.POOL_NAME }}

run-tests:
runs-on: ubuntu-latest
needs: [prepare_variables, deploy_dashboard, prepare_instance]
strategy:
fail-fast: false
matrix:
shard: [1/2, 2/2]
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"

- name: Install dependencies
run: npm ci

- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run tests
env:
API_URI: ${{ needs.prepare_variables.outputs.API_URI }}
BASE_URL: https://${{ needs.prepare_variables.outputs.BASE_URL }}/
E2E_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }}
E2E_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }}
E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
run: npx playwright test --shard ${{ matrix.shard }}

- name: Upload blob report to GitHub Actions Artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: all-blob-reports
path: blob-report
retention-days: 1

merge-reports:
if: '!cancelled()'
needs: [run-tests]

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci

- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v3
with:
name: all-blob-reports
path: all-blob-reports

- name: Merge into HTML Report
run: npx playwright merge-reports --reporter html ./all-blob-reports

- name: Upload HTML report
uses: actions/upload-artifact@v3
with:
name: html-report--attempt-${{ github.run_attempt }}
path: playwright-report
retention-days: 14
29 changes: 29 additions & 0 deletions .github/workflows/remove-instance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Testing

on:
pull_request:
types: [closed]

jobs:
remove_instance:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"

- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved

- name: Saleor login
uses: ./.github/actions/cli-login
with:
token: ${{ secrets.STAGING_TOKEN }}

- name: Remove instance
env:
SALEOR_CLI_ENV: staging
run: npx saleor env remove "${{ env.GITHUB_HEAD_REF_SLUG_URL }}" --force
andrzejewsky marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion .github/workflows/test-env-cleanup.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: TEST-ENV-CLEANUP
name: Testing
# Remove test instance for closed pull requests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional? This name may be a bit confusing.


on:
Expand Down
Loading
Loading