From 58064b64ba49b1e658eccd54c075ffa4d603ce5f Mon Sep 17 00:00:00 2001 From: Josh Ng Date: Fri, 8 Nov 2024 15:44:35 +0000 Subject: [PATCH 01/14] ci(pie-storybook): DSW-2468 init commit setup storybook dev:testing --- .github/workflows/ci.yml | 15 ++++ apps/pie-storybook/.storybook/main.ts | 17 +++-- apps/pie-storybook/package.json | 2 + .../stories/pie-divider.test.stories.ts | 68 +++++++++++++++++++ apps/pie-storybook/turbo.json | 14 ++++ package.json | 2 + 6 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 apps/pie-storybook/stories/pie-divider.test.stories.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b36aefe4b..87d4bcd2f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -195,6 +195,21 @@ jobs: bucket-name-main: 'pie-storybook' secrets: inherit + deploy-storybook-testing: + needs: unit-tests + if: (needs.check-change-type.outputs.web-components-change == 'true' || needs.check-change-type.outputs.storybook-change == 'true') || github.ref == 'refs/heads/main' + uses: ./.github/workflows/amplify-deploy.yml + with: + os: ubuntu-latest + node-version: 20 + amplify-app-id: d17ja0ul7nrdy0 + package-name: 'pie-storybook' + package-dist-directory: ./apps/pie-storybook/dist + bucket-name-preview: 'pie-storybook-preview/testing' + bucket-name-main: 'pie-storybook' + build-script: 'build:testing' + secrets: inherit + # TODO: DSW-1151 - Move this into a reusable action so it's not duplicated browser-tests-components: needs: [ build-ubuntu-node-20, deploy-storybook ] diff --git a/apps/pie-storybook/.storybook/main.ts b/apps/pie-storybook/.storybook/main.ts index c6b381645e..1d1069d151 100644 --- a/apps/pie-storybook/.storybook/main.ts +++ b/apps/pie-storybook/.storybook/main.ts @@ -1,10 +1,17 @@ import type { StorybookConfig } from '@storybook/web-components-vite'; +const isBrowserTesting = process.env.BROWSER_TESTING === 'true'; + const config: StorybookConfig = { - stories: [ - "../stories/**/*.mdx", - "../stories/**/*.stories.@(js|ts|tsx)" - ], + stories: isBrowserTesting + ? [ + "../stories/**/*.test.mdx", + "../stories/**/*.test.stories.@(js|ts|tsx)" + ] + : [ + "../stories/**/*.mdx", + "../stories/**/!(*.test).stories.@(js|ts|tsx)" + ], addons: [ "@storybook/addon-essentials", "@storybook/addon-a11y", @@ -20,6 +27,6 @@ const config: StorybookConfig = { docs: { autodocs: false } -} +}; export default config; diff --git a/apps/pie-storybook/package.json b/apps/pie-storybook/package.json index 8facef5344..30d5760230 100644 --- a/apps/pie-storybook/package.json +++ b/apps/pie-storybook/package.json @@ -5,7 +5,9 @@ "description": "Storybook for PIE Design System components", "scripts": { "dev": "storybook dev -p 6006", + "dev:testing": "BROWSER_TESTING=true storybook dev -p 6006", "build": "storybook build --output-dir dist && cp -R ./static ./dist", + "build:testing": "BROWSER_TESTING=true storybook build --output-dir dist && cp -R ./static ./dist", "lint:scripts": "run -T eslint .", "lint:scripts:fix": "run -T eslint . --fix", "copy:component-statuses": "cp -v ../../component-statuses.json ." diff --git a/apps/pie-storybook/stories/pie-divider.test.stories.ts b/apps/pie-storybook/stories/pie-divider.test.stories.ts new file mode 100644 index 0000000000..58195acad7 --- /dev/null +++ b/apps/pie-storybook/stories/pie-divider.test.stories.ts @@ -0,0 +1,68 @@ +import { html } from 'lit'; +import { ifDefined } from 'lit/directives/if-defined.js'; +import { type Meta } from '@storybook/web-components'; + +import '@justeattakeaway/pie-divider'; +import { + type DividerProps, variants, orientations, defaultProps, +} from '@justeattakeaway/pie-divider'; + +import { createStory, type TemplateFunction } from '../utilities'; + +type DividerStoryMeta = Meta; + +const defaultArgs: DividerProps = { ...defaultProps }; + +const dividerStoryMeta: DividerStoryMeta = { + title: 'Divider', + component: 'pie-divider', + argTypes: { + variant: { + description: 'Set the variant of the divider. To change this, view the other story.', + control: { disable: true }, + options: variants, + defaultValue: { + summary: defaultProps.variant, + }, + }, + label: { + description: 'The label text for the divider.', + control: { + type: 'text', + defaultValue: { + summary: 'Label', + }, + }, + }, + orientation: { + description: 'Set the orientation of the divider.', + control: 'select', + options: orientations, + defaultValue: { + summary: defaultProps.orientation, + }, + }, + }, + args: defaultArgs, + parameters: { + design: { + type: 'figma', + url: 'https://www.figma.com/file/R2rBfzJP0hG0MZorq6FLZ1/%5BCore%5D-Components-%E2%9A%AA%EF%B8%8F-%5BPIE-2.0%5D?node-id=876-1227&node-type=CANVAS&t=v6qypWzZqWE6lPxm-0', + }, + }, +}; + +export default dividerStoryMeta; + +const Template : TemplateFunction = ({ variant, label, orientation }) => html` +
+ +
+ `; + +const createDividerStory = createStory(Template, defaultArgs); + +export const Default = createDividerStory(); +export const Inverse = createDividerStory({ variant: 'inverse' }, { bgColor: 'dark (container-dark)' }); +export const Labelled = createDividerStory({ label: 'Label' }); +export const LargeTextContent = createDividerStory({ label: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Reprehenderit quas inventore quasi ullam, sed ab odio dicta, tempore' }); diff --git a/apps/pie-storybook/turbo.json b/apps/pie-storybook/turbo.json index d596c7aca1..98d9e8b101 100644 --- a/apps/pie-storybook/turbo.json +++ b/apps/pie-storybook/turbo.json @@ -11,6 +11,13 @@ "copy:component-statuses" ] }, + "dev:testing": { + "cache": false, + "dependsOn": [ + "^build", + "copy:component-statuses" + ] + }, "build": { "cache": true, "dependsOn": [ @@ -18,6 +25,13 @@ "copy:component-statuses" ] }, + "build:testing": { + "cache": true, + "dependsOn": [ + "^build", + "copy:component-statuses" + ] + }, "copy:component-statuses": { "dependsOn": [ "//#generate:component-statuses" diff --git a/package.json b/package.json index 655c6a6009..1967314311 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "analyse-component-bundles": "bundlewatch --config bundlewatch.config.json", "watch": "turbo run watch --filter=!pie-monorepo", "build": "cross-env-shell turbo run build --filter=!'./apps/examples/*' --filter=!pie-monorepo --token=${TURBO_TOKEN}", + "build:testing": "cross-env-shell turbo run build:testing --filter=!'./apps/examples/*' --filter=!pie-monorepo --token=${TURBO_TOKEN}", "build:dev": "cross-env-shell turbo run build:dev --filter=!'./apps/examples/*' --filter=!pie-monorepo --token=${TURBO_TOKEN}", "build:examples": "cross-env-shell turbo run build:examples --filter=!pie-monorepo --token=${TURBO_TOKEN}", "build:react-wrapper": "cross-env-shell turbo run build:react-wrapper --filter=!pie-monorepo --token=${TURBO_TOKEN}", @@ -35,6 +36,7 @@ "clean": "turbo run clean --filter=!pie-monorepo", "cz": "./packages/tools/pie-git-hooks-scripts/check-branch-name.js $(git symbolic-ref --short HEAD) && ./node_modules/cz-customizable/standalone.js", "dev": "turbo run dev --filter=!pie-monorepo", + "dev:testing": "turbo run dev:testing --filter=!pie-monorepo", "copy:component-statuses": "cross-env-shell turbo run copy:component-statuses --filter=!pie-monorepo", "generate:component-statuses": "npx generate-component-statuses", "generate:examples": "cross-env-shell turbo run generate:examples --filter=!pie-monorepo --token=${TURBO_TOKEN}", From 973cc2b3036c9174b3600acf2466fa0789847a7c Mon Sep 17 00:00:00 2001 From: Josh Ng Date: Mon, 11 Nov 2024 11:41:00 +0000 Subject: [PATCH 02/14] ci(pie-storybook): DSW-2468 updated ci.yml --- .github/workflows/amplify-deploy.yml | 202 ++++++++++++++------------- .github/workflows/ci.yml | 1 + 2 files changed, 104 insertions(+), 99 deletions(-) diff --git a/.github/workflows/amplify-deploy.yml b/.github/workflows/amplify-deploy.yml index 61df75cc34..f12cc001eb 100644 --- a/.github/workflows/amplify-deploy.yml +++ b/.github/workflows/amplify-deploy.yml @@ -33,6 +33,10 @@ on: required: false type: string default: 'build' + destination-dir: + required: false + type: string + default: '/' env: AMPLIFY_ID: ${{ inputs.amplify-app-id }} @@ -86,116 +90,116 @@ jobs: aws-region: ${{ env.AWS_REGION }} aws-bucket: ${{ env.BUCKET_NAME }} bucket-root: "/" - destination-dir: "/" + destination-dir: "${{ inputs.destination-dir }}" file-path: "${{inputs.package-dist-directory}}/${{ env.ZIP_NAME }}" content-type: "application/zip" public: true # Create branch on Amplify - - name: Create Amplify branch - shell: bash - # We return true to prevent the step from failing if the branch already exists - run: | - aws amplify create-branch \ - --app-id ${{ env.AMPLIFY_ID }} \ - --branch-name ${{ env.BRANCH_NAME }} \ - || true - # Deploy Amplify from S3 - - name: Start Amplify Deployment from S3 - shell: bash - run: | - aws amplify start-deployment \ - --app-id ${{ env.AMPLIFY_ID }} \ - --branch-name ${{ env.BRANCH_NAME }} \ - --source-url s3://${{ env.BUCKET_NAME }}/${{ env.ZIP_NAME }} - # Set env vars for domain name association - - name: Set environment variables for domain name association - if: github.event_name == 'pull_request' - run: | - PACKAGE_NAME_SUFFIX=$(echo "${{ inputs.package-name }}" | sed -e 's/^pie-//') - echo "SUB_DOMAIN=pr${{ github.event.number }}-$PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV + # - name: Create Amplify branch + # shell: bash + # # We return true to prevent the step from failing if the branch already exists + # run: | + # aws amplify create-branch \ + # --app-id ${{ env.AMPLIFY_ID }} \ + # --branch-name ${{ env.BRANCH_NAME }} \ + # || true + # # Deploy Amplify from S3 + # - name: Start Amplify Deployment from S3 + # shell: bash + # run: | + # aws amplify start-deployment \ + # --app-id ${{ env.AMPLIFY_ID }} \ + # --branch-name ${{ env.BRANCH_NAME }} \ + # --source-url s3://${{ env.BUCKET_NAME }}/${{ env.ZIP_NAME }} + # # Set env vars for domain name association + # - name: Set environment variables for domain name association + # if: github.event_name == 'pull_request' + # run: | + # PACKAGE_NAME_SUFFIX=$(echo "${{ inputs.package-name }}" | sed -e 's/^pie-//') + # echo "SUB_DOMAIN=pr${{ github.event.number }}-$PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV - - name: Get existing domain associations - if: github.event_name == 'pull_request' - run: | - DOMAIN_ASSOCIATIONS=$(aws amplify get-domain-association \ - --app-id ${{ env.AMPLIFY_ID }} \ - --domain-name pie.design \ - --region ${{ env.AWS_REGION }} \ - | jq ' - [.domainAssociation.subDomains[].subDomainSetting | { prefix: (.prefix // ""), branchName }] | - . |= (map(.branchName) | index("pr${{ github.event.number }}")) as $ix | - if $ix == null then - . + [{branchName: "pr${{ github.event.number }}", prefix: "${{ env.SUB_DOMAIN }}"}] - else . end - ' -c) - echo "DOMAIN_ASSOCIATIONS=$DOMAIN_ASSOCIATIONS" >> $GITHUB_ENV - - name: Create Subdomain Association - if: github.event_name == 'pull_request' - shell: bash - run: | - aws amplify update-domain-association \ - --app-id ${{ env.AMPLIFY_ID }} \ - --domain-name pie.design \ - --sub-domain-settings '${{ env.DOMAIN_ASSOCIATIONS }}' + # - name: Get existing domain associations + # if: github.event_name == 'pull_request' + # run: | + # DOMAIN_ASSOCIATIONS=$(aws amplify get-domain-association \ + # --app-id ${{ env.AMPLIFY_ID }} \ + # --domain-name pie.design \ + # --region ${{ env.AWS_REGION }} \ + # | jq ' + # [.domainAssociation.subDomains[].subDomainSetting | { prefix: (.prefix // ""), branchName }] | + # . |= (map(.branchName) | index("pr${{ github.event.number }}")) as $ix | + # if $ix == null then + # . + [{branchName: "pr${{ github.event.number }}", prefix: "${{ env.SUB_DOMAIN }}"}] + # else . end + # ' -c) + # echo "DOMAIN_ASSOCIATIONS=$DOMAIN_ASSOCIATIONS" >> $GITHUB_ENV + # - name: Create Subdomain Association + # if: github.event_name == 'pull_request' + # shell: bash + # run: | + # aws amplify update-domain-association \ + # --app-id ${{ env.AMPLIFY_ID }} \ + # --domain-name pie.design \ + # --sub-domain-settings '${{ env.DOMAIN_ASSOCIATIONS }}' - - name: Wait for Amplify deployment - if: github.event_name == 'pull_request' - run: | - LATEST_JOB_ID=$(aws amplify list-jobs \ - --app-id ${{ env.AMPLIFY_ID }} \ - --branch-name ${{ env.BRANCH_NAME }} \ - --region ${{ env.AWS_REGION }} --query jobSummaries[0].jobId \ - --output text) - MAX_ATTEMPTS=12 - SLEEP_SECONDS=10 + # - name: Wait for Amplify deployment + # if: github.event_name == 'pull_request' + # run: | + # LATEST_JOB_ID=$(aws amplify list-jobs \ + # --app-id ${{ env.AMPLIFY_ID }} \ + # --branch-name ${{ env.BRANCH_NAME }} \ + # --region ${{ env.AWS_REGION }} --query jobSummaries[0].jobId \ + # --output text) + # MAX_ATTEMPTS=12 + # SLEEP_SECONDS=10 - attempt_counter=0 - status="" + # attempt_counter=0 + # status="" - while [ $attempt_counter -lt $MAX_ATTEMPTS ]; do - status=$(aws amplify get-job \ - --app-id ${{ env.AMPLIFY_ID }} \ - --branch-name ${{ env.BRANCH_NAME }} \ - --job-id $LATEST_JOB_ID \ - --query job.summary.status \ - --output text) - echo "Attempt $(( attempt_counter+1 )) of $MAX_ATTEMPTS: Status - $status" + # while [ $attempt_counter -lt $MAX_ATTEMPTS ]; do + # status=$(aws amplify get-job \ + # --app-id ${{ env.AMPLIFY_ID }} \ + # --branch-name ${{ env.BRANCH_NAME }} \ + # --job-id $LATEST_JOB_ID \ + # --query job.summary.status \ + # --output text) + # echo "Attempt $(( attempt_counter+1 )) of $MAX_ATTEMPTS: Status - $status" - if [ "$status" == "SUCCEED" ]; then - echo "Amplify deployment succeeded." - break - fi + # if [ "$status" == "SUCCEED" ]; then + # echo "Amplify deployment succeeded." + # break + # fi - if [ "$status" == "FAILED" ]; then - echo "Amplify deployment failed." - exit 1 - fi + # if [ "$status" == "FAILED" ]; then + # echo "Amplify deployment failed." + # exit 1 + # fi - let "attempt_counter+=1" - sleep $SLEEP_SECONDS - done + # let "attempt_counter+=1" + # sleep $SLEEP_SECONDS + # done - if [ "$status" != "SUCCEED" ]; then - echo "Amplify deployment did not succeed within the expected time." - exit 1 - fi + # if [ "$status" != "SUCCEED" ]; then + # echo "Amplify deployment did not succeed within the expected time." + # exit 1 + # fi - # If successful - - name: Update deployment status (success) - if: ${{ github.event_name == 'pull_request' && success() }} - uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - environment-url: https://${{ env.SUB_DOMAIN }}.pie.design/ - deployment-id: ${{ steps.deploy.outputs.deployment_id }} - state: "success" + # # If successful + # - name: Update deployment status (success) + # if: ${{ github.event_name == 'pull_request' && success() }} + # uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 + # with: + # token: ${{ secrets.GITHUB_TOKEN }} + # environment-url: https://${{ env.SUB_DOMAIN }}.pie.design/ + # deployment-id: ${{ steps.deploy.outputs.deployment_id }} + # state: "success" - # If it failed - - name: Update deployment status (failure) - if: ${{ github.event_name == 'pull_request' && failure() }} - uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - environment-url: https://${{ env.SUB_DOMAIN }}.pie.design/ - deployment-id: ${{ steps.deploy.outputs.deployment_id }} - state: "failure" \ No newline at end of file + # # If it failed + # - name: Update deployment status (failure) + # if: ${{ github.event_name == 'pull_request' && failure() }} + # uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 + # with: + # token: ${{ secrets.GITHUB_TOKEN }} + # environment-url: https://${{ env.SUB_DOMAIN }}.pie.design/ + # deployment-id: ${{ steps.deploy.outputs.deployment_id }} + # state: "failure" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87d4bcd2f5..0e2bbc6c2b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -208,6 +208,7 @@ jobs: bucket-name-preview: 'pie-storybook-preview/testing' bucket-name-main: 'pie-storybook' build-script: 'build:testing' + destination-dir: 'testing' secrets: inherit # TODO: DSW-1151 - Move this into a reusable action so it's not duplicated From 34e38afaf65079933424c0fb2ad908eb40b6a335 Mon Sep 17 00:00:00 2001 From: Josh Ng Date: Mon, 11 Nov 2024 12:08:17 +0000 Subject: [PATCH 03/14] ci(pie-storybook): DSW-2468 updated amplify deploy naming --- .github/workflows/amplify-deploy.yml | 196 +++++++++++++-------------- .github/workflows/ci.yml | 4 +- 2 files changed, 100 insertions(+), 100 deletions(-) diff --git a/.github/workflows/amplify-deploy.yml b/.github/workflows/amplify-deploy.yml index f12cc001eb..3c99658cbe 100644 --- a/.github/workflows/amplify-deploy.yml +++ b/.github/workflows/amplify-deploy.yml @@ -95,111 +95,111 @@ jobs: content-type: "application/zip" public: true # Create branch on Amplify - # - name: Create Amplify branch - # shell: bash - # # We return true to prevent the step from failing if the branch already exists - # run: | - # aws amplify create-branch \ - # --app-id ${{ env.AMPLIFY_ID }} \ - # --branch-name ${{ env.BRANCH_NAME }} \ - # || true - # # Deploy Amplify from S3 - # - name: Start Amplify Deployment from S3 - # shell: bash - # run: | - # aws amplify start-deployment \ - # --app-id ${{ env.AMPLIFY_ID }} \ - # --branch-name ${{ env.BRANCH_NAME }} \ - # --source-url s3://${{ env.BUCKET_NAME }}/${{ env.ZIP_NAME }} - # # Set env vars for domain name association - # - name: Set environment variables for domain name association - # if: github.event_name == 'pull_request' - # run: | - # PACKAGE_NAME_SUFFIX=$(echo "${{ inputs.package-name }}" | sed -e 's/^pie-//') - # echo "SUB_DOMAIN=pr${{ github.event.number }}-$PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV + - name: Create Amplify branch + shell: bash + # We return true to prevent the step from failing if the branch already exists + run: | + aws amplify create-branch \ + --app-id ${{ env.AMPLIFY_ID }} \ + --branch-name ${{ env.BRANCH_NAME }} \ + || true + # Deploy Amplify from S3 + - name: Start Amplify Deployment from S3 + shell: bash + run: | + aws amplify start-deployment \ + --app-id ${{ env.AMPLIFY_ID }} \ + --branch-name ${{ env.BRANCH_NAME }} \ + --source-url ${{ steps.upload-s3.outputs.file-url }} + # Set env vars for domain name association + - name: Set environment variables for domain name association + if: github.event_name == 'pull_request' + run: | + PACKAGE_NAME_SUFFIX=$(echo "${{ inputs.package-name }}" | sed -e 's/^pie-//') + echo "SUB_DOMAIN=pr${{ github.event.number }}-$PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV - # - name: Get existing domain associations - # if: github.event_name == 'pull_request' - # run: | - # DOMAIN_ASSOCIATIONS=$(aws amplify get-domain-association \ - # --app-id ${{ env.AMPLIFY_ID }} \ - # --domain-name pie.design \ - # --region ${{ env.AWS_REGION }} \ - # | jq ' - # [.domainAssociation.subDomains[].subDomainSetting | { prefix: (.prefix // ""), branchName }] | - # . |= (map(.branchName) | index("pr${{ github.event.number }}")) as $ix | - # if $ix == null then - # . + [{branchName: "pr${{ github.event.number }}", prefix: "${{ env.SUB_DOMAIN }}"}] - # else . end - # ' -c) - # echo "DOMAIN_ASSOCIATIONS=$DOMAIN_ASSOCIATIONS" >> $GITHUB_ENV - # - name: Create Subdomain Association - # if: github.event_name == 'pull_request' - # shell: bash - # run: | - # aws amplify update-domain-association \ - # --app-id ${{ env.AMPLIFY_ID }} \ - # --domain-name pie.design \ - # --sub-domain-settings '${{ env.DOMAIN_ASSOCIATIONS }}' + - name: Get existing domain associations + if: github.event_name == 'pull_request' + run: | + DOMAIN_ASSOCIATIONS=$(aws amplify get-domain-association \ + --app-id ${{ env.AMPLIFY_ID }} \ + --domain-name pie.design \ + --region ${{ env.AWS_REGION }} \ + | jq ' + [.domainAssociation.subDomains[].subDomainSetting | { prefix: (.prefix // ""), branchName }] | + . |= (map(.branchName) | index("pr${{ github.event.number }}")) as $ix | + if $ix == null then + . + [{branchName: "pr${{ github.event.number }}", prefix: "${{ env.SUB_DOMAIN }}"}] + else . end + ' -c) + echo "DOMAIN_ASSOCIATIONS=$DOMAIN_ASSOCIATIONS" >> $GITHUB_ENV + - name: Create Subdomain Association + if: github.event_name == 'pull_request' + shell: bash + run: | + aws amplify update-domain-association \ + --app-id ${{ env.AMPLIFY_ID }} \ + --domain-name pie.design \ + --sub-domain-settings '${{ env.DOMAIN_ASSOCIATIONS }}' - # - name: Wait for Amplify deployment - # if: github.event_name == 'pull_request' - # run: | - # LATEST_JOB_ID=$(aws amplify list-jobs \ - # --app-id ${{ env.AMPLIFY_ID }} \ - # --branch-name ${{ env.BRANCH_NAME }} \ - # --region ${{ env.AWS_REGION }} --query jobSummaries[0].jobId \ - # --output text) - # MAX_ATTEMPTS=12 - # SLEEP_SECONDS=10 + - name: Wait for Amplify deployment + if: github.event_name == 'pull_request' + run: | + LATEST_JOB_ID=$(aws amplify list-jobs \ + --app-id ${{ env.AMPLIFY_ID }} \ + --branch-name ${{ env.BRANCH_NAME }} \ + --region ${{ env.AWS_REGION }} --query jobSummaries[0].jobId \ + --output text) + MAX_ATTEMPTS=12 + SLEEP_SECONDS=10 - # attempt_counter=0 - # status="" + attempt_counter=0 + status="" - # while [ $attempt_counter -lt $MAX_ATTEMPTS ]; do - # status=$(aws amplify get-job \ - # --app-id ${{ env.AMPLIFY_ID }} \ - # --branch-name ${{ env.BRANCH_NAME }} \ - # --job-id $LATEST_JOB_ID \ - # --query job.summary.status \ - # --output text) - # echo "Attempt $(( attempt_counter+1 )) of $MAX_ATTEMPTS: Status - $status" + while [ $attempt_counter -lt $MAX_ATTEMPTS ]; do + status=$(aws amplify get-job \ + --app-id ${{ env.AMPLIFY_ID }} \ + --branch-name ${{ env.BRANCH_NAME }} \ + --job-id $LATEST_JOB_ID \ + --query job.summary.status \ + --output text) + echo "Attempt $(( attempt_counter+1 )) of $MAX_ATTEMPTS: Status - $status" - # if [ "$status" == "SUCCEED" ]; then - # echo "Amplify deployment succeeded." - # break - # fi + if [ "$status" == "SUCCEED" ]; then + echo "Amplify deployment succeeded." + break + fi - # if [ "$status" == "FAILED" ]; then - # echo "Amplify deployment failed." - # exit 1 - # fi + if [ "$status" == "FAILED" ]; then + echo "Amplify deployment failed." + exit 1 + fi - # let "attempt_counter+=1" - # sleep $SLEEP_SECONDS - # done + let "attempt_counter+=1" + sleep $SLEEP_SECONDS + done - # if [ "$status" != "SUCCEED" ]; then - # echo "Amplify deployment did not succeed within the expected time." - # exit 1 - # fi + if [ "$status" != "SUCCEED" ]; then + echo "Amplify deployment did not succeed within the expected time." + exit 1 + fi - # # If successful - # - name: Update deployment status (success) - # if: ${{ github.event_name == 'pull_request' && success() }} - # uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 - # with: - # token: ${{ secrets.GITHUB_TOKEN }} - # environment-url: https://${{ env.SUB_DOMAIN }}.pie.design/ - # deployment-id: ${{ steps.deploy.outputs.deployment_id }} - # state: "success" + # If successful + - name: Update deployment status (success) + if: ${{ github.event_name == 'pull_request' && success() }} + uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + environment-url: https://${{ env.SUB_DOMAIN }}.pie.design/ + deployment-id: ${{ steps.deploy.outputs.deployment_id }} + state: "success" - # # If it failed - # - name: Update deployment status (failure) - # if: ${{ github.event_name == 'pull_request' && failure() }} - # uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 - # with: - # token: ${{ secrets.GITHUB_TOKEN }} - # environment-url: https://${{ env.SUB_DOMAIN }}.pie.design/ - # deployment-id: ${{ steps.deploy.outputs.deployment_id }} - # state: "failure" \ No newline at end of file + # If it failed + - name: Update deployment status (failure) + if: ${{ github.event_name == 'pull_request' && failure() }} + uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + environment-url: https://${{ env.SUB_DOMAIN }}.pie.design/ + deployment-id: ${{ steps.deploy.outputs.deployment_id }} + state: "failure" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e2bbc6c2b..075c57c739 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -202,10 +202,10 @@ jobs: with: os: ubuntu-latest node-version: 20 - amplify-app-id: d17ja0ul7nrdy0 + amplify-app-id: d3eyargno6okyn package-name: 'pie-storybook' package-dist-directory: ./apps/pie-storybook/dist - bucket-name-preview: 'pie-storybook-preview/testing' + bucket-name-preview: 'pie-storybook-preview' bucket-name-main: 'pie-storybook' build-script: 'build:testing' destination-dir: 'testing' From a6f2dc03b6d565b917b77f3e5a3d3c66acf999f6 Mon Sep 17 00:00:00 2001 From: Josh Ng Date: Mon, 11 Nov 2024 12:18:59 +0000 Subject: [PATCH 04/14] ci(pie-storybook): DSW-2468 updated output file url for s3 --- .github/workflows/amplify-deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/amplify-deploy.yml b/.github/workflows/amplify-deploy.yml index 3c99658cbe..978091fc9d 100644 --- a/.github/workflows/amplify-deploy.yml +++ b/.github/workflows/amplify-deploy.yml @@ -94,6 +94,7 @@ jobs: file-path: "${{inputs.package-dist-directory}}/${{ env.ZIP_NAME }}" content-type: "application/zip" public: true + output-file-url: 'true' # Create branch on Amplify - name: Create Amplify branch shell: bash From 7a5461a4998386c8ac3ac327b8921304b16ac2f8 Mon Sep 17 00:00:00 2001 From: Josh Ng Date: Mon, 11 Nov 2024 14:48:04 +0000 Subject: [PATCH 05/14] ci(pie-storybook): DSW-2468 updated storybook turbo.json --- apps/pie-storybook/turbo.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/pie-storybook/turbo.json b/apps/pie-storybook/turbo.json index 98d9e8b101..15059c8c8e 100644 --- a/apps/pie-storybook/turbo.json +++ b/apps/pie-storybook/turbo.json @@ -23,14 +23,16 @@ "dependsOn": [ "^build", "copy:component-statuses" - ] + ], + "outputs": ["dist/**"] }, "build:testing": { "cache": true, "dependsOn": [ "^build", "copy:component-statuses" - ] + ], + "outputs": ["dist/**"] }, "copy:component-statuses": { "dependsOn": [ From 083deb6c1059191e4330851037d49f71608241f0 Mon Sep 17 00:00:00 2001 From: Josh Ng Date: Mon, 11 Nov 2024 15:07:33 +0000 Subject: [PATCH 06/14] ci(pie-storybook): DSW-2468 updated amplify deploy for sub domain suffix --- .github/workflows/amplify-deploy.yml | 8 ++++++-- .github/workflows/ci.yml | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/amplify-deploy.yml b/.github/workflows/amplify-deploy.yml index 978091fc9d..79cd8a2c18 100644 --- a/.github/workflows/amplify-deploy.yml +++ b/.github/workflows/amplify-deploy.yml @@ -37,6 +37,9 @@ on: required: false type: string default: '/' + sub-domain-suffix: + required: true + type: string env: AMPLIFY_ID: ${{ inputs.amplify-app-id }} @@ -115,9 +118,10 @@ jobs: # Set env vars for domain name association - name: Set environment variables for domain name association if: github.event_name == 'pull_request' + env: + SUB_DOMAIN_SUFFIX: ${{ inputs.sub-domain-suffix }} run: | - PACKAGE_NAME_SUFFIX=$(echo "${{ inputs.package-name }}" | sed -e 's/^pie-//') - echo "SUB_DOMAIN=pr${{ github.event.number }}-$PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV + echo "SUB_DOMAIN=pr${{ github.event.number }}-$SUB_DOMAIN_SUFFIX" >> $GITHUB_ENV - name: Get existing domain associations if: github.event_name == 'pull_request' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 075c57c739..3774d2d06d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -193,6 +193,7 @@ jobs: package-dist-directory: ./apps/pie-storybook/dist bucket-name-preview: 'pie-storybook-preview' bucket-name-main: 'pie-storybook' + sub-domain-suffix: 'storybook' secrets: inherit deploy-storybook-testing: @@ -209,6 +210,7 @@ jobs: bucket-name-main: 'pie-storybook' build-script: 'build:testing' destination-dir: 'testing' + sub-domain-suffix: 'storybook-testing' secrets: inherit # TODO: DSW-1151 - Move this into a reusable action so it's not duplicated @@ -279,6 +281,7 @@ jobs: package-dist-directory: ./apps/pie-docs/dist bucket-name-preview: 'pie-docs-preview' bucket-name-main: 'pie-docs' + sub-domain-suffix: 'docs' secrets: inherit browser-tests-docs: From daf21522c5fcc6a380dcade68cea83c5068d40c1 Mon Sep 17 00:00:00 2001 From: Josh Ng Date: Mon, 11 Nov 2024 15:31:13 +0000 Subject: [PATCH 07/14] ci(pie-storybook): DSW-2468 updated GH deployment name --- .github/workflows/amplify-deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/amplify-deploy.yml b/.github/workflows/amplify-deploy.yml index 79cd8a2c18..b2209182ca 100644 --- a/.github/workflows/amplify-deploy.yml +++ b/.github/workflows/amplify-deploy.yml @@ -70,13 +70,13 @@ jobs: with: script-name: "${{inputs.build-script }} --filter=${{ inputs.package-name }}" # Create Github Deployment - - name: Create Docs GitHub deployment + - name: Create GitHub deployment if: ${{ github.event_name == 'pull_request' }} uses: chrnorm/deployment-action@55729fcebec3d284f60f5bcabbd8376437d696b1 # v2.0.7 id: deploy with: token: ${{ secrets.GITHUB_TOKEN }} - environment: "${{ inputs.package-name}}-pr-${{ github.event.number }}" + environment: "${{ inputs.sub-domain-suffix }}-pr-${{ github.event.number }}" # Zip dist folder - name: Zip build output shell: bash From 028f4ab6eb59e00d1f8fd46d89e0481044e8d7cc Mon Sep 17 00:00:00 2001 From: Josh Ng Date: Mon, 11 Nov 2024 16:16:32 +0000 Subject: [PATCH 08/14] ci(pie-storybook): DSW-2468 closed.yml updated with storybook testing --- .github/workflows/closed.yml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/closed.yml b/.github/workflows/closed.yml index c766f8765d..e5fa83f61e 100644 --- a/.github/workflows/closed.yml +++ b/.github/workflows/closed.yml @@ -12,6 +12,7 @@ jobs: outputs: hasDocsEnv: ${{ steps.list-environments.outputs.hasDocsEnv }} hasStorybookEnv: ${{ steps.list-environments.outputs.hasStorybookEnv }} + hasStorybookTestingEnv: ${{ steps.list-environments.outputs.hasStorybookTestingEnv }} steps: - name: Checkout uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 @@ -36,11 +37,13 @@ jobs: const envList = environments.data.environments.map(env => env.name); // Check for existence of specific environments - const hasDocsEnv = envList.includes(`pie-docs-pr-${pull_number}`); - const hasStorybookEnv = envList.includes(`pie-storybook-pr-${pull_number}`); + const hasDocsEnv = envList.includes(`docs-pr-${pull_number}`); + const hasStorybookEnv = envList.includes(`storybook-pr-${pull_number}`); + cosnt hasStorybookTestingEnv = envList.includes(`storybook-testing-pr-${pull_number}`); core.setOutput('hasDocsEnv', hasDocsEnv); core.setOutput('hasStorybookEnv', hasStorybookEnv); + core.setOutput('hasStorybookTestingEnv', hasStorybookTestingEnv); - name: Delete associated docs environments if: steps.list-environments.outputs.hasDocsEnv == 'true' @@ -52,7 +55,7 @@ jobs: aws-region: 'eu-west-1' aws-access-key-id: ${{ secrets.AWS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - environment-name: pie-docs-pr-${{ github.event.number }} + environment-name: docs-pr-${{ github.event.number }} branch-name: 'pr${{ github.event.number }}' - name: Delete associated storybook environment @@ -65,5 +68,18 @@ jobs: aws-region: 'eu-west-1' aws-access-key-id: ${{ secrets.AWS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - environment-name: pie-storybook-pr-${{ github.event.number }} + environment-name: storybook-pr-${{ github.event.number }} + branch-name: 'pr${{ github.event.number }}' + + - name: Delete associated storybook testing environments + if: steps.list-environments.outputs.hasStorybookTestingEnv == 'true' + uses: ./.github/actions/amplify-teardown + with: + gh-app-id: ${{ secrets.GH_APP_ID }} + gh-app-private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} + amplify-app-id: d3eyargno6okyn + aws-region: 'eu-west-1' + aws-access-key-id: ${{ secrets.AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + environment-name: storybook-testing-pr-${{ github.event.number }} branch-name: 'pr${{ github.event.number }}' \ No newline at end of file From c2bf48551a8d45529bc854937cb13a1e22bc15c1 Mon Sep 17 00:00:00 2001 From: Josh Ng Date: Mon, 11 Nov 2024 16:18:45 +0000 Subject: [PATCH 09/14] fix(pie-monorepo): DSW-2468 fix amplify teardown step --- .github/actions/amplify-teardown/action.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/actions/amplify-teardown/action.yml b/.github/actions/amplify-teardown/action.yml index ecee8b5e13..370ac3ac93 100644 --- a/.github/actions/amplify-teardown/action.yml +++ b/.github/actions/amplify-teardown/action.yml @@ -49,11 +49,10 @@ runs: env: APP_ID: ${{ inputs.amplify-app-id }} BRANCH_NAME: ${{ inputs.branch-name }} + AWS_ACCESS_KEY_ID: ${{ inputs.aws-access-key-id }} + AWS_SECRET_ACCESS_KEY: ${{ inputs.aws-secret-access-key }} + AWS_REGION: ${{ inputs.aws-region }} run: | aws amplify delete-branch \ --app-id "$APP_ID" \ - --branch-name "$BRANCH_NAME" - env: - AWS_ACCESS_KEY_ID: ${{ inputs.aws-access-key-id }} - AWS_SECRET_ACCESS_KEY: ${{ inputs.aws-secret-access-key }} - AWS_REGION: ${{ inputs.aws-region }} \ No newline at end of file + --branch-name "$BRANCH_NAME" \ No newline at end of file From 621f098ec1ceb032c09a2f6fe372a1a9fdb10c71 Mon Sep 17 00:00:00 2001 From: Josh Ng Date: Tue, 12 Nov 2024 11:01:42 +0000 Subject: [PATCH 10/14] ci(pie-monorepo): DSW-2468 added comment for storybook testing deploy step --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3774d2d06d..0adcb0f19a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -196,6 +196,7 @@ jobs: sub-domain-suffix: 'storybook' secrets: inherit + # Workflow task that deploys an instance of storybook used for test suites to run against deploy-storybook-testing: needs: unit-tests if: (needs.check-change-type.outputs.web-components-change == 'true' || needs.check-change-type.outputs.storybook-change == 'true') || github.ref == 'refs/heads/main' From 47aabd7bb4f9034d79773ebbd1e6ab4893549f78 Mon Sep 17 00:00:00 2001 From: Josh Ng Date: Wed, 13 Nov 2024 16:41:25 +0000 Subject: [PATCH 11/14] ci(pie-monorepo): DSW-2468 updated sub-domain-suffix --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0adcb0f19a..af093f963f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -193,7 +193,7 @@ jobs: package-dist-directory: ./apps/pie-storybook/dist bucket-name-preview: 'pie-storybook-preview' bucket-name-main: 'pie-storybook' - sub-domain-suffix: 'storybook' + sub-domain-suffix: 'pie-storybook' secrets: inherit # Workflow task that deploys an instance of storybook used for test suites to run against @@ -209,9 +209,9 @@ jobs: package-dist-directory: ./apps/pie-storybook/dist bucket-name-preview: 'pie-storybook-preview' bucket-name-main: 'pie-storybook' - build-script: 'build:testing' destination-dir: 'testing' - sub-domain-suffix: 'storybook-testing' + build-script: 'build:testing' + sub-domain-suffix: 'pie-storybook-testing' secrets: inherit # TODO: DSW-1151 - Move this into a reusable action so it's not duplicated @@ -282,7 +282,7 @@ jobs: package-dist-directory: ./apps/pie-docs/dist bucket-name-preview: 'pie-docs-preview' bucket-name-main: 'pie-docs' - sub-domain-suffix: 'docs' + sub-domain-suffix: 'pie-docs' secrets: inherit browser-tests-docs: From fe7440e433e85b1767c52187321bda5417c743d5 Mon Sep 17 00:00:00 2001 From: Josh Ng Date: Wed, 13 Nov 2024 17:17:54 +0000 Subject: [PATCH 12/14] revert(pie-monorepo): DSW-2468 revert last commit --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af093f963f..42571e5b7c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -193,7 +193,7 @@ jobs: package-dist-directory: ./apps/pie-storybook/dist bucket-name-preview: 'pie-storybook-preview' bucket-name-main: 'pie-storybook' - sub-domain-suffix: 'pie-storybook' + sub-domain-suffix: 'storybook' secrets: inherit # Workflow task that deploys an instance of storybook used for test suites to run against @@ -211,7 +211,7 @@ jobs: bucket-name-main: 'pie-storybook' destination-dir: 'testing' build-script: 'build:testing' - sub-domain-suffix: 'pie-storybook-testing' + sub-domain-suffix: 'storybook-testing' secrets: inherit # TODO: DSW-1151 - Move this into a reusable action so it's not duplicated @@ -282,7 +282,7 @@ jobs: package-dist-directory: ./apps/pie-docs/dist bucket-name-preview: 'pie-docs-preview' bucket-name-main: 'pie-docs' - sub-domain-suffix: 'pie-docs' + sub-domain-suffix: 'docs' secrets: inherit browser-tests-docs: From b21bfb7b7ed9b50f4fc051d8359cb1d1ecbef8c0 Mon Sep 17 00:00:00 2001 From: Josh Ng Date: Tue, 19 Nov 2024 12:28:14 +0000 Subject: [PATCH 13/14] ci(pie-storybook): DSW-2468 updated storybook turbo.json --- apps/pie-storybook/turbo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/pie-storybook/turbo.json b/apps/pie-storybook/turbo.json index fcb50402ef..95d0a43d1f 100644 --- a/apps/pie-storybook/turbo.json +++ b/apps/pie-storybook/turbo.json @@ -33,6 +33,6 @@ "^generate:component-statuses" ], "outputs": ["dist/**"] - }, + } } -} +} \ No newline at end of file From 95087a86b432a770f89b1d6045dd63172f9b1f94 Mon Sep 17 00:00:00 2001 From: Josh Ng Date: Tue, 19 Nov 2024 14:44:57 +0000 Subject: [PATCH 14/14] Update package.json Co-authored-by: Ben Siggery <14013357+siggerzz@users.noreply.github.com> --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index f1429b6eef..19fe2241fc 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "cz": "./packages/tools/pie-monorepo-utils/git-hooks/check-branch-name.js $(git symbolic-ref --short HEAD) && ./node_modules/cz-customizable/standalone.js", "dev": "turbo run dev --filter=!pie-monorepo", "dev:testing": "turbo run dev:testing --filter=!pie-monorepo", - "copy:component-statuses": "cross-env-shell turbo run copy:component-statuses --filter=!pie-monorepo", "generate:component-statuses": "turbo run generate:component-statuses --filter=!pie-monorepo", "generate:examples": "cross-env-shell turbo run generate:examples --filter=!pie-monorepo --token=${TURBO_TOKEN}", "lint:config:fix": "eslint --fix turbo.json (packages|apps)/**/turbo.json",