Skip to content

Commit

Permalink
add reporting to release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
szczecha committed Feb 20, 2025
1 parent 31f9085 commit f41d109
Show file tree
Hide file tree
Showing 7 changed files with 647 additions and 13 deletions.
7 changes: 4 additions & 3 deletions .github/actions/flaky-tests-report/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,22 @@ runs:
shell: bash
run: |
DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") # ISO format
jq --arg date "$DATE" '.results.summary.extra = { "data": $date }' ctrf-reports/merged-report.json > ctrf-reports/tmp.json && mv ctrf-reports/tmp.json ctrf-reports/merged-report.json
jq --arg date "$DATE" '.results.summary.extra = { "date": $date }' ctrf-reports/merged-report.json > ctrf-reports/tmp.json && mv ctrf-reports/tmp.json ctrf-reports/merged-report.json
- name: Upload CTRF report
uses: actions/upload-artifact@v4
with:
name: merged-report.json
path: ctrf-reports
retention-days: 14
delete-merged: true

- name: Publish Test Report
uses: ctrf-io/github-test-reporter@v1
with:
report-path: ctrf-reports/merged-report.json
summary-report: true
commit-report: true
failed-report: true
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
if: always()
Expand All @@ -53,7 +54,7 @@ runs:
overwrite-comment: true
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
if: always()
if: github.event_name == 'pull_request'

inputs:
github_token:
Expand Down
12 changes: 11 additions & 1 deletion .github/actions/prepare-api-variables/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ outputs:
SALEOR_CLOUD_SERVICE:
description: "Which saleor cloud service will be used"
value: ${{ steps.generate.outputs.SALEOR_CLOUD_SERVICE }}
SALEOR_VERSION:
description: "The version of Saleor"
value: ${{ steps.generate.outputs.SALEOR_VERSION }}

runs:
using: "composite"
Expand All @@ -55,11 +58,13 @@ runs:
if [[ "$DESTINATION_BRANCH" == 'main' ]]; then
echo "BACKUP_NAMESPACE=snapshot-automation-tests" >> $GITHUB_OUTPUT
echo "SALEOR_CLOUD_SERVICE=saleor-master-staging" >> $GITHUB_OUTPUT
echo "SALEOR_VERSION=${PREFIX}${PULL_REQUEST_NUMBER}" >> $GITHUB_OUTPUT
else
# it handles pull requests to the other branches than main, e.g. release branches
VERSION_SLUG=$(echo "${DESTINATION_BRANCH}" | sed "s/\.//")
echo "BACKUP_NAMESPACE=snapshot-automation-tests-${DESTINATION_BRANCH}" >> $GITHUB_OUTPUT
echo "SALEOR_CLOUD_SERVICE=saleor-staging-v${VERSION_SLUG}" >> $GITHUB_OUTPUT
echo "SALEOR_VERSION=${DESTINATION_BRANCH}" >> $GITHUB_OUTPUT
fi
exit 0
Expand All @@ -76,6 +81,7 @@ runs:
echo "POOL_INSTANCE=https://v${VERSION_SLUG}.staging.saleor.cloud/" >> $GITHUB_OUTPUT
echo "BACKUP_NAMESPACE=snapshot-automation-tests-${CURRENT_BRANCH}" >> $GITHUB_OUTPUT
echo "SALEOR_CLOUD_SERVICE=saleor-master-staging" >> $GITHUB_OUTPUT
echo "SALEOR_VERSION=${VERSION_SLUG}" >> $GITHUB_OUTPUT
exit 0
fi
Expand All @@ -88,6 +94,9 @@ runs:
echo "POOL_INSTANCE=https://automation-dashboard.staging.saleor.cloud" >> $GITHUB_OUTPUT
echo "BACKUP_NAMESPACE=snapshot-automation-tests" >> $GITHUB_OUTPUT
echo "SALEOR_CLOUD_SERVICE=saleor-master-staging" >> $GITHUB_OUTPUT
VERSION=$(cat package.json | jq -r .version)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "SALEOR_VERSION=$VERSION" >> $GITHUB_OUTPUT
exit 0
fi
Expand All @@ -101,7 +110,8 @@ runs:
echo "POOL_NAME=${VERSION} Staging" >> "$GITHUB_OUTPUT"
echo "POOL_INSTANCE=https://v${VERSION_SLUG}.staging.saleor.cloud/" >> "$GITHUB_OUTPUT"
echo "BACKUP_NAMESPACE=snapshot-automation-tests-${VERSION}" >> "$GITHUB_OUTPUT"
echo "SALEOR_CLOUD_SERVICE=saleor-master-staging" >> $GITHUB_OUTPUT
echo "SALEOR_CLOUD_SERVICE=saleor-staging-v${VERSION_SLUG}" >> $GITHUB_OUTPUT
echo "SALEOR_VERSION=$VERSION" >> $GITHUB_OUTPUT
exit 0
fi
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/prepare-tests-variables/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ outputs:
SALEOR_CLOUD_SERVICE:
description: "Which saleor cloud service will be used"
value: ${{ steps.api.outputs.SALEOR_CLOUD_SERVICE }}
SALEOR_VERSION:
description: "The version of Saleor"
value: ${{ steps.api.outputs.SALEOR_VERSION }}

runs:
using: "composite"
Expand Down Expand Up @@ -80,3 +83,4 @@ runs:
echo "::notice title=BACKUP_NAMESPACE::${BACKUP_NAMESPACE}"
echo "::notice title=SNAPSHOT::backup_id=${BACKUP_ID}, version=${BACKUP_VER}, name=${BACKUP_NAME}"
echo "::notice title=SALEOR_CLOUD_SERVICE::${SALEOR_CLOUD_SERVICE}"
61 changes: 61 additions & 0 deletions .github/workflows/automation-tests-on-repository-dispatch-new.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: NEW Execute automation tests
run-name: Run tests on ${{github.event.client_payload.custom_version }} ${{github.event.client_payload.project}}

on:
repository_dispatch:
types: [automation-tests-event]

jobs:
get-environment-variables:
runs-on: ubuntu-22.04
timeout-minutes: 30
outputs:
VERSION: ${{ steps.get-environment-variables.outputs.version }}
env:
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CUSTOM_VERSION: ${{github.event.client_payload.custom_version }}
steps:
- name: Checkout
uses: actions/checkout@v4

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

- name: Install dependencies
run: |
cd .github/workflows
npm ci
- name: get environment variables
id: get-environment-variables
run: |
node .github/workflows/getEnvironmentVariables.js \
--custom_version "$CUSTOM_VERSION" \
--repo_token "$REPO_TOKEN"
run-tests-on-release:
needs: get-environment-variables
uses: ./.github/workflows/run-tests-on-release-new.yml
with:
VERSION: ${{needs.get-environment-variables.outputs.VERSION}}
CUSTOM_VERSION: ${{github.event.client_payload.custom_version }}
ADDITIONAL_TITLE: "Core automation test"
secrets: inherit

add-comment-to-release-pr:
if: ${{ !cancelled() }}
needs: run-tests-on-release
runs-on: ubuntu-22.04
steps:
- name: add-comment-to-release-pr
env:
PR_NUMBER: ${{github.event.client_payload.release_pr }}
PR_COMMENT: ${{needs.run-tests-on-release.outputs.PR_COMMENT}}
run: |
export GITHUB_TOKEN=$( \
curl --request GET --url ${{ secrets.VAULT_URL}} --header "Authorization: JWT ${{ secrets.VAULT_JWT }}" | jq -r .token \
)
gh pr comment "$PR_NUMBER" --body "$PR_COMMENT" -R github.com/saleor/saleor-cloud-deployments
186 changes: 186 additions & 0 deletions .github/workflows/deploy-staging-and-prepare-release-new.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
name: NEW Deploy Dashboard to staging
on:
push:
branches:
# Matches release branches
- "[0-9]+.[0-9]+"

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
prepare-release:
name: Prepare release with Changesets
runs-on: ubuntu-22.04
outputs:
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }}
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Install Dependencies
run: npm ci
- name: Publishing version
uses: changesets/action@d89c1de63c7f28ac47ec85ed395f5f1d045d4697 # v1.4.4
id: changesets
with:
title: "Prepare release ${{ github.ref_name }}"
commit: "Release ${{ github.ref_name }}"
publish: "npm run release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build:
needs: prepare-release
if: always()
runs-on: ubuntu-20.04
outputs:
MINOR_VERSION: ${{ env.MINOR_VERSION }}
CUSTOM_VERSION: ${{ env.CUSTOM_VERSION || env.VERSION }}
env:
## backward compatibility for older versions
APPS_MARKETPLACE_API_URI: "https://apps.staging.saleor.io/api/v2/saleor-apps"
## backward compatibility for older versions
API_URI: /graphql/

API_URL: /graphql/
APP_MOUNT_URI: /dashboard/
STATIC_URL: /dashboard/static/
SENTRY_ORG: saleor
SENTRY_PROJECT: dashboard
SENTRY_URL_PREFIX: "~/dashboard/static"
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
APPS_MARKETPLACE_API_URL: "https://apps.staging.saleor.io/api/v2/saleor-apps"
VERSION: ${{ github.event.inputs.git_ref || github.ref_name }}
IS_CLOUD_INSTANCE: true
ENABLED_SERVICE_NAME_HEADER: true
ONBOARDING_USER_JOINED_DATE_THRESHOLD: ${{ vars.STAGING_ONBOARDING_USER_JOINED_DATE_THRESHOLD }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.VERSION }}

- name: Set environment
# Convert version into staging deployment name (e.g 3.3.0 -> saleor-staging-v33)
run: |
set -x
environment=$(echo $VERSION | sed -n 's#\([0-9]\+\).\([0-9]\+\).*#saleor-staging-v\1\2#p')
echo "ENVIRONMENT=${environment}" >> "$GITHUB_ENV"
- name: Set custom version
env:
VERSION: ${{ github.event.inputs.git_ref || github.ref_name }}
# Add commit hash to basic version number
run: |
set -x
HASH=$(git rev-parse --short HEAD)
CURRENT_VERSION=$(jq -r .version package.json)
RELEASE="${CURRENT_VERSION}-${HASH}"
echo "CUSTOM_VERSION=${RELEASE}" >> "$GITHUB_ENV"
echo "SENTRY_RELEASE=${RELEASE}" >> "$GITHUB_ENV"
minor_version=$(echo "$VERSION" | sed -n 's#\([0-9]\+\).\([0-9]\+\).*#\1.\2#p')
echo "MINOR_VERSION=${minor_version}" >> "$GITHUB_ENV"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"

- name: Create check in prepare release PR
if: needs.prepare-release.outputs.hasChangesets == 'true'
id: create-check
uses: ./.github/actions/checks/create-pull-request-check
with:
PR_HEAD: "changeset-release/${{env.MINOR_VERSION}}"
CHECK_NAME: "Deploy_staging"
STATUS: "in_progress"
TITLE: "Deploy staging"
DETAILS_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

- name: Package
timeout-minutes: 15
run: |
npm ci
- name: Build
run: |
npm run build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_CLOUD_STAGING_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_CLOUD_STAGING_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Deploy
id: deploy
run: |
aws s3 sync build/dashboard "s3://${DEPLOYMENT_BUCKET}/${ENVIRONMENT}/static/"
aws s3 cp build/dashboard/index.html "s3://${DEPLOYMENT_BUCKET}/${ENVIRONMENT}/"
IFS=',' read -ra DISTRIBUTIONS_ARRAY <<< "${CDN_DISTRIBUTIONS}"
for DISTRIBUTION in "${DISTRIBUTIONS_ARRAY[@]}"; do
echo "::add-mask::$DISTRIBUTION"
for i in {1..3}; do aws cloudfront create-invalidation --distribution-id "$DISTRIBUTION" --paths "/dashboard*" && break || sleep 5; done
done
env:
DEPLOYMENT_BUCKET: ${{ secrets.AWS_CLOUD_STAGING_DEPLOYMENT_BUCKET }}
CDN_DISTRIBUTIONS: ${{ secrets.AWS_CLOUD_STAGING_CDN_DISTRIBUTIONS }}

- name: Update check
if: always() && ${{ steps.create-check.outputs.CHECK_ID }}
uses: ./.github/actions/checks/update-pull-request-check
with:
CHECK_ID: ${{ steps.create-check.outputs.CHECK_ID }}
CHECK_NAME: "Deploy_staging"
STATUS: "completed"
CONCLUSION: "${{ steps.deploy.outcome }}"
TITLE: "Deploy staging"
SUMMARY: "Deploy finished with status ${{ steps.deploy.outcome }}. To check details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
DETAILS_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

- name: Notify Slack
if: ${{ always() }}
env:
JOB_DEPLOYMENT_KIND: staging
JOB_STATUS: ${{ job.status }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLOUD_DEPLOYMENTS_WEBHOOK_URL }}
SLACK_MENTION_GROUP_ID: ${{ secrets.SLACK_DASHBOARD_GROUP_ID }}
JOB_TITLE: "Dashboard deployment of ${{ env.CUSTOM_VERSION || env.VERSION }} to ${{ env.ENVIRONMENT }}"
run: |
python3 ./.github/workflows/notify/notify-slack.py
- name: Prepare Sandbox release pull request
if: needs.prepare-release.outputs.hasChangesets == 'false'
run: |
export GITHUB_TOKEN=$( \
curl --request GET --url ${{ secrets.VAULT_URL}} --header "Authorization: JWT ${{ secrets.VAULT_JWT }}" | jq -r .token \
)
version=$(cat package.json | jq -r .version)
payload=$(jq --null-input --arg version "$version" '{
"event_type": "open-release-pull-request",
"client_payload": {
"project": "DASHBOARD",
"environment": "SANDBOX",
"version": $version
}
}')
gh api /repos/saleor/saleor-cloud-deployments/dispatches --input - <<< $payload
run-tests-on-release:
needs: [prepare-release, build]
if: needs.prepare-release.outputs.hasChangesets == 'true'
uses: ./.github/workflows/run-tests-on-release-new.yml
with:
VERSION: ${{ needs.build.outputs.MINOR_VERSION }} # eg. "3.19"
CUSTOM_VERSION: ${{ needs.build.outputs.CUSTOM_VERSION }} # eg. "3.19.4-5a41d18"
secrets: inherit
12 changes: 3 additions & 9 deletions .github/workflows/pr-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
BACKUP_NAME: ${{ steps.cloud_variables.outputs.BACKUP_NAME }}
SHARD_MATRIX: ${{ steps.generate-shard-matrix.outputs.SHARD_MATRIX }}
SALEOR_CLOUD_SERVICE: ${{ steps.cloud_variables.outputs.SALEOR_CLOUD_SERVICE }}
SALEOR_VERSION: ${{ steps.cloud_variables.outputs.SALEOR_VERSION }}
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -75,7 +76,6 @@ jobs:
outputs:
ACCOUNTS: ${{ steps.accounts.outputs.ACCOUNTS }}
TESTMO_RUN_ID: ${{ steps.init-testmo.outputs.testmo-run-id }}
DASHBOARD_VERSION: ${{ steps.build-dashboard.outputs.DASHBOARD_VERSION }}
runs-on: ubuntu-22.04
needs: initialize-cloud
permissions:
Expand Down Expand Up @@ -127,13 +127,7 @@ jobs:
IS_CLOUD_INSTANCE: true
ENABLED_SERVICE_NAME_HEADER: true
ONBOARDING_USER_JOINED_DATE_THRESHOLD: ${{ vars.STAGING_ONBOARDING_USER_JOINED_DATE_THRESHOLD }}
run: |
npm run build
# Extract version from package.json
VERSION=$(cat package.json | jq -r .version)
echo "VERSION=$VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "DASHBOARD_VERSION=$VERSION" >> $GITHUB_OUTPUT
run: npm run build

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
Expand Down Expand Up @@ -212,7 +206,7 @@ jobs:
PW_RETRIES: ${{ vars.PW_RETRIES }}
ACCOUNTS: ${{ needs.deploy-dashboard.outputs.ACCOUNTS }}
E2E_ENCODE_PASS: ${{ secrets.E2E_ENCODE_PASS }}
DASHBOARD_VERSION: ${{ needs.deploy-dashboard.outputs.DASHBOARD_VERSION }}
DASHBOARD_VERSION: ${{ needs.initialize-cloud.outputs.SALEOR_VERSION }}
BRANCH_NAME: ${{ github.ref}}
SALEOR_CLOUD_SERVICE: ${{ needs.initialize-cloud.outputs.SALEOR_CLOUD_SERVICE }}

Expand Down
Loading

0 comments on commit f41d109

Please sign in to comment.