Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
davidejones committed Jun 8, 2022
1 parent 5c6c4fd commit 9e912ba
Show file tree
Hide file tree
Showing 10 changed files with 11,936 additions and 8,501 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.yarn/releases/** binary
/.yarn/plugins/** binary
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,14 @@ static/images/integrations_logos/2020w2.pdf
# Generated resources from Hugo Pipes
resources/_gen/
static/jsconfig.json

# yarn v2 or greater
# Not using zero installs
# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
85 changes: 41 additions & 44 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ variables:
# gitlab checkout
DOCS_REPO_NAME: documentation
REPO_URL: "https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/${DOCS_REPO_NAME}.git"
# yarn/node cache dirs
YARN_CACHE_FOLDER: "${CI_PROJECT_DIR}/.yarn/cache/"

# ================== copy scripts =============== #
before_script:
Expand All @@ -27,11 +29,27 @@ before_script:
- "[ -f /etc/profile ] && source /etc/profile" # for golang on path
- mkdir -p logs

cache: &cache
key: $CI_COMMIT_REF_SLUG-$CI_PROJECT_DIR
paths:
- node_modules/
- tmp/.htmltest/
# set policy for the common case
# yarn cache is used in a lot but only built during build job so lets default to pull and explicit push in build job
.yarn_cache: &yarn_cache
- key:
files:
- yarn.lock
paths:
- package.json
- yarn.lock
- ${YARN_CACHE_FOLDER}
policy: pull

.yarn_cache_pull_push: &yarn_cache_pull_push
- key:
files:
- yarn.lock
paths:
- package.json
- yarn.lock
- ${YARN_CACHE_FOLDER}
policy: pull-push

# ================== templates ================== #
.base_template: &base_template
Expand All @@ -43,35 +61,13 @@ cache: &cache
only:
- branches

# ================== Install Node Dependencies ================== #
install_dependencies:
<<: *base_template
stage: bootstrap
cache:
<<: *cache
variables:
GIT_STRATEGY: none
script:
- git version
- git clone --branch $CI_COMMIT_REF_NAME --depth 1 --filter=blob:none --no-checkout $REPO_URL sparse-docs
- cd sparse-docs && git sparse-checkout init --cone && git sparse-checkout set local && git checkout $CI_COMMIT_REF_NAME && cd ..
- mkdir -p ./local/bin/sh && cp --remove-destination ./sparse-docs/local/bin/sh/preinstall.sh ./local/bin/sh/preinstall.sh
- cp --remove-destination ./sparse-docs/package.json ./package.json
- cp --remove-destination ./sparse-docs/yarn.lock ./yarn.lock
- yarn install --link-duplicates --frozen-lockfile --cache-folder .yarn
- rm -rf ./sparse-docs # cleanup runner
only:
changes:
- yarn.lock

# ================== preview ================== #
# If the branch has a name of <slack-user>/<feature-name> then ci builds a preview site
build_preview:
<<: *base_template
stage: build
cache:
<<: *cache
policy: pull
- *yarn_cache_pull_push
environment: "preview"
variables:
URL: ${PREVIEW_DOMAIN}
Expand All @@ -81,6 +77,7 @@ build_preview:
LOCAL: "False"
script:
- post_dd_event "documentation deploy ${CI_COMMIT_REF_NAME} started" "${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}" "info"
- yarn install --immutable
- touch Makefile.config
- make BRANCH=${CI_COMMIT_REF_NAME} examples
- sync_integration_descriptions
Expand Down Expand Up @@ -156,11 +153,11 @@ index_algolia_preview:
tags: ["runner:main"]
stage: post-deploy
cache:
<<: *cache
policy: pull
- *yarn_cache
environment: "preview"
timeout: 1h 30m
script:
- yarn install --immutable
- |-
echo APPLICATION_ID=$(get_secret 'ci.documentation.algolia_preview_application_id') > .env
echo API_KEY=$(get_secret 'ci.documentation.algolia_preview_api_key') >> .env
Expand All @@ -178,10 +175,10 @@ replica_algolia_preview:
<<: *base_template
stage: post-deploy
cache:
<<: *cache
policy: pull
- *yarn_cache
environment: "preview"
script:
- yarn install --immutable
- ALGOLIA_APP_ID=$(get_secret 'algolia_preview_application_id') ALGOLIA_ADMIN_KEY=$(get_secret 'algolia_preview_api_key') yarn run algolia:config
dependencies:
- build_preview
Expand All @@ -194,10 +191,10 @@ sourcemaps_preview:
<<: *base_template
stage: post-deploy
cache:
<<: *cache
policy: pull
- *yarn_cache
environment: "preview"
script:
- yarn install --immutable
# Rename any js.map files to include SHA if correlating JS file is fingerprinted. Hugo's asset build system seems to lose the fingerprint value when generating source maps.
- find ./public -type f -name "*.*.js" -exec bash -c 'x={}; hash=$(basename $x | cut -d '.' -f 2); map=${x/$hash./}.map; mv $map ${map/.js/.$hash.js}' \;
- DATADOG_API_KEY="$(get_secret 'dd-api-key')" ./node_modules/.bin/datadog-ci sourcemaps upload ./public/static --service docs --minified-path-prefix "https://docs-staging.datadoghq.com/${CI_COMMIT_REF_NAME}/static/" --release-version "${CI_COMMIT_SHORT_SHA}"
Expand All @@ -213,8 +210,7 @@ build_live:
<<: *base_template
stage: build
cache:
<<: *cache
policy: pull
- *yarn_cache_pull_push
environment: "live"
variables:
CONFIG: ${LIVE_CONFIG}
Expand All @@ -225,6 +221,7 @@ build_live:
script:
- post_dd_event "documentation deploy ${CI_COMMIT_REF_NAME} started" "${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}" "info"
- notify_slack "<https://github.com/DataDog/documentation/commit/${CI_COMMIT_SHA}|${CI_COMMIT_SHA:0:8}> sent to gitlab for production deployment. <${CI_PROJECT_URL}/pipelines/${CI_PIPELINE_ID}|details>" "#FFD700"
- yarn install --immutable
- touch Makefile.config
- make clean-examples
- make examples
Expand Down Expand Up @@ -295,11 +292,11 @@ index_algolia:
tags: ["runner:main"]
stage: post-deploy
cache:
<<: *cache
policy: pull
- *yarn_cache
environment: "live"
timeout: 1h 30m
script:
- yarn install --immutable
- |-
echo APPLICATION_ID=$(get_secret 'ci.documentation.algolia_docsearch_application_id') > .env
echo API_KEY=$(get_secret 'ci.documentation.algolia_docsearch_api_key') >> .env
Expand All @@ -315,10 +312,10 @@ replica_algolia:
<<: *base_template
stage: post-deploy
cache:
<<: *cache
policy: pull
- *yarn_cache
environment: "live"
script:
- yarn install --immutable
- ALGOLIA_APP_ID=$(get_secret 'algolia_docsearch_application_id') ALGOLIA_ADMIN_KEY=$(get_secret 'algolia_docsearch_api_key') yarn run algolia:config
dependencies:
- build_live
Expand All @@ -329,10 +326,10 @@ sourcemaps_live:
<<: *base_template
stage: post-deploy
cache:
<<: *cache
policy: pull
- *yarn_cache
environment: "live"
script:
- yarn install --immutable
# Rename any js.map files to include SHA if correlating JS file is fingerprinted. Hugo's asset build system seems to lose the fingerprint value when generating source maps.
- find ./public -type f -name "*.*.js" -exec bash -c 'x={}; hash=$(basename $x | cut -d '.' -f 2); map=${x/$hash./}.map; mv $map ${map/.js/.$hash.js}' \;
- DATADOG_API_KEY="$(get_secret 'dd-api-key')" ./node_modules/.bin/datadog-ci sourcemaps upload ./public/static --service docs --minified-path-prefix "https://docs.datadoghq.com/static/" --release-version "${CI_COMMIT_SHORT_SHA}"
Expand Down Expand Up @@ -412,12 +409,12 @@ test_pa11y:
<<: *base_template
stage: post-deploy
cache:
<<: *cache
policy: pull
- *yarn_cache
environment: "live"
dependencies:
- build_live
script:
- yarn install --immutable
- node ./local/bin/js/pa11y.js --env live --dd_api_key $(get_secret 'dd-api-key')
only:
- schedules
Expand Down
786 changes: 786 additions & 0 deletions .yarn/releases/yarn-3.2.1.cjs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-3.2.1.cjs
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Built with [hugo][1], a static website generation tool.

### Installation

1. [Install node / npm][2]
1. [Install node / npm][2] (node `>=14.16.0`)

2. [Install Python3][3] (you can also use [pyenv][4])

Expand Down
3 changes: 2 additions & 1 deletion local/bin/sh/run-site-no-pre-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ if [ ${RUN_SERVER} = true ]; then
# Building the documentation
printf "checking that node modules are installed and up-to-date"
npm --global install yarn && \
npm cache clean --force && yarn install --frozen-lockfile
npm cache clean --force && yarn install --immutable
printf "starting webpack and hugo build"
yarn run prestart
yarn run start

sleep 5
Expand Down
5 changes: 3 additions & 2 deletions local/bin/sh/run-site.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if [ ${RUN_SERVER} = true ]; then

update_pre_build.py "${args}"

# rbac permissions
# rbac permissions
if [ ${PULL_RBAC_PERMISSIONS} == true ]; then
echo "Pulling RBAC permissions."

Expand All @@ -37,8 +37,9 @@ if [ ${RUN_SERVER} = true ]; then

echo "Checking that node modules are installed and up-to-date."
npm --global install yarn && \
npm cache clean --force && yarn install --frozen-lockfile
npm cache clean --force && yarn install --immutable
echo "Starting webpack and hugo build."
yarn run prestart
yarn run start

sleep 5
Expand Down
26 changes: 9 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
"algolia:config": "node ./local/bin/js/algolia-config.js",
"preinstall": "bash local/bin/sh/preinstall.sh",
"prestart": "rimraf public && npx hugo mod clean",
"start": "run-p start:**",
"start:hugo": "./node_modules/.bin/hugo server -D -d ./public -s ./ --port 1313 --navigateToChanged --noHTTPCache",
"start": "./node_modules/.bin/hugo server -D -d ./public -s ./ --port 1313 --navigateToChanged --noHTTPCache",
"prebuild": "rimraf public && npx hugo mod clean",
"build": "run-s build:hugo",
"build": "yarn run prebuild && yarn run build:hugo",
"build:preview": "yarn run build:hugo:preview",
"build:hugo": "./node_modules/.bin/hugo -d ./public -s ./ -v --minify",
"build:hugo:preview": "yarn run build:hugo -- -D -F --environment preview",
"build:hugo:live": "yarn run build:hugo -- -D -F --environment live",
"build:live": "run-s build:hugo:live",
"build:hugo:preview": "yarn run build:hugo -D -F --environment preview",
"build:hugo:live": "yarn run build:hugo -D -F --environment live",
"build:live": "yarn run build:hugo:live",
"deploy:previewAssets": "./node_modules/.bin/hugo deploy --target previewAssets -e preview --maxDeletes 0 --log --verbose",
"deploy:preview": "./node_modules/.bin/hugo deploy --target preview -e preview --maxDeletes -1 --invalidateCDN --log --verbose",
"deploy:liveAssets": "./node_modules/.bin/hugo deploy --target liveAssets -e live --maxDeletes 0 --log --verbose --debug",
Expand All @@ -40,8 +39,8 @@
"dependencies": {
"@apidevtools/json-schema-ref-parser": "^8.0.0",
"@babel/polyfill": "^7.4.4",
"@datadog/browser-logs": "^3.6.4",
"@datadog/browser-rum": "^3.6.4",
"@datadog/browser-logs": "^4.11.2",
"@datadog/browser-rum": "^4.11.2",
"a11y": "https://s3.amazonaws.com/origin-static-assets/corp-node-packages/master/a11y-v1.0.1.tgz",
"algoliasearch": "4.11.0",
"bootstrap": "4.3.1",
Expand Down Expand Up @@ -79,31 +78,24 @@
"eslint-config-airbnb": "^18.1.0",
"eslint-config-prettier": "^6.10.1",
"eslint-config-standard": "^14.1.1",
"eslint-loader": "^3.0.2",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.19.0",
"eslint-plugin-react-hooks": "^2.5.0",
"eslint-plugin-standard": "^4.0.0",
"exports-loader": "^0.7.0",
"expose-loader": "^0.7.5",
"file-loader": "^4.1.0",
"html-loader": "^0.5.5",
"imports-loader": "^0.8.0",
"jest": "^25.3.0",
"npm-run-all": "^4.1.5",
"postcss-import": "^12.0.1",
"postcss-preset-env": "^6.7.0",
"prettier": "^2.0.2",
"resolve-url-loader": "^3.1.0",
"rimraf": "^3.0.2",
"run-sequence": "^2.2.1",
"sass": "^1.26.10",
"serialize-javascript": "^2.1.1"
},
"hugo-bin": {
"buildTags": "extended"
}
},
"packageManager": "yarn@3.2.1"
}
Loading

0 comments on commit 9e912ba

Please sign in to comment.