Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 2277b5b

Browse files
authored
Implement docusaurus build, deployment and CI hooks (#129)
* Implement docs build, deployment and CI hooks * Fixup travis config * Update references to final domain choice
1 parent b24bfe7 commit 2277b5b

29 files changed

+545
-25
lines changed

.travis.yml

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,51 @@
11
dist: bionic
22
sudo: required
3-
language: rust
4-
services:
5-
- docker
3+
4+
notifications:
5+
email: false
6+
67
cache:
78
cargo: true
89
directories:
9-
- "~/.npm"
10-
notifications:
11-
email: false
10+
- "~/.npm"
1211

13-
install:
14-
- cargo --version
15-
- rustup install nightly
16-
- rustup component add clippy --toolchain nightly
17-
- docker --version
18-
- wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
19-
- sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main"
20-
- sudo apt-get update
21-
- sudo apt-get install -y clang-7 --allow-unauthenticated
22-
- sudo apt-get install -y openssl --allow-unauthenticated
23-
- sudo apt-get install -y libssl-dev --allow-unauthenticated
24-
- sudo apt-get install -y libssl1.1 --allow-unauthenticated
25-
- clang-7 --version
26-
- nvm install node
27-
- node --version
12+
services:
13+
- docker
2814

2915
jobs:
3016
include:
31-
- stage: "Test Programs"
32-
script: ./ci/memo.sh
33-
- script: ./ci/token-swap.sh
34-
- script: ./ci/token.sh
17+
- name: "Test Memo"
18+
language: rust
19+
install:
20+
source .travis/install-program-deps.sh
21+
script:
22+
./ci/memo.sh
23+
24+
- name: "Test Token-Swap"
25+
language: rust
26+
install:
27+
source .travis/install-program-deps.sh
28+
script:
29+
./ci/token-swap.sh
30+
31+
- name: "Test Token Program"
32+
language: rust
33+
install:
34+
source .travis/install-program-deps.sh
35+
script:
36+
./ci/token.sh
37+
38+
39+
# docs pull request or commit to master
40+
- name: "Build Docs"
41+
if: type IN (push, pull_request) AND branch = master
42+
language: node_js
43+
node_js:
44+
- "node"
45+
46+
before_install:
47+
- .travis/affects.sh docs/ .travis || travis_terminate 0
48+
- cd docs/
49+
- source .travis/before_install.sh
50+
script:
51+
- source .travis/script.sh

.travis/affects.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Check if files in the commit range match one or more prefixes
4+
#
5+
6+
(
7+
set -x
8+
git diff --name-only "$TRAVIS_COMMIT_RANGE"
9+
)
10+
11+
for file in $(git diff --name-only "$TRAVIS_COMMIT_RANGE"); do
12+
for prefix in "$@"; do
13+
if [[ $file =~ ^"$prefix" ]]; then
14+
exit 0
15+
fi
16+
done
17+
done
18+
19+
echo "No modifications to $*"
20+
exit 1

.travis/install-program-deps.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# |source| this file
2+
3+
cargo --version
4+
rustup install nightly
5+
rustup component add clippy --toolchain nightly
6+
docker --version
7+
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
8+
sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main"
9+
sudo apt-get update
10+
sudo apt-get install -y clang-7 --allow-unauthenticated
11+
sudo apt-get install -y openssl --allow-unauthenticated
12+
sudo apt-get install -y libssl-dev --allow-unauthenticated
13+
sudo apt-get install -y libssl1.1 --allow-unauthenticated
14+
clang-7 --version
15+
nvm install node
16+
node --version

ci/env.sh

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#
2+
# Normalized CI environment variables
3+
#
4+
# |source| me
5+
#
6+
7+
if [[ -n $CI ]]; then
8+
export CI=1
9+
if [[ -n $TRAVIS ]]; then
10+
export CI_BRANCH=$TRAVIS_BRANCH
11+
export CI_BASE_BRANCH=$TRAVIS_BRANCH
12+
export CI_BUILD_ID=$TRAVIS_BUILD_ID
13+
export CI_COMMIT=$TRAVIS_COMMIT
14+
export CI_JOB_ID=$TRAVIS_JOB_ID
15+
if [[ $TRAVIS_PULL_REQUEST != false ]]; then
16+
export CI_PULL_REQUEST=true
17+
else
18+
export CI_PULL_REQUEST=
19+
fi
20+
export CI_OS_NAME=$TRAVIS_OS_NAME
21+
export CI_REPO_SLUG=$TRAVIS_REPO_SLUG
22+
export CI_TAG=$TRAVIS_TAG
23+
elif [[ -n $BUILDKITE ]]; then
24+
export CI_BRANCH=$BUILDKITE_BRANCH
25+
export CI_BUILD_ID=$BUILDKITE_BUILD_ID
26+
export CI_COMMIT=$BUILDKITE_COMMIT
27+
export CI_JOB_ID=$BUILDKITE_JOB_ID
28+
# The standard BUILDKITE_PULL_REQUEST environment variable is always "false" due
29+
# to how solana-ci-gate is used to trigger PR builds rather than using the
30+
# standard Buildkite PR trigger.
31+
if [[ $CI_BRANCH =~ pull/* ]]; then
32+
export CI_BASE_BRANCH=$BUILDKITE_PULL_REQUEST_BASE_BRANCH
33+
export CI_PULL_REQUEST=true
34+
else
35+
export CI_BASE_BRANCH=$BUILDKITE_BRANCH
36+
export CI_PULL_REQUEST=
37+
fi
38+
export CI_OS_NAME=linux
39+
if [[ -n $BUILDKITE_TRIGGERED_FROM_BUILD_PIPELINE_SLUG ]]; then
40+
# The solana-secondary pipeline should use the slug of the pipeline that
41+
# triggered it
42+
export CI_REPO_SLUG=$BUILDKITE_ORGANIZATION_SLUG/$BUILDKITE_TRIGGERED_FROM_BUILD_PIPELINE_SLUG
43+
else
44+
export CI_REPO_SLUG=$BUILDKITE_ORGANIZATION_SLUG/$BUILDKITE_PIPELINE_SLUG
45+
fi
46+
# TRIGGERED_BUILDKITE_TAG is a workaround to propagate BUILDKITE_TAG into
47+
# the solana-secondary pipeline
48+
if [[ -n $TRIGGERED_BUILDKITE_TAG ]]; then
49+
export CI_TAG=$TRIGGERED_BUILDKITE_TAG
50+
else
51+
export CI_TAG=$BUILDKITE_TAG
52+
fi
53+
elif [[ -n $APPVEYOR ]]; then
54+
export CI_BRANCH=$APPVEYOR_REPO_BRANCH
55+
export CI_BUILD_ID=$APPVEYOR_BUILD_ID
56+
export CI_COMMIT=$APPVEYOR_REPO_COMMIT
57+
export CI_JOB_ID=$APPVEYOR_JOB_ID
58+
if [[ -n $APPVEYOR_PULL_REQUEST_NUMBER ]]; then
59+
export CI_PULL_REQUEST=true
60+
else
61+
export CI_PULL_REQUEST=
62+
fi
63+
if [[ $CI_LINUX = True ]]; then
64+
export CI_OS_NAME=linux
65+
else
66+
export CI_OS_NAME=windows
67+
fi
68+
export CI_REPO_SLUG=$APPVEYOR_REPO_NAME
69+
export CI_TAG=$APPVEYOR_REPO_TAG_NAME
70+
fi
71+
else
72+
export CI=
73+
export CI_BRANCH=
74+
export CI_BUILD_ID=
75+
export CI_COMMIT=
76+
export CI_JOB_ID=
77+
export CI_OS_NAME=
78+
export CI_PULL_REQUEST=
79+
export CI_REPO_SLUG=
80+
export CI_TAG=
81+
fi
82+
83+
cat <<EOF
84+
CI=$CI
85+
CI_BRANCH=$CI_BRANCH
86+
CI_BUILD_ID=$CI_BUILD_ID
87+
CI_COMMIT=$CI_COMMIT
88+
CI_JOB_ID=$CI_JOB_ID
89+
CI_OS_NAME=$CI_OS_NAME
90+
CI_PULL_REQUEST=$CI_PULL_REQUEST
91+
CI_TAG=$CI_TAG
92+
EOF

docs/.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Dependencies
2+
/node_modules
3+
4+
# Production
5+
/build
6+
7+
# Generated files
8+
.docusaurus
9+
.cache-loader
10+
.vercel
11+
vercel.json
12+
13+
# Misc
14+
.DS_Store
15+
.env.local
16+
.env.development.local
17+
.env.test.local
18+
.env.production.local
19+
20+
npm-debug.log*
21+
yarn-debug.log*
22+
yarn-error.log*

docs/.travis/before_install.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# |source| this file
2+
3+
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
4+
sudo apt install -y nodejs
5+
6+
npm install --global docusaurus-init
7+
docusaurus-init
8+
9+
npm install --global vercel

docs/.travis/script.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# |source| this file
2+
3+
set -ex
4+
./build.sh

docs/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Docs Readme
2+
3+
SPL Docs are built using [Docusaurus 2](https://v2.docusaurus.io/) with `npm`.
4+
Static content delivery is handled using `vercel`.
5+
6+
### Installing Docusaurus
7+
8+
```
9+
$ npm install
10+
```
11+
12+
### Local Development
13+
14+
This command starts a local development server and open up a browser window.
15+
Most changes are reflected live without having to restart the server.
16+
17+
```
18+
$ npm run start
19+
```
20+
21+
### Build Locally
22+
23+
This command generates static content into the `build` directory and can be
24+
served using any static contents hosting service.
25+
26+
```
27+
$ docs/build.sh
28+
```
29+
30+
### CI Build Flow
31+
The docs are built and published in Travis CI with the `docs/build.sh` script.
32+
On each PR, the docs are built, but not published.
33+
34+
In each post-commit build, docs are built and published using `vercel`.
35+
36+
Documentation is published to spl.solana.com

docs/babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [require.resolve("@docusaurus/core/lib/babel/preset")],
3+
};

docs/build.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
cd "$(dirname "$0")"
5+
6+
# shellcheck source=ci/env.sh
7+
source ../ci/env.sh
8+
9+
# Build from /src into /build
10+
npm run build
11+
12+
# Publish only from merge commits and release tags
13+
if [[ -n $CI ]]; then
14+
if [[ -z $CI_PULL_REQUEST ]]; then
15+
./publish-docs.sh
16+
fi
17+
fi

0 commit comments

Comments
 (0)