Skip to content

Commit ff46230

Browse files
committed
Nav SDK v2 CI documentation workflow (#4810)
(cherry picked from commit b1a40e7)
1 parent 9a07c44 commit ff46230

File tree

4 files changed

+175
-50
lines changed

4 files changed

+175
-50
lines changed

.circleci/config.yml

Lines changed: 87 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ parameters:
1717
default: false
1818

1919
commands:
20+
install-linux-mbx-ci:
21+
steps:
22+
- run:
23+
name: "Install mbx-ci"
24+
command: |
25+
mkdir -p ./bin
26+
curl -fsSL https://mapbox-release-engineering.s3.amazonaws.com/mbx-ci/latest/mbx-ci-linux-amd64 > mbx-ci
27+
sudo mv mbx-ci /usr/local/bin/
28+
chmod 755 /usr/local/bin/mbx-ci
29+
echo "mbx-ci version: $(mbx-ci --version)"
2030
install-mbx-ci:
2131
steps:
2232
- macos/install-rosetta
@@ -25,6 +35,14 @@ commands:
2535
command: |
2636
curl -Ls https://mapbox-release-engineering.s3.amazonaws.com/mbx-ci/latest/mbx-ci-darwin-amd64 > /usr/local/bin/mbx-ci
2737
chmod 755 /usr/local/bin/mbx-ci
38+
install-linux-s5cmd:
39+
steps:
40+
- run:
41+
name: "Install s5cmd"
42+
command: |
43+
curl -fsSL https://github.com/peak/s5cmd/releases/download/v2.3.0/s5cmd_2.3.0_Linux-64bit.tar.gz | tar xvz
44+
sudo mv s5cmd /usr/local/bin/
45+
echo "s5cmd version: $(s5cmd version)"
2846
notify-build-finished:
2947
parameters:
3048
notify_success:
@@ -695,46 +713,79 @@ jobs:
695713
default: "14.3.1"
696714
macos:
697715
xcode: << parameters.xcode >>
716+
resource_class: m4pro.medium
698717
environment:
699718
HOMEBREW_NO_AUTO_UPDATE: 1
700-
resource_class: m4pro.medium
701719
steps:
702720
- checkout
703721
- *restore-cache-gems
704-
- *restore-cache-podmaster
705722
- *install-gems
706723
- *prepare-netrc-file
707724
- *add-github-to-known-hosts
708-
- install-mbx-ci
709725
- run:
710726
name: Generate docs
711727
command: |
712-
OUTPUT=$( echo << pipeline.git.tag >> | sed 's/^v//' )
713-
export OUTPUT="${OUTPUT:-documentation}"
714-
echo "export OUTPUT=$OUTPUT" >> $BASH_ENV
715-
./scripts/document.sh
716-
cp -a "$OUTPUT" /tmp/generated-docs
717-
- *save-cache-podmaster
728+
TAG="<< pipeline.git.tag >>"
729+
if [ -n "$TAG" ]; then
730+
VERSION=${TAG#v}
731+
else
732+
# Dummy version for non-tagged builds.
733+
VERSION=0.0.0
734+
fi
735+
OUTPUT_PATH="build/docs/$VERSION"
736+
echo "export OUTPUT_PATH=$OUTPUT_PATH" >> $BASH_ENV
737+
./scripts/generate-docs.sh "$VERSION" "$OUTPUT_PATH"
718738
- *save-cache-gems
739+
- persist_to_workspace:
740+
root: ./
741+
paths:
742+
- build/docs
719743
- run:
720-
name: Compress Docs
721-
command: tar -cvzf /tmp/docs.tar /tmp/generated-docs
744+
name: Compress docs
745+
command: |
746+
mkdir -p build/archives
747+
tar -cvzf build/archives/navsdk-v2-docs.tar $OUTPUT_PATH
722748
- store_artifacts:
723-
path: /tmp/docs.tar
724-
destination: docs
749+
path: build/archives/navsdk-v2-docs.tar
750+
destination: navsdk-v2-docs
751+
- notify-build-finished
752+
753+
publish-docs-job:
754+
docker:
755+
- image: cimg/base:current
756+
resource_class: small
757+
environment:
758+
HOMEBREW_NO_AUTO_UPDATE: 1
759+
MBX_CI_DOMAIN: o619qyc20d.execute-api.us-east-1.amazonaws.com
760+
TARGET_ENVIRONMENT: docs.mapbox.com
761+
steps:
725762
- when:
726-
condition: << pipeline.git.tag >>
763+
condition: << pipeline.git.tag >> =~ /^v2\.\d+\.\d+(-.+)?$/
727764
steps:
728-
- run:
729-
name: Push docs to publisher-production
730-
command: |
731-
git remote set-url origin "https://x-access-token:$(mbx-ci github writer public token)@github.com/mapbox/mapbox-navigation-ios.git"
732-
git config user.email "[email protected]"
733-
git config user.name "Mapbox Releases"
734-
VERSION="${OUTPUT}" scripts/publish-docs.sh
735-
- notify-build-finished:
736-
notify_success: true
737-
- notify-build-finished
765+
- checkout
766+
- *add-github-to-known-hosts
767+
- attach_workspace:
768+
at: .
769+
- install-linux-mbx-ci
770+
- install-linux-s5cmd
771+
- run:
772+
name: Publish docs
773+
command: |
774+
TAG="<< pipeline.git.tag >>"
775+
if [ -z "$TAG" ]; then
776+
echo "ERROR: Missing git tag. A tag is required to publish documentation."
777+
exit 1
778+
fi
779+
VERSION=${TAG#v}
780+
781+
if ! mbx-ci aws setup; then
782+
echo "ERROR: Could not setup AWS credentials."
783+
exit 1
784+
fi
785+
786+
SOURCE_PATH="build/docs/$VERSION"
787+
./scripts/publish-docs.sh "$VERSION" "$TARGET_ENVIRONMENT" "$SOURCE_PATH"
788+
- notify-build-finished
738789

739790
update-version-job:
740791
parameters:
@@ -946,11 +997,21 @@ workflows:
946997
clean_build: false
947998
context: Slack Orb
948999
- generate-docs-job:
949-
name: Generate / Publish Documentation
1000+
name: Generate Documentation
9501001
context: Slack Orb
9511002
filters:
9521003
tags:
953-
only: /^v\d+\.\d+\.\d+(-.+)?$/
1004+
only: /^v2\.\d+\.\d+(-.+)?$/
1005+
- publish-docs-job:
1006+
name: Publish Documentation
1007+
context: Slack Orb
1008+
requires:
1009+
- Generate Documentation
1010+
filters:
1011+
branches:
1012+
ignore: /.*/
1013+
tags:
1014+
only: /^v2\.\d+\.\d+(-.+)?$/
9541015
- ios-trigger-metrics:
9551016
filters:
9561017
branches:

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
## Generating documentation locally
22

3-
Make sure you’ve got Bundler installed, then run `scripts/document.sh`.
3+
Make sure you’ve got Bundler installed, then run `scripts/generate-docs.sh`.
Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,42 @@
11
#!/usr/bin/env bash
22

3-
set -e
4-
set -o pipefail
5-
set -u
3+
set -euo pipefail
4+
5+
if [ $# -ne 2 ]; then
6+
echo "Usage: $0 <documentation_version> <output_directory>"
7+
echo "Example: $0 2.20.3 build/docs/2.20.3"
8+
exit 1
9+
fi
10+
11+
SHORT_VERSION=$1
12+
OUTPUT=$2
13+
14+
if [[ ! "${SHORT_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
15+
echo "Error: Version '${SHORT_VERSION}' does not match the required format."
16+
echo "Format: X.Y.Z or X.Y.Z-suffix (e.g., 2.20.3, 2.21.0-beta.1)"
17+
exit 1
18+
fi
19+
20+
# Safety checks for output directory
21+
ABS_PWD=$(pwd -P)
22+
if [[ "$OUTPUT" == /* ]]; then
23+
# Absolute path
24+
if [[ "$OUTPUT" != "$ABS_PWD"* ]]; then
25+
echo "Error: Output directory '$OUTPUT' must be within the current working directory '$ABS_PWD'."
26+
exit 1
27+
fi
28+
else
29+
# Relative path
30+
if [[ "$OUTPUT" == *".."* ]]; then
31+
echo "Error: Output directory '$OUTPUT' cannot contain parent directory traversal ('..')."
32+
exit 1
33+
fi
34+
fi
35+
36+
if [[ "${OUTPUT}" == "/" ]] || [[ "${OUTPUT}" == "${HOME}" ]]; then
37+
echo "Error: Output directory cannot be root or home directory."
38+
exit 1
39+
fi
640

741
bundle check || bundle install
842

@@ -13,12 +47,9 @@ if [[ -z $(which "${SOURCEKITTEN_PATH}") ]]; then
1347
exit 1
1448
fi
1549

16-
BRANCH=$( git describe --tags --match=v*.*.* --abbrev=0 )
17-
SHORT_VERSION=$( echo ${BRANCH} | sed 's/^v//' )
1850
RELEASE_VERSION=$( echo ${SHORT_VERSION} | sed -e 's/-.*//' )
1951
MINOR_VERSION=$( echo ${SHORT_VERSION} | grep -Eo '^\d+\.\d+' )
20-
21-
OUTPUT=${OUTPUT:-${SHORT_VERSION:-documentation}}
52+
LONG_VERSION="v${SHORT_VERSION}"
2253

2354
DEFAULT_THEME="docs/theme"
2455
THEME=${JAZZY_THEME:-$DEFAULT_THEME}
@@ -48,7 +79,7 @@ DESTINATION="generic/platform=iOS"
4879
bundle exec jazzy \
4980
--config docs/jazzy.yml \
5081
--sdk iphonesimulator \
51-
--github-file-prefix "https://github.com/mapbox/mapbox-navigation-ios/tree/${BRANCH}" \
82+
--github-file-prefix "https://github.com/mapbox/mapbox-navigation-ios/tree/${LONG_VERSION}" \
5283
--readme ${README} \
5384
--documentation="docs/guides/*.md" \
5485
--root-url "${BASE_URL}/navigation/api/${RELEASE_VERSION}/" \
@@ -59,7 +90,10 @@ bundle exec jazzy \
5990
2>&1 | tee docs.output
6091

6192
rm core.json ui.json
62-
93+
94+
# Filter out known harmless warnings (needed for Xcode 15+)
95+
sed -i '' '/`AppKit` has no USR/d' docs.output
96+
6397
if egrep -e "(WARNING)|(USR)" docs.output; then
6498
echo "Please eliminate Jazzy warnings"
6599
exit 1

scripts/publish-docs.sh

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,51 @@
11
#!/usr/bin/env bash
22

3-
set -e
4-
set -o pipefail
5-
set -u
3+
set -euo pipefail
64

7-
if ! [[ -d "${VERSION}" ]]; then
8-
echo "${VERSION} directory does not exist"
9-
exit 1
5+
if [ $# -ne 3 ]; then
6+
echo "Usage: $0 <version> <target_environment> <source_path>"
7+
echo "Example: $0 2.20.3 docs.mapbox.com-staging build/docs/2.20.3"
8+
exit 1
109
fi
1110

12-
if ! [[ "${VERSION}" =~ ^([0-9]+\.){2}[0-9]+(-.+)?$ ]]; then
13-
echo "Set \$VERSION to a valid semver version"
14-
exit 1
11+
VERSION=$1
12+
TARGET_ENVIRONMENT=$2
13+
SOURCE_PATH=$3
14+
15+
# Validate version format
16+
if [[ ! "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
17+
echo "Error: Version '${VERSION}' does not match the required format."
18+
echo "Format: X.Y.Z or X.Y.Z-suffix (e.g., 2.20.3, 2.21.0-beta.1)"
19+
exit 1
20+
fi
21+
22+
# Validate target environment
23+
if [[ "${TARGET_ENVIRONMENT}" != "docs.mapbox.com" ]] && [[ "${TARGET_ENVIRONMENT}" != "docs.mapbox.com-staging" ]]; then
24+
echo "Error: Target environment '${TARGET_ENVIRONMENT}' is invalid."
25+
echo "Allowed values: docs.mapbox.com, docs.mapbox.com-staging"
26+
exit 1
27+
fi
28+
29+
# Validate source path
30+
if [[ ! -f "${SOURCE_PATH}/index.html" ]]; then
31+
echo "Error: Documentation not found at '${SOURCE_PATH}'."
32+
echo "Missing index.html file."
33+
exit 1
1534
fi
1635

17-
git checkout -- .
18-
git checkout publisher-production
19-
git add "${VERSION}"
20-
git commit -m "v${VERSION} [skip ci]"
21-
git push origin publisher-production
36+
echo "########################################################"
37+
echo "PUBLISHING DOCS FOR VERSION: ${VERSION}"
38+
echo "########################################################"
39+
echo "SOURCE_PATH: ${SOURCE_PATH}"
40+
echo "TARGET_ENVIRONMENT: ${TARGET_ENVIRONMENT}"
41+
echo "########################################################"
42+
43+
s5cmd sync \
44+
"${SOURCE_PATH}/*" \
45+
"s3://${TARGET_ENVIRONMENT}/ios/navigation/api/${VERSION}/"
46+
47+
echo "########################################################"
48+
echo "DOCS PUBLISHED SUCCESSFULLY"
49+
echo "URL: https://${TARGET_ENVIRONMENT}/ios/navigation/api/${VERSION}/"
50+
echo "########################################################"
51+

0 commit comments

Comments
 (0)