From fc2a7b55537269ad3ad717401d196c294b6186e7 Mon Sep 17 00:00:00 2001 From: kathrynlovett Date: Thu, 19 Oct 2023 15:16:03 -0700 Subject: [PATCH 01/11] chore: [CP-603] First attempt at setting up release flow --- .github/workflows/build-push-test.yaml | 51 ++++++++++++++++++++++++++ .github/workflows/create-release.yaml | 34 +++++++++++++++++ .github/workflows/lint-name.yaml | 23 ++++++++++++ .github/workflows/release-build.yaml | 47 ++++++++++++++++++++++++ 4 files changed, 155 insertions(+) create mode 100644 .github/workflows/build-push-test.yaml create mode 100644 .github/workflows/create-release.yaml create mode 100644 .github/workflows/lint-name.yaml create mode 100644 .github/workflows/release-build.yaml diff --git a/.github/workflows/build-push-test.yaml b/.github/workflows/build-push-test.yaml new file mode 100644 index 0000000000..0403b9c78e --- /dev/null +++ b/.github/workflows/build-push-test.yaml @@ -0,0 +1,51 @@ +name: Docker Build Test + +on: + pull_request: + push: + tags: + - 'v*' + +env: + AWS_REGION: "us-west-2" + AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}" + AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" + GITHUB_PAT: "${{ secrets.KIVA_ROBOT_GITHUB_PAT }}" + SLACK_BOT_TOKEN: "${{ secrets.SLACK_TOKEN }}" + SLACK_CHANNEL: "eng-build-failures" + +jobs: + # Test that the image actually builds on each commit + build-push-test: + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + steps: + - name: Checkout + uses: actions/checkout@v3 + - uses: actions/checkout@v3 + with: + repository: kiva/github-actions + token: ${{ env.GITHUB_PAT }} + path: .github/ + - uses: snow-actions/sparse-checkout@v1.2.0 + with: + repository: kiva/marketplace-web-ui-ci + token: ${{ env.GITHUB_PAT }} + path: .docker + ref: ui-static + patterns: | + resources/org/kiva/marketplaceWebUiCi/ui + + - name: move files + run: | + mv .docker/resources/org/kiva/marketplaceWebUiCi/ui/Dockerfile . + cp -aRv .docker/resources/org/kiva/marketplaceWebUiCi/ui/config . + + - name: docker-build + uses: ./.github/actions/docker-build-push + if: github.event_name == 'pull_request' + with: + build_args: | + TARGET_ENV=dev + dockerfile_target: "release" + push: false diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml new file mode 100644 index 0000000000..f5794042a5 --- /dev/null +++ b/.github/workflows/create-release.yaml @@ -0,0 +1,34 @@ +name: create-release + +on: + workflow_dispatch: + inputs: + environment: + type: choice + description: 'Environment to release to (staging or production)' + options: + - staging + - production + required: true + +jobs: + create-release: + runs-on: ubuntu-latest + steps: + - name: checkout-repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + - name: checkout-actions + uses: actions/checkout@v4 + with: + repository: kiva/github-actions + token: ${{ secrets.KIVA_ROBOT_GITHUB_PAT }} + path: .github/ + - name: create-release + uses: ./.github/actions/create-release + env: + GITHUB_PAT: ${{ secrets.KIVA_ROBOT_GITHUB_PAT }} + with: + environment: ${{ github.event.inputs.environment }} diff --git a/.github/workflows/lint-name.yaml b/.github/workflows/lint-name.yaml new file mode 100644 index 0000000000..6b06136c2b --- /dev/null +++ b/.github/workflows/lint-name.yaml @@ -0,0 +1,23 @@ +name: Lint PR (semantic title) + +on: + pull_request: + types: + - opened + - synchronize + - edited + +jobs: + lint-title: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/checkout@v3 + with: + repository: kiva/github-actions + token: ${{ secrets.KIVA_ROBOT_GITHUB_PAT }} + path: .github/ + - name: lint-pr + uses: ./.github/actions/lint-pr + env: + GITHUB_PAT: ${{ secrets.KIVA_ROBOT_GITHUB_PAT }} diff --git a/.github/workflows/release-build.yaml b/.github/workflows/release-build.yaml new file mode 100644 index 0000000000..6b51c0fdca --- /dev/null +++ b/.github/workflows/release-build.yaml @@ -0,0 +1,47 @@ +name: Docker Build Publish + +on: + release: + types: [published] + push: + branches: + - main + +env: + GITHUB_PAT: "${{ secrets.KIVA_ROBOT_GITHUB_PAT }}" + AWS_REGION: "us-west-2" + AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}" + AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" + SLACK_BOT_TOKEN: "${{ secrets.SLACK_TOKEN }}" + SLACK_CHANNEL: "eng-build-failures" + +jobs: + # Build and push the image to ECR + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Checkout actions + uses: actions/checkout@v3 + with: + repository: kiva/github-actions + token: ${{ env.GITHUB_PAT }} + path: .github/ + - uses: snow-actions/sparse-checkout@v1.2.0 + with: + repository: kiva/marketplace-web-ui-ci + token: ${{ env.GITHUB_PAT }} + path: .docker + patterns: | + resources/org/kiva/marketplaceWebUiCi/ui + - name: move files + run: | + mv .docker/resources/org/kiva/marketplaceWebUiCi/ui/Dockerfile . + cp -aRv .docker/resources/org/kiva/marketplaceWebUiCi/ui/config . + - name: docker-push + uses: ./.github/actions/docker-build-push + with: + dockerfile_target: "release" + push: true From c6f1e24f53bf13a0fcfe1ab1406b28e6051e3b36 Mon Sep 17 00:00:00 2001 From: kathrynlovett Date: Thu, 19 Oct 2023 15:17:39 -0700 Subject: [PATCH 02/11] chore: [CP-603] Indentation --- .github/workflows/release-build.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-build.yaml b/.github/workflows/release-build.yaml index 6b51c0fdca..694a40f1db 100644 --- a/.github/workflows/release-build.yaml +++ b/.github/workflows/release-build.yaml @@ -41,7 +41,7 @@ jobs: mv .docker/resources/org/kiva/marketplaceWebUiCi/ui/Dockerfile . cp -aRv .docker/resources/org/kiva/marketplaceWebUiCi/ui/config . - name: docker-push - uses: ./.github/actions/docker-build-push - with: - dockerfile_target: "release" - push: true + uses: ./.github/actions/docker-build-push + with: + dockerfile_target: "release" + push: true From 0ced93180fe76263547ddac303296408a6ca0314 Mon Sep 17 00:00:00 2001 From: kathrynlovett Date: Thu, 19 Oct 2023 15:21:09 -0700 Subject: [PATCH 03/11] chore: [CP-603] pass token --- .github/workflows/build-push-test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-push-test.yaml b/.github/workflows/build-push-test.yaml index 0403b9c78e..e2037ace01 100644 --- a/.github/workflows/build-push-test.yaml +++ b/.github/workflows/build-push-test.yaml @@ -22,6 +22,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + token: ${{ env.GITHUB_PAT }} - uses: actions/checkout@v3 with: repository: kiva/github-actions From 24fb2ff3e3cc30b566c59322e42d7bbc801d8715 Mon Sep 17 00:00:00 2001 From: kathrynlovett Date: Fri, 20 Oct 2023 10:43:10 -0700 Subject: [PATCH 04/11] chore: [CP-603] Use main branch on marketplace ui repo --- .github/workflows/build-push-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-push-test.yaml b/.github/workflows/build-push-test.yaml index e2037ace01..49cd758b94 100644 --- a/.github/workflows/build-push-test.yaml +++ b/.github/workflows/build-push-test.yaml @@ -34,7 +34,7 @@ jobs: repository: kiva/marketplace-web-ui-ci token: ${{ env.GITHUB_PAT }} path: .docker - ref: ui-static + ref: main patterns: | resources/org/kiva/marketplaceWebUiCi/ui From 6a6afd283a057dabb5121a8227cb7fb6219052fc Mon Sep 17 00:00:00 2001 From: kathrynlovett Date: Fri, 20 Oct 2023 10:47:59 -0700 Subject: [PATCH 05/11] chore: [CP-603] UI doesn't have config here --- .github/workflows/build-push-test.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-push-test.yaml b/.github/workflows/build-push-test.yaml index 49cd758b94..afe5f03e05 100644 --- a/.github/workflows/build-push-test.yaml +++ b/.github/workflows/build-push-test.yaml @@ -41,7 +41,6 @@ jobs: - name: move files run: | mv .docker/resources/org/kiva/marketplaceWebUiCi/ui/Dockerfile . - cp -aRv .docker/resources/org/kiva/marketplaceWebUiCi/ui/config . - name: docker-build uses: ./.github/actions/docker-build-push From 06e8409cdf3d9aac46acef3ba4fc5d5447fa3e25 Mon Sep 17 00:00:00 2001 From: kathrynlovett Date: Mon, 23 Oct 2023 11:45:20 -0700 Subject: [PATCH 06/11] chore: [CP-603] Consolidate to a single build file and copy over Dockerfile --- .github/workflows/build-push-test.yaml | 52 ----------- .github/workflows/release-build.yaml | 11 --- Dockerfile | 114 +++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 63 deletions(-) delete mode 100644 .github/workflows/build-push-test.yaml create mode 100644 Dockerfile diff --git a/.github/workflows/build-push-test.yaml b/.github/workflows/build-push-test.yaml deleted file mode 100644 index afe5f03e05..0000000000 --- a/.github/workflows/build-push-test.yaml +++ /dev/null @@ -1,52 +0,0 @@ -name: Docker Build Test - -on: - pull_request: - push: - tags: - - 'v*' - -env: - AWS_REGION: "us-west-2" - AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}" - AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" - GITHUB_PAT: "${{ secrets.KIVA_ROBOT_GITHUB_PAT }}" - SLACK_BOT_TOKEN: "${{ secrets.SLACK_TOKEN }}" - SLACK_CHANNEL: "eng-build-failures" - -jobs: - # Test that the image actually builds on each commit - build-push-test: - runs-on: ubuntu-latest - if: github.event_name == 'pull_request' - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - token: ${{ env.GITHUB_PAT }} - - uses: actions/checkout@v3 - with: - repository: kiva/github-actions - token: ${{ env.GITHUB_PAT }} - path: .github/ - - uses: snow-actions/sparse-checkout@v1.2.0 - with: - repository: kiva/marketplace-web-ui-ci - token: ${{ env.GITHUB_PAT }} - path: .docker - ref: main - patterns: | - resources/org/kiva/marketplaceWebUiCi/ui - - - name: move files - run: | - mv .docker/resources/org/kiva/marketplaceWebUiCi/ui/Dockerfile . - - - name: docker-build - uses: ./.github/actions/docker-build-push - if: github.event_name == 'pull_request' - with: - build_args: | - TARGET_ENV=dev - dockerfile_target: "release" - push: false diff --git a/.github/workflows/release-build.yaml b/.github/workflows/release-build.yaml index 694a40f1db..fc3901490d 100644 --- a/.github/workflows/release-build.yaml +++ b/.github/workflows/release-build.yaml @@ -29,17 +29,6 @@ jobs: repository: kiva/github-actions token: ${{ env.GITHUB_PAT }} path: .github/ - - uses: snow-actions/sparse-checkout@v1.2.0 - with: - repository: kiva/marketplace-web-ui-ci - token: ${{ env.GITHUB_PAT }} - path: .docker - patterns: | - resources/org/kiva/marketplaceWebUiCi/ui - - name: move files - run: | - mv .docker/resources/org/kiva/marketplaceWebUiCi/ui/Dockerfile . - cp -aRv .docker/resources/org/kiva/marketplaceWebUiCi/ui/config . - name: docker-push uses: ./.github/actions/docker-build-push with: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..b28165ca18 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,114 @@ +## Base stage with system dependencies and working directory +FROM node:16.15.0-alpine as base +RUN apk add --no-cache git +RUN apk add --no-cache bash +RUN apk add --no-cache tini +RUN apk add --no-cache make gcc g++ python2 pkgconfig pixman-dev cairo-dev pango-dev libjpeg-turbo-dev giflib-dev +# Change working directory +RUN mkdir /ui +WORKDIR /ui +# Use Tini for entrypoint, available at /sbin/tini +ENTRYPOINT ["/sbin/tini", "--"] + + +## Dev stage with all node modules installed +FROM base as dev-dependencies +# Copy only package files so that changes to other files don't cause this step to be repeated +COPY package.json package-lock.json /ui/ +# Install all dependencies +RUN HUSKY=0 npm ci + + +## Unit test stage +FROM dev-dependencies as unit-test +# Copy only files needed for unit testing +COPY babel.config.js /ui/ +COPY __mocks__ /ui/__mocks__ +COPY config /ui/config +COPY test/unit /ui/test/unit +COPY server /ui/server +COPY src /ui/src +# Run unit tests +RUN npm run unit + + +## Build stage +FROM dev-dependencies as build +# Copy only files needed for building +COPY babel.config.js tailwind.config.js tailwind.purge.safelist.txt /ui/ +COPY build /ui/build +COPY config /ui/config +# Copy source files from the unit-test step to ensure the unit tests pass before building +COPY --from=unit-test /ui/src /ui/src +# Copy git directory because the build process needs to know the current git revision +COPY .git /ui/.git +# Build app +RUN npm run build +# Remove development dependencies +RUN npm prune --production && rm -rf node_modules/.cache + + +## Static assets for kiva origins export stage +FROM scratch as export-kiva-origins +COPY --from=build /ui/dist/static/binary ./static/binary +COPY --from=build /ui/dist/static/css ./static/css +COPY --from=build /ui/dist/static/img ./static/img +COPY --from=build /ui/dist/static/js ./static/js +COPY --from=build /ui/dist/static/manifest ./static/manifest +COPY --from=build /ui/dist/static/media ./static/media +COPY --from=build /ui/dist/static/wasm ./static/wasm +COPY --from=build /ui/dist/static/icons.*.svg ./static/ + +## Static assets for all origins export stage +FROM scratch as export-all-origins +COPY --from=build /ui/dist/static/fonts ./static/fonts + + +## End-to-end test stage based on cypress pre-built image +# For updates to the base image, look at https://github.com/cypress-io/cypress-docker-images/tree/master/included +FROM cypress/included:10.11.0 as e2e-test +# Only use basic text for reporting to stdout +ENV NO_COLOR=1 +# Base image has npm 6, so for project dependencies to run correctly we need to manually upgrade to npm 7 +RUN npm install -g npm@7 +# Create directory for test code +RUN mkdir /e2e +WORKDIR /e2e +# Copy project dependencies +COPY --from=dev-dependencies /ui/ /e2e/ +# Copy test code into the image +COPY cypress.config.js reporter-config.json /e2e/ +COPY test/e2e /e2e/test/e2e + + +## Performance test stage +FROM dev-dependencies as performance-test +# Install chromium +RUN apk add --no-cache chromium +# Install lighthouse ci cli +RUN npm install -g @lhci/cli@0.9.x +# Copy git directory because the upload process needs to know the current git revision +COPY .git /ui/.git +# Copy server code into the image +COPY lighthouserc-dev.js /ui/ +COPY config /ui/config +COPY server /ui/server +COPY src /ui/src +COPY --from=build /ui/dist /ui/dist + + +## Release stage +FROM base as release +# Copy app files +COPY config /ui/config +COPY server /ui/server +COPY src /ui/src +COPY --from=build /ui/node_modules /ui/node_modules +COPY --from=build /ui/dist /ui/dist +# TODO: replace line above with line below to eliminate static assets from final image +# COPY --from=build /ui/dist/vue-ssr-server-bundle.json /ui/dist/vue-ssr-client-manifest.json /ui/dist/ +# Expose server port to the outside +EXPOSE 8888 +# Launch application using tini +# NOTE: Uses default Production config and is overridden when starting K8s pods +CMD [ "npm", "start-k8s" ] From c45c549851e31ddb59ac16b9a9104b4e521e66be Mon Sep 17 00:00:00 2001 From: kathrynlovett Date: Tue, 24 Oct 2023 09:43:53 -0700 Subject: [PATCH 07/11] chore: [CP-603] add test build on PR back to workflow --- .github/workflows/release-build.yaml | 35 +++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-build.yaml b/.github/workflows/release-build.yaml index fc3901490d..6746b4d79e 100644 --- a/.github/workflows/release-build.yaml +++ b/.github/workflows/release-build.yaml @@ -1,11 +1,13 @@ name: Docker Build Publish on: - release: - types: [published] + pull_request: push: branches: - main + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + - 'v[0-9]+.[0-9]+.[0-9]+-rc*' env: GITHUB_PAT: "${{ secrets.KIVA_ROBOT_GITHUB_PAT }}" @@ -16,10 +18,37 @@ env: SLACK_CHANNEL: "eng-build-failures" jobs: + test-build: + concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + env: + AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}" + AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" + steps: + - name: Checkout + uses: actions/checkout@v3 + - uses: actions/checkout@v3 + with: + repository: kiva/github-actions + token: ${{ env.GITHUB_PAT }} + path: .github/ + - uses: webfactory/ssh-agent@v0.7.0 + with: + ssh-private-key: ${{ secrets.KIVA_ROBOT_SSH_PRIVATE_KEY }} + - name: docker-build + uses: ./.github/actions/docker-build-push + if: github.event_name == 'pull_request' + with: + push: false + ssh: "github=${{ env.SSH_AUTH_SOCK }}" # Build and push the image to ECR build: runs-on: ubuntu-latest - + # Run on merges to development or tag pushes (done by create-release workflow) + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags') steps: - name: Checkout uses: actions/checkout@v3 From d53c57507b578faad91d0f3ff41fd74a053edafa Mon Sep 17 00:00:00 2001 From: kathrynlovett Date: Tue, 24 Oct 2023 09:51:25 -0700 Subject: [PATCH 08/11] chore: [CP-603] Remove unneeded step --- .github/workflows/release-build.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/release-build.yaml b/.github/workflows/release-build.yaml index 6746b4d79e..8e671ec1f0 100644 --- a/.github/workflows/release-build.yaml +++ b/.github/workflows/release-build.yaml @@ -35,15 +35,11 @@ jobs: repository: kiva/github-actions token: ${{ env.GITHUB_PAT }} path: .github/ - - uses: webfactory/ssh-agent@v0.7.0 - with: - ssh-private-key: ${{ secrets.KIVA_ROBOT_SSH_PRIVATE_KEY }} - name: docker-build uses: ./.github/actions/docker-build-push if: github.event_name == 'pull_request' with: push: false - ssh: "github=${{ env.SSH_AUTH_SOCK }}" # Build and push the image to ECR build: runs-on: ubuntu-latest From 39503c862318987d91c5702ba6d4b4a91fbd26d7 Mon Sep 17 00:00:00 2001 From: kathrynlovett Date: Tue, 24 Oct 2023 10:14:33 -0700 Subject: [PATCH 09/11] chore: [CP-603] add target for test build --- .github/workflows/release-build.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release-build.yaml b/.github/workflows/release-build.yaml index 8e671ec1f0..e831416a7c 100644 --- a/.github/workflows/release-build.yaml +++ b/.github/workflows/release-build.yaml @@ -39,6 +39,7 @@ jobs: uses: ./.github/actions/docker-build-push if: github.event_name == 'pull_request' with: + dockerfile_target: "release" push: false # Build and push the image to ECR build: From 03a1ab06389e09947ad28f5158505dd6cacb8fe0 Mon Sep 17 00:00:00 2001 From: kathrynlovett Date: Tue, 24 Oct 2023 11:15:40 -0700 Subject: [PATCH 10/11] chore: [CP-603] Remove dockerfile and copy from marketplace repo --- .github/workflows/release-build.yaml | 22 ++++++ Dockerfile | 114 --------------------------- 2 files changed, 22 insertions(+), 114 deletions(-) delete mode 100644 Dockerfile diff --git a/.github/workflows/release-build.yaml b/.github/workflows/release-build.yaml index e831416a7c..43ed3d3e96 100644 --- a/.github/workflows/release-build.yaml +++ b/.github/workflows/release-build.yaml @@ -35,6 +35,17 @@ jobs: repository: kiva/github-actions token: ${{ env.GITHUB_PAT }} path: .github/ + - uses: snow-actions/sparse-checkout@v1.2.0 + with: + repository: kiva/marketplace-web-ui-ci + token: ${{ env.GITHUB_PAT }} + path: .docker + ref: main + patterns: | + resources/org/kiva/marketplaceWebUiCi/ui + - name: move files + run: | + mv .docker/resources/org/kiva/marketplaceWebUiCi/ui/Dockerfile . - name: docker-build uses: ./.github/actions/docker-build-push if: github.event_name == 'pull_request' @@ -55,6 +66,17 @@ jobs: repository: kiva/github-actions token: ${{ env.GITHUB_PAT }} path: .github/ + - uses: snow-actions/sparse-checkout@v1.2.0 + with: + repository: kiva/marketplace-web-ui-ci + token: ${{ env.GITHUB_PAT }} + path: .docker + ref: main + patterns: | + resources/org/kiva/marketplaceWebUiCi/ui + - name: move files + run: | + mv .docker/resources/org/kiva/marketplaceWebUiCi/ui/Dockerfile . - name: docker-push uses: ./.github/actions/docker-build-push with: diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index b28165ca18..0000000000 --- a/Dockerfile +++ /dev/null @@ -1,114 +0,0 @@ -## Base stage with system dependencies and working directory -FROM node:16.15.0-alpine as base -RUN apk add --no-cache git -RUN apk add --no-cache bash -RUN apk add --no-cache tini -RUN apk add --no-cache make gcc g++ python2 pkgconfig pixman-dev cairo-dev pango-dev libjpeg-turbo-dev giflib-dev -# Change working directory -RUN mkdir /ui -WORKDIR /ui -# Use Tini for entrypoint, available at /sbin/tini -ENTRYPOINT ["/sbin/tini", "--"] - - -## Dev stage with all node modules installed -FROM base as dev-dependencies -# Copy only package files so that changes to other files don't cause this step to be repeated -COPY package.json package-lock.json /ui/ -# Install all dependencies -RUN HUSKY=0 npm ci - - -## Unit test stage -FROM dev-dependencies as unit-test -# Copy only files needed for unit testing -COPY babel.config.js /ui/ -COPY __mocks__ /ui/__mocks__ -COPY config /ui/config -COPY test/unit /ui/test/unit -COPY server /ui/server -COPY src /ui/src -# Run unit tests -RUN npm run unit - - -## Build stage -FROM dev-dependencies as build -# Copy only files needed for building -COPY babel.config.js tailwind.config.js tailwind.purge.safelist.txt /ui/ -COPY build /ui/build -COPY config /ui/config -# Copy source files from the unit-test step to ensure the unit tests pass before building -COPY --from=unit-test /ui/src /ui/src -# Copy git directory because the build process needs to know the current git revision -COPY .git /ui/.git -# Build app -RUN npm run build -# Remove development dependencies -RUN npm prune --production && rm -rf node_modules/.cache - - -## Static assets for kiva origins export stage -FROM scratch as export-kiva-origins -COPY --from=build /ui/dist/static/binary ./static/binary -COPY --from=build /ui/dist/static/css ./static/css -COPY --from=build /ui/dist/static/img ./static/img -COPY --from=build /ui/dist/static/js ./static/js -COPY --from=build /ui/dist/static/manifest ./static/manifest -COPY --from=build /ui/dist/static/media ./static/media -COPY --from=build /ui/dist/static/wasm ./static/wasm -COPY --from=build /ui/dist/static/icons.*.svg ./static/ - -## Static assets for all origins export stage -FROM scratch as export-all-origins -COPY --from=build /ui/dist/static/fonts ./static/fonts - - -## End-to-end test stage based on cypress pre-built image -# For updates to the base image, look at https://github.com/cypress-io/cypress-docker-images/tree/master/included -FROM cypress/included:10.11.0 as e2e-test -# Only use basic text for reporting to stdout -ENV NO_COLOR=1 -# Base image has npm 6, so for project dependencies to run correctly we need to manually upgrade to npm 7 -RUN npm install -g npm@7 -# Create directory for test code -RUN mkdir /e2e -WORKDIR /e2e -# Copy project dependencies -COPY --from=dev-dependencies /ui/ /e2e/ -# Copy test code into the image -COPY cypress.config.js reporter-config.json /e2e/ -COPY test/e2e /e2e/test/e2e - - -## Performance test stage -FROM dev-dependencies as performance-test -# Install chromium -RUN apk add --no-cache chromium -# Install lighthouse ci cli -RUN npm install -g @lhci/cli@0.9.x -# Copy git directory because the upload process needs to know the current git revision -COPY .git /ui/.git -# Copy server code into the image -COPY lighthouserc-dev.js /ui/ -COPY config /ui/config -COPY server /ui/server -COPY src /ui/src -COPY --from=build /ui/dist /ui/dist - - -## Release stage -FROM base as release -# Copy app files -COPY config /ui/config -COPY server /ui/server -COPY src /ui/src -COPY --from=build /ui/node_modules /ui/node_modules -COPY --from=build /ui/dist /ui/dist -# TODO: replace line above with line below to eliminate static assets from final image -# COPY --from=build /ui/dist/vue-ssr-server-bundle.json /ui/dist/vue-ssr-client-manifest.json /ui/dist/ -# Expose server port to the outside -EXPOSE 8888 -# Launch application using tini -# NOTE: Uses default Production config and is overridden when starting K8s pods -CMD [ "npm", "start-k8s" ] From 7fa4da0dcd1168f2ad8038656d7789d7c95bc26c Mon Sep 17 00:00:00 2001 From: kathrynlovett Date: Thu, 26 Oct 2023 13:23:21 -0700 Subject: [PATCH 11/11] chore: [CP-603] Write changelog and update package file --- .github/workflows/create-release.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index f5794042a5..bb22107016 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -27,8 +27,16 @@ jobs: token: ${{ secrets.KIVA_ROBOT_GITHUB_PAT }} path: .github/ - name: create-release + id: release uses: ./.github/actions/create-release env: GITHUB_PAT: ${{ secrets.KIVA_ROBOT_GITHUB_PAT }} with: environment: ${{ github.event.inputs.environment }} + write_to_file: "true" + - name: update-package-file + uses: ./.github/actions/semantic-package-json-update + env: + GITHUB_PAT: ${{ secrets.KIVA_ROBOT_GITHUB_PAT }} + with: + new_version: ${{ steps.release.outputs.tag }}