Skip to content

Commit

Permalink
chore: build docs in earthly (#6038)
Browse files Browse the repository at this point in the history
Adds a `docs-preview` job to the github actions `CI` workflow which:
1. Builds the docs
2. Adds the familiar PR comment with link to preview

Adds a `Publish Docs` workflow, which gets triggered from the
`release-please` workflow which builds and deploys docs to production.

Removes doc builds from circle ci.
  • Loading branch information
just-mitch committed Apr 30, 2024
1 parent 1a89d1a commit 784d542
Show file tree
Hide file tree
Showing 20 changed files with 6,508 additions and 247 deletions.
20 changes: 0 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -513,24 +513,6 @@ jobs:
aztec_manifest_key: end-to-end
<<: *defaults_e2e_test

build-docs:
machine:
image: default
resource_class: large
steps:
- *checkout
- *setup_env
- run:
name: "Build docs"
command: |
echo "Building docs"
build docs
- run:
name: "Deploy docs"
command: |
echo "Deploying docs"
docs/deploy_netlify.sh $BRANCH $PULL_REQUEST
e2e-join:
docker:
- image: cimg/base:2023.09
Expand Down Expand Up @@ -741,7 +723,6 @@ workflows:
- noir-projects
<<: *defaults
- end-to-end: *defaults_yarn_project
- build-docs: *defaults_yarn_project_pre_join
- prover-client-test: *defaults_yarn_project
- yarn-project-x86_64: *defaults_yarn_project_pre_join
- yarn-project-arm64: *defaults_yarn_project_pre_join
Expand Down Expand Up @@ -787,7 +768,6 @@ workflows:
- barretenberg-acir-tests-bb
- barretenberg-acir-tests-bb-sol
- barretenberg-docs
- build-docs
- boxes-vanilla
- boxes-react
- noir-packages-tests
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,22 @@ jobs:
timeout-minutes: 25
run: earthly-ci --no-output ./yarn-project/+test

docs-preview:
needs: setup
runs-on: ${{ inputs.username || github.actor }}-x86
steps:
- {
uses: actions/checkout@v4,
with: { ref: "${{ github.event.pull_request.head.sha }}" },
}
- uses: ./.github/ci-setup-action
with:
dockerhub_password: "${{ secrets.DOCKERHUB_PASSWORD }}"
concurrency_key: docs-preview-${{ inputs.username || github.actor }}-x86
- name: "Docs Preview"
timeout-minutes: 25
run: earthly --no-output ./docs/+deploy-preview --PR=${{ github.event.number }} --AZTEC_BOT_COMMENTER_GITHUB_TOKEN=${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} --NETLIFY_AUTH_TOKEN=${{ secrets.NETLIFY_AUTH_TOKEN }} --NETLIFY_SITE_ID=${{ secrets.NETLIFY_SITE_ID }}

# push benchmarking binaries to dockerhub registry
bb-bench-binaries:
needs: setup
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Publish Docs
on:
workflow_dispatch:
inputs:
tag:
description: The tag to build from (leave empty to build a nightly release from master)
required: true

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || env.GITHUB_REF }}

- timeout-minutes: 25
run: earthly --no-output ./docs/+deploy-prod --NETLIFY_AUTH_TOKEN=${{ secrets.NETLIFY_AUTH_TOKEN }} --NETLIFY_SITE_ID=${{ secrets.NETLIFY_SITE_ID }}
11 changes: 10 additions & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,20 @@ jobs:
token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
command: manifest

- name: Dispatch to publish workflow
- name: Dispatch to publish BB workflow
uses: benc-uk/workflow-dispatch@v1
if: ${{ steps.release.outputs.tag_name }}
with:
workflow: publish-bb.yml
ref: master
token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
inputs: '{ "tag": "${{ steps.release.outputs.tag_name }}", "publish": true }'

- name: Dispatch to publish docs workflow
uses: benc-uk/workflow-dispatch@v1
if: ${{ steps.release.outputs.tag_name }}
with:
workflow: publish-docs.yml
ref: master
token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
inputs: '{ "tag": "${{ steps.release.outputs.tag_name }}" }'
4 changes: 4 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ test-end-to-end:

bench:
RUN echo hi

release-meta:
COPY .release-please-manifest.json /usr/src/.release-please-manifest.json
SAVE ARTIFACT /usr/src /usr/src
4 changes: 4 additions & 0 deletions docs/.earthlyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.docusaurus
node_modules
processed-docs
processed-docs-cache
56 changes: 56 additions & 0 deletions docs/Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
VERSION 0.8

FROM node:18.19.0
WORKDIR /usr/src/docs

deps:
RUN apt update && apt install -y jq curl perl && rm -rf /var/lib/apt/lists/* && apt-get clean
COPY ./yarn.lock ./yarn.lock
COPY ./package.json ./package.json
RUN yarn install --frozen-lockfile

build:
BUILD ../yarn-project/+build-dev
BUILD ../+release-meta
FROM +deps

COPY --dir ../yarn-project/+build-dev/usr/src /usr
COPY ../+release-meta/usr/src/.release-please-manifest.json /usr/src

COPY . .

RUN ./scripts/build.sh
SAVE ARTIFACT build

serve:
FROM +deps
COPY +build/build build
COPY ./static static
COPY ./src src
COPY ./docusaurus.config.js .
COPY ./sidebars.js .
ENTRYPOINT ["yarn", "serve"]
EXPOSE 3000
SAVE ARTIFACT /usr/src/docs
SAVE IMAGE aztecprotocol/docs-server

deploy-preview:
BUILD ../yarn-project/+scripts-prod
ARG NETLIFY_AUTH_TOKEN
ARG NETLIFY_SITE_ID
ARG AZTEC_BOT_COMMENTER_GITHUB_TOKEN
ARG PR
FROM +serve
COPY --dir ../yarn-project/+scripts-prod/usr/src/yarn-project /usr/src
COPY ./netlify.toml .
COPY ./deploy_preview.sh .
RUN NETLIFY_AUTH_TOKEN=$NETLIFY_AUTH_TOKEN NETLIFY_SITE_ID=$NETLIFY_SITE_ID ./deploy_preview.sh $PR $AZTEC_BOT_COMMENTER_GITHUB_TOKEN

deploy-prod:
BUILD ../yarn-project/+scripts-prod
ARG NETLIFY_AUTH_TOKEN
ARG NETLIFY_SITE_ID
FROM +serve
COPY ./netlify.toml .
COPY ./deploy_prod.sh .
RUN NETLIFY_AUTH_TOKEN=$NETLIFY_AUTH_TOKEN NETLIFY_SITE_ID=$NETLIFY_SITE_ID ./deploy_prod.sh
48 changes: 0 additions & 48 deletions docs/deploy_netlify.sh

This file was deleted.

29 changes: 29 additions & 0 deletions docs/deploy_preview.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -eu

PR_NUMBER=$1
AZTEC_BOT_COMMENTER_GITHUB_TOKEN="$2"

API_URL="https://api.github.com/repos/AztecProtocol/aztec-packages/pulls/${PR_NUMBER}/files"

echo "API URL: $API_URL"

DOCS_CHANGED=$(curl -L \
-H "Authorization: Bearer $AZTEC_BOT_COMMENTER_GITHUB_TOKEN" \
"${API_URL}" | \
jq '[.[] | select(.filename | startswith("docs/"))] | length > 0')

echo "Docs changed: $DOCS_CHANGED"

if [ "$DOCS_CHANGED" = "false" ]; then
echo "No docs changed, not deploying"
exit 0
fi

# Regular deploy if the argument is not "master" and docs changed
DEPLOY_OUTPUT=$(yarn netlify deploy --site aztec-docs-dev)
DOCS_PREVIEW_URL=$(echo "$DEPLOY_OUTPUT" | grep -E "https://.*aztec-docs-dev.netlify.app" | awk '{print $4}')
echo "Unique deploy URL: $DOCS_PREVIEW_URL"

cd ../yarn-project/scripts
AZTEC_BOT_COMMENTER_GITHUB_TOKEN=$AZTEC_BOT_COMMENTER_GITHUB_TOKEN PR_NUMBER=$PR_NUMBER DOCS_PREVIEW_URL=$DOCS_PREVIEW_URL yarn docs-preview-comment
4 changes: 4 additions & 0 deletions docs/deploy_prod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -eu

netlify deploy --site aztec-docs-dev --prod
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"concurrently": "^8.0.1",
"docusaurus-plugin-typedoc": "^0.20.2",
"dotenv": "^16.3.1",
"netlify-cli": "^17.23.0",
"nodemon": "^3.0.1",
"typedoc": "^0.25.1",
"typedoc-plugin-markdown": "^3.16.0",
Expand Down
Loading

0 comments on commit 784d542

Please sign in to comment.