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

DOP-5159 Specify content repo and parser version in build script for Netlify Frontend Builds #1309

Merged
merged 31 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0f6a377
DOP-5159 logging in build script
anabellabuckvar Nov 20, 2024
d7cc504
DOP-5159 logging in build script
anabellabuckvar Nov 20, 2024
90cd72d
DOP-5159 logging in build script
anabellabuckvar Nov 20, 2024
43ae22c
DOP-5159 logging in build script
anabellabuckvar Nov 20, 2024
f64cf26
DOP-5159 logging in build script
anabellabuckvar Nov 20, 2024
b39f5f7
DOP-5159 logging in build script
anabellabuckvar Nov 20, 2024
e9edfb1
DOP-5159 logging in build script
anabellabuckvar Nov 20, 2024
6a5568f
DOP-5159 logging in build script
anabellabuckvar Nov 20, 2024
0cd4396
DOP-5159 logging in build script
anabellabuckvar Nov 20, 2024
118f1d1
DOP-5159 logging in build script
anabellabuckvar Nov 20, 2024
9a221ad
DOP-5159 logging in build script
anabellabuckvar Nov 20, 2024
5751781
DOP-5159 set repo name env var in toml build env
anabellabuckvar Nov 20, 2024
bbcdea8
DOP-5159 set repo name repo name as build.sh argument
anabellabuckvar Nov 20, 2024
6d048ec
DOP-5159 testing precedence of UI env var vs toml env var
anabellabuckvar Nov 20, 2024
a8fac5f
DOP-5159 testing if UI env var is found by toml
anabellabuckvar Nov 20, 2024
38fcf6e
DOP-5159 removing env vars from toml for testing
anabellabuckvar Nov 20, 2024
5f9b2b8
DOP-5159 removing env vars from toml for testing
anabellabuckvar Nov 20, 2024
471bbb3
DOP-5159 add back env vars to toml
anabellabuckvar Nov 20, 2024
caf006d
DOP-5159 all 4 env vars in build command
anabellabuckvar Nov 20, 2024
ec4abd2
DOP-5159 all 4 env vars in build command
anabellabuckvar Nov 20, 2024
24e94ee
DOP-5159 all 4 env vars in build command
anabellabuckvar Nov 20, 2024
af4d17e
DOP-5159 all 4 env vars in build command
anabellabuckvar Nov 20, 2024
9b571ac
DOP-5159 all 4 env vars in build command
anabellabuckvar Nov 20, 2024
fba7e5c
DOP-5159 clone specific branch
anabellabuckvar Nov 20, 2024
57895c3
DOP-5159 update comments
anabellabuckvar Nov 20, 2024
ff36663
DOP-5159 creating docs cpp staging link
anabellabuckvar Nov 21, 2024
a3b1c2b
Update README.md
anabellabuckvar Nov 21, 2024
20ca87b
Update README.md
anabellabuckvar Nov 21, 2024
9f2eccf
DOP-5159 ran prettier and reverted toml to use docs-landing as defaul…
anabellabuckvar Nov 21, 2024
2c6e65e
Merge branch 'main' into DOP-5159
anabellabuckvar Nov 21, 2024
50ff0e7
Merge branch 'main' into DOP-5159
anabellabuckvar Nov 22, 2024
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ coverage/
.vscode/
.env
.swc/
bundle.zip
bundle.zip
# Local Netlify folder
.netlify
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ npm run build:clean:stage

:warning: Note: This will promote the contents of your local public directory. Your instance in staging may break or be outdated if you haven't run `npm run build` before `make stage`.

## Staging with Netlify

When a commit is pushed, this automatically triggers a Netlify build on your branch. For every push, a deploy and deploy preview will be generated.

By default, the master branch of `docs-landing` will be parsed with the parser version specified in the `Netlify.toml` and built using your branch as the frontend. If you'd like to build a different site or branch or build with a different parser version, this can be easily done by just updating the values in the Netlify.toml accordingly. Don't forget to update the `ORG_NAME` to `mongodb` or `10gen` depending on which org your repo belongs to!
seungpark marked this conversation as resolved.
Show resolved Hide resolved

## Releasing

We have configured an automatic release process using [GitHub Actions](https://github.com/features/actions) that is triggered by [npm-version](https://docs.npmjs.com/cli/version). To release a version, you must have admin privileges in this repo. Then proceed as follows:
Expand Down
16 changes: 9 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
# variables that need to be changed based on the content repo you're working on -------------------------------------------
TESTING_CONTENT_REPO=docs-landing # name of content repo
ORGANIZATION=mongodb # name of org, usually mongodb or 10gen
TESTING_ORGANIZATION=$1 # name of org, usually mongodb or 10gen
TESTING_REPO_NAME=$2 # name of content repo
TESTING_BRANCH_NAME=$3 # name of the branch
PARSER_VERSION=$4 # version of the parser to download
Comment on lines +2 to +5
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want to throw an error immediately if any of these are empty/undefined? Or do we want to have a fallback for the PARSER_VERSION and the TESTING_BRANCH_NAME? ie "latest" and "master"

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 for fallback defaults for these

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can set the fallback for these values as environment variables in the UI, or throw an error if they're undefined in the toml. Which do you think is the better way to go @seungpark @mmeigs

Copy link
Collaborator

Choose a reason for hiding this comment

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

i feel like directly in the toml as fallbacks might be good to keep it clear !

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry I'm not clear on what that would look like, would you mind elaborating? How is what you are suggesting different than what is currently in the toml?

Copy link
Collaborator

Choose a reason for hiding this comment

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

sorry, i meant directly in this shell script** but in the toml is fine. in the case we want to deploy multiple previews, is that possible?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm, I believe Netlify only really supports one deploy preview per build, but I'll brainstorm more

# -------------------------------------------------------------------------------------------------------------------------
PARSER_VERSION=0.18.6

# This make command curls the examples for certain repos.
# If the rule doesn't exist, the error doesn't interrupt the build process.
# make examples - we don't need this for docs-landing, but have it here for when we change repos

# cloning the content repo
echo "cloning content repo: ${TESTING_CONTENT_REPO}"
git clone https://github.com/${ORGANIZATION}/${TESTING_CONTENT_REPO}.git
echo "Cloning content repo: ${TESTING_REPO_NAME}"
git clone -b ${TESTING_BRANCH_NAME} https://github.com/${TESTING_ORGANIZATION}/${TESTING_REPO_NAME}.git



# running the parser
if [ ! -d "snooty-parser" ]; then
echo "snooty parser not installed, downloading..."
echo "Snooty parser not installed, downloading parser version $PARSER_VERSION ..."
curl -L -o snooty-parser.zip https://github.com/mongodb/snooty-parser/releases/download/v${PARSER_VERSION}/snooty-v${PARSER_VERSION}-linux_x86_64.zip
unzip -d ./snooty-parser snooty-parser.zip
chmod +x ./snooty-parser/snooty
fi

echo "======================================================================================================================================================================="
echo "========================================================================== Running parser... =========================================================================="
./snooty-parser/snooty/snooty build $(pwd)/${TESTING_CONTENT_REPO} --output=./bundle.zip
./snooty-parser/snooty/snooty build $(pwd)/${TESTING_REPO_NAME} --output=./bundle.zip
echo "========================================================================== Parser complete ============================================================================"
echo "======================================================================================================================================================================="

Expand Down
8 changes: 7 additions & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ name = "snooty-cache-plugin"

[build]
publish = "public"
command = ". ./build.sh"
command = ". ./build.sh $ORG_NAME $REPO_NAME $BRANCH_NAME $PARSER_VERSION"

[build.environment]
ORG_NAME = "mongodb"
Copy link
Collaborator

Choose a reason for hiding this comment

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

are we only testing docs-landing for now, or can we build all content sites with this change right away. Out of curiosity, which ones have we already tested for ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All of them should be able to be built! I've tested landing, docs-cpp, and docs-relational-migrator so far

REPO_NAME = "docs-landing"
BRANCH_NAME = "master"
PARSER_VERSION = "0.18.6"
Loading