Skip to content

Commit

Permalink
build: made VRTs optional as they're not yet working
Browse files Browse the repository at this point in the history
Also cleaned up `bacon.yml` and used `yarn-berry` script.
  • Loading branch information
KevinGhadyani-Okta committed Jul 16, 2024
1 parent 97243f3 commit 7f9c08c
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 96 deletions.
32 changes: 15 additions & 17 deletions .bacon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@ test_suites:
- name: "Code Coverage"
abort_commit_on_failure: true
criteria: OPTIONAL
# Playwright only works with certain distros of Linux
queue_name: ci-queue-prodJenga-Ubuntu20
script_path: /root/okta/odyssey/scripts
queue_name: ci-queue-prodJenga-Ubuntu20 # Playwright only works with certain distros of Linux
script_name: code-coverage
script_path: /root/okta/odyssey/scripts
sort_order: "6"
timeout: "20"

- name: "Interaction Test"
abort_commit_on_failure: true
criteria: MERGE
# Playwright only works with certain distros of Linux
queue_name: ci-queue-prodJenga-Ubuntu20
queue_name: ci-queue-prodJenga-Ubuntu20 # Playwright only works with certain distros of Linux
script_path: /root/okta/odyssey/scripts
script_name: interaction-test
sort_order: "5"
Expand All @@ -51,21 +49,21 @@ test_suites:

- name: "Publish Package"
abort_commit_on_failure: true
criteria: MERGE
queue_name: ci-queue-productionJenga-AL2023
script_name: publish-packages
script_path: /root/okta/odyssey/scripts
sort_order: "8"
timeout: "15"
script_name: publish-package
criteria: MERGE
queue_name: ci-queue-productionJenga-AL2023

- name: "Publish Storybook"
abort_commit_on_failure: true
criteria: MERGE
queue_name: ci-queue-productionJenga-AL2023
script_name: publish-storybook
script_path: /root/okta/odyssey/scripts
sort_order: "9"
timeout: "15"
script_name: publish-storybook-topic
criteria: MERGE
queue_name: ci-queue-productionJenga-AL2023

- name: "Semgrep"
criteria: MERGE
Expand All @@ -77,11 +75,11 @@ test_suites:

- name: "Test"
abort_commit_on_failure: true
script_path: /root/okta/odyssey/scripts
sort_order: "3"
script_name: unit-test
criteria: MERGE
queue_name: ci-queue-productionJenga-AL2023
script_name: unit-test
script_path: /root/okta/odyssey/scripts
sort_order: "3"
timeout: "20"

- name: "Typecheck"
Expand All @@ -101,9 +99,9 @@ test_suites:

- name: "Visual Regression Test"
abort_commit_on_failure: true
criteria: OPTIONAL
queue_name: ci-queue-productionJenga-AL2023
script_name: visual-regression-test
script_path: /root/okta/odyssey/scripts
sort_order: "7"
script_name: visual-regression-test
criteria: MERGE
queue_name: ci-queue-productionJenga-AL2023
timeout: "20"
File renamed without changes.
65 changes: 65 additions & 0 deletions scripts/publish-storybook-temp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash

source $OKTA_HOME/$REPO/scripts/setup.sh

cd $OKTA_HOME/$REPO

PUBLISH_SHA="$(git rev-parse --short $SHA)"
PUBLISH_REGISTRY="${ARTIFACTORY_URL}/api/npm/npm-topic"
CURRENT_VERSION=$(< lerna.json jq -r '.version')
TAGGED_VERSION=$CURRENT_VERSION-$PUBLISH_SHA

npm config set @okta:registry ${PUBLISH_REGISTRY}

function lerna_publish() {
# use lerna to publish without making a commit to the repo
MY_CMD="yarn run lerna publish from-package --force-publish=* --ignore-changes --no-push --no-git-tag-version --no-verify-access --registry \"${PUBLISH_REGISTRY}\" --yes"
echo "Running ${MY_CMD}"
${MY_CMD}
}

# prevent local changes from being reported so lerna can publish
git checkout .

# All packages are built by `prepack`.

# update version with commit SHA to allow lerna to publish
FILES_TO_UPDATE_VERSION="packages/odyssey-storybook/package.json"
for PATH_AND_FILE in $FILES_TO_UPDATE_VERSION; do
FULL_PATH="$OKTA_HOME/$REPO/$PATH_AND_FILE"
json_contents="$(jq '.version = "'$TAGGED_VERSION'"' $FULL_PATH)" && \
echo -E "${json_contents}" > $FULL_PATH
git update-index --assume-unchanged $FULL_PATH
done

echo "Publishing to artifactory"
if ! lerna_publish; then
echo "ERROR: Lerna Publish has failed."
exit $PUBLISH_ARTIFACTORY_FAILURE
else
echo "Publish successful. Sending promotion message"
fi

##
## Publish docs
##
## While the package artifact is already in npm-release, we use this
## promotion event workaround to trigger the conductor workflow to deploy
##

echo "Publish successful. Sending promotion message"

function send_promotion_message() {
curl -H "x-aurm-token: ${AURM_TOKEN}" \
-H "Content-Type: application/json" \
-X POST -d "[{\"artifactId\":\"$1\",\"repository\":\"npm-topic\",\"artifact\":\"$2\",\"version\":\"$3\",\"promotionType\":\"ARTIFACT\"}]" \
-k "${APERTURE_BASE_URL}/v1/artifact-promotion/createPromotionEvent"
}

ARTIFACT="@okta/odyssey-storybook/-/@okta/odyssey-storybook-${CURRENT_VERSION}.tgz"
echo "Artifact is ${ARTIFACT}"
if ! send_promotion_message "odyssey-storybook" "${ARTIFACT}" "${CURRENT_VERSION}"; then
echo "Error sending docs promotion event to Aperture"
fi

exit $SUCCESS
27 changes: 0 additions & 27 deletions scripts/publish-storybook-topic.sh

This file was deleted.

64 changes: 13 additions & 51 deletions scripts/publish-storybook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,24 @@ source $OKTA_HOME/$REPO/scripts/setup.sh

cd $OKTA_HOME/$REPO

PUBLISH_SHA="$(git rev-parse --short $SHA)"
PUBLISH_REGISTRY="${ARTIFACTORY_URL}/api/npm/npm-topic"
CURRENT_VERSION=$(< lerna.json jq -r '.version')
TAGGED_VERSION=$CURRENT_VERSION-$PUBLISH_SHA
get_terminus_secret "/" AWS_ACCESS_KEY_ID AWS_ACCESS_KEY_ID
get_terminus_secret "/" AWS_SECRET_ACCESS_KEY AWS_SECRET_ACCESS_KEY
get_terminus_secret "/" AWS_REGION AWS_REGION

npm config set @okta:registry ${PUBLISH_REGISTRY}
export URL_STORYBOOK="https://${SHA}.ods.dev"
echo $URL_STORYBOOK

function lerna_publish() {
# use lerna to publish without making a commit to the repo
MY_CMD="yarn run lerna publish from-package --force-publish=* --ignore-changes --no-push --no-git-tag-version --no-verify-access --registry \"${PUBLISH_REGISTRY}\" --yes"
echo "Running ${MY_CMD}"
${MY_CMD}
}
# Build all packages except Storybook because it's excluded.
yarn build

# prevent local changes from being reported so lerna can publish
git checkout .
# Build Storybook package.
cd ./packages/odyssey-storybook && rm -rf ./node_modules/.cache && yarn build

# All packages are built by `prepack`.
aws s3 sync ./dist/ s3://ods.dev/$SHA --delete

# update version with commit SHA to allow lerna to publish
FILES_TO_UPDATE_VERSION="packages/odyssey-storybook/package.json"
for PATH_AND_FILE in $FILES_TO_UPDATE_VERSION; do
FULL_PATH="$OKTA_HOME/$REPO/$PATH_AND_FILE"
json_contents="$(jq '.version = "'$TAGGED_VERSION'"' $FULL_PATH)" && \
echo -E "${json_contents}" > $FULL_PATH
git update-index --assume-unchanged $FULL_PATH
done
# bash ./scripts/notify-slack.sh

echo "Publishing to artifactory"
if ! lerna_publish; then
echo "ERROR: Lerna Publish has failed."
exit $PUBLISH_ARTIFACTORY_FAILURE
else
echo "Publish successful. Sending promotion message"
fi

##
## Publish docs
##
## While the package artifact is already in npm-release, we use this
## promotion event workaround to trigger the conductor workflow to deploy
##

echo "Publish successful. Sending promotion message"

function send_promotion_message() {
curl -H "x-aurm-token: ${AURM_TOKEN}" \
-H "Content-Type: application/json" \
-X POST -d "[{\"artifactId\":\"$1\",\"repository\":\"npm-topic\",\"artifact\":\"$2\",\"version\":\"$3\",\"promotionType\":\"ARTIFACT\"}]" \
-k "${APERTURE_BASE_URL}/v1/artifact-promotion/createPromotionEvent"
}

ARTIFACT="@okta/odyssey-storybook/-/@okta/odyssey-storybook-${CURRENT_VERSION}.tgz"
echo "Artifact is ${ARTIFACT}"
if ! send_promotion_message "odyssey-storybook" "${ARTIFACT}" "${CURRENT_VERSION}"; then
echo "Error sending docs promotion event to Aperture"
fi
echo "Publish successful."
log_custom_message "Storybook URL" $URL_STORYBOOK

exit $SUCCESS
2 changes: 1 addition & 1 deletion scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ else
fi

echo "installing yarn v${YARN_VERSION}"
if setup_service yarn ${YARN_VERSION}; then
if setup_service yarn-berry ${YARN_VERSION}; then
echo "Installed yarn ${YARN_VERSION} successfully"
else
echo "Yarn ${YARN_VERSION} installation failed."
Expand Down

0 comments on commit 7f9c08c

Please sign in to comment.