diff --git a/.github/workflows/doc-build-livedoc.yml b/.github/workflows/doc-build-livedoc.yml new file mode 100644 index 00000000000..72f9ff1b59a --- /dev/null +++ b/.github/workflows/doc-build-livedoc.yml @@ -0,0 +1,87 @@ +name: Build live documentation + +on: + push: + tags: + # Match all release tags including beta, rc + - '[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.beta[0-9]+' + - '[0-9]+.[0-9]+.[0-9]+.beta[0-9]+' + - '[0-9]+.[0-9]+.rc[0-9]+' + - '[0-9]+.[0-9]+.[0-9]+.rc[0-9]+' + workflow_dispatch: + +env: + PYTHON_VERSION: 3.11 + +jobs: + livedoc: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Cache conda packages + uses: actions/cache@v4 + with: + path: ~/conda_pkgs_dir + key: + ${{ runner.os }}-conda-${{ hashFiles('environment-${{ env.PYTHON_VERSION }}-linux.yml') }} + + - name: Compiler cache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ runner.os }}-meson-${{ env.PYTHON_VERSION }} + + - name: Setup Conda environment + uses: conda-incubator/setup-miniconda@v3 + with: + python-version: ${{ env.PYTHON_VERSION }} + # Disabled for now due to + # https://github.com/conda-incubator/setup-miniconda/issues/379 + # miniforge-version: latest + use-mamba: true + channels: conda-forge + channel-priority: true + activate-environment: sage-dev + environment-file: environment-${{ env.PYTHON_VERSION }}-linux.yml + + - name: Build Sage + shell: bash -l {0} + run: | + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" + export CC="ccache $CC" + export CXX="ccache $CXX" + pip install --no-build-isolation --config-settings=builddir=builddir . -v + + - name: Build pdf doc + shell: bash -l {0} + run: | + sudo DEBIAN_FRONTEND=noninteractive sudo apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get install $(build/bin/sage-get-system-packages debian texlive texlive_luatex free_fonts xindy) + meson compile -C builddir doc-pdf + + - name: Build live doc + shell: bash -l {0} + run: | + meson compile -C builddir doc-html -j1 + env: + SAGE_USE_CDNS: yes + SAGE_LIVE_DOC: yes + SAGE_JUPYTER_SERVER: "binder:sagemath/sage-binder-env/dev" + + - name: Copy doc + id: copy + run: | + mkdir -p ./doc + cp -r builddir/src/doc/pdf doc/ + cp -rL builddir/src/doc/html doc/ + cp builddir/src/doc/index.html doc/ + zip -r livedoc.zip doc + + - name: Upload livedoc + uses: actions/upload-artifact@v4 + with: + name: livedoc + path: livedoc.zip diff --git a/.github/workflows/doc-build-pdf.yml b/.github/workflows/doc-build-pdf.yml index f278dae841e..536fcabc67f 100644 --- a/.github/workflows/doc-build-pdf.yml +++ b/.github/workflows/doc-build-pdf.yml @@ -4,14 +4,6 @@ on: pull_request: merge_group: push: - tags: - # Match all release tags including beta, rc - - '[0-9]+.[0-9]+' - - '[0-9]+.[0-9]+.[0-9]+' - - '[0-9]+.[0-9]+.beta[0-9]+' - - '[0-9]+.[0-9]+.[0-9]+.beta[0-9]+' - - '[0-9]+.[0-9]+.rc[0-9]+' - - '[0-9]+.[0-9]+.[0-9]+.rc[0-9]+' branches: - develop workflow_dispatch: @@ -44,7 +36,7 @@ jobs: path: ~/conda_pkgs_dir key: ${{ runner.os }}-conda-${{ hashFiles('environment-${{ env.PYTHON_VERSION }}-linux.yml') }} - + - name: Compiler cache uses: hendrikmuhs/ccache-action@v1.2 with: @@ -62,7 +54,7 @@ jobs: channel-priority: true activate-environment: sage-dev environment-file: environment-${{ env.PYTHON_VERSION }}-linux.yml - + - name: Build Sage shell: bash -l {0} run: | diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 947329f04ea..37888c75f8a 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -4,14 +4,6 @@ on: pull_request: merge_group: push: - tags: - # Match all release tags including beta, rc - - '[0-9]+.[0-9]+' - - '[0-9]+.[0-9]+.[0-9]+' - - '[0-9]+.[0-9]+.beta[0-9]+' - - '[0-9]+.[0-9]+.[0-9]+.beta[0-9]+' - - '[0-9]+.[0-9]+.rc[0-9]+' - - '[0-9]+.[0-9]+.[0-9]+.rc[0-9]+' branches: - develop workflow_dispatch: @@ -74,6 +66,7 @@ jobs: # # For pull requests # + - name: Get workflow run-id if: github.event_name == 'pull_request' run: | @@ -195,7 +188,7 @@ jobs: path: doc.zip # - # On release events + # On push events # - name: Upload doc-develop @@ -205,34 +198,3 @@ jobs: with: name: doc-${{ github.ref_name }} path: doc.zip - - # The following fails randomly - # - name: Build live doc - # if: github.event_name != 'pull_request' - # shell: bash -l {0} - # run: | - # # Remove previous doc build - # rm -rf builddir/src/doc - # meson compile -C builddir doc-html - # env: - # SAGE_USE_CDNS: yes - # SAGE_LIVE_DOC: yes - # SAGE_JUPYTER_SERVER: binder:sagemath/sage-binder-env/dev - # SAGE_DOCBUILD_OPTS: "--include-tests-blocks" - - # - name: Copy live doc - # if: github.event_name != 'pull_request' - # run: | - # mkdir -p ./livedoc - # # We copy everything to a local folder - # cp -r builddir/src/doc/html livedoc/ - # cp builddir/src/doc/index.html livedoc/ - # zip -r livedoc.zip livedoc - - # - name: Upload live doc - # if: github.event_name != 'pull_request' - # uses: actions/upload-artifact@v4 - # with: - # name: livedoc - # path: livedoc.zip - diff --git a/.github/workflows/doc-publish-livedoc.yml b/.github/workflows/doc-publish-livedoc.yml new file mode 100644 index 00000000000..e8d1f414cae --- /dev/null +++ b/.github/workflows/doc-publish-livedoc.yml @@ -0,0 +1,101 @@ +name: Publish live documentation + +on: + workflow_run: + workflows: "Build live documentation" + types: + - completed + +permissions: + statuses: write + checks: write + pull-requests: write + + +# This workflow runs after doc-build-livedoc workflow, taking the +# artifact livedoc and deploying it to a netlify site. +# +# event (triggered doc-build-livedoc) URL (of the doc deployed to NETLIFY_SITE) +# ----------------------------------- --------------------------------- +# on push tag https://doc-10-4-beta2--NETLIFY_SITE +# on push tag https://doc-release--NETLIFY_SITE +# +# where NETLIFY_SITE is presently sagemath.netlify.app for repo sagemath/sage. +# +# This workflow runs only if secrets NETLIFY_AUTH_TOKEN and NETLIFY_SITE_ID are set. + +jobs: + publish-live-doc: + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion == 'success' + env: + CAN_DEPLOY: ${{ secrets.NETLIFY_AUTH_TOKEN != '' && secrets.NETLIFY_SITE_ID != '' }} + steps: + - name: Get information about workflow origin + uses: actions/github-script@v6 + id: source-run-info + with: + script: | + const runId = context.payload.workflow_run.id; + const { data: run } = await github.rest.actions.getWorkflowRun({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: runId + }); + const event = run.event; + const branchName = run.head_branch; + + core.setOutput('sourceEvent', event); + core.setOutput('branchName', branchName); + if: env.CAN_DEPLOY == 'true' + + - name: Download live doc + id: download-doc + uses: actions/download-artifact@v4 + with: + name: livedoc + github-token: ${{ secrets.GITHUB_TOKEN }} + repository: ${{ github.repository }} + run-id: ${{ github.event.workflow_run.id }} + # if the doc was built for tag push (branchName contains the tag) + if: steps.source-run-info.outputs.sourceEvent == 'push' && steps.source-run-info.outputs.branchName != 'develop' + + - name: Extract live doc + run: unzip livedoc.zip -d livedoc + if: steps.download-doc.outcome == 'success' + + - name: Create _headers file for permissive CORS + run: | + cat < livedoc/doc/_headers + /* + Access-Control-Allow-Origin: * + Access-Control-Allow-Methods: GET + Access-Control-Allow-Headers: Content-Type + EOF + if: steps.download-doc.outcome == 'success' + + - name: Deploy to netlify with doc-TAG alias + id: deploy-netlify + uses: netlify/actions/cli@master + with: + args: deploy --dir=livedoc/doc --message ${NETLIFY_MESSAGE} --alias ${NETLIFY_ALIAS} + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + NETLIFY_MESSAGE: doc-${{ steps.source-run-info.outputs.branchName }} + NETLIFY_ALIAS: doc-${{ steps.source-run-info.outputs.branchName }} + if: steps.download-doc.outcome == 'success' + + - name: Deploy to netlify with doc-release alias + uses: netlify/actions/cli@master + with: + args: deploy --dir=livedoc/doc --message doc-release --alias doc-release + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + if: steps.download-doc.outcome == 'success' + + - name: Report deployment url + run: | + echo "::notice::The live documentation has been deployed - ${{ steps.deploy-netlify.outputs.NETLIFY_URL }}" + if: steps.download-doc.outcome == 'success' diff --git a/.github/workflows/doc-publish.yml b/.github/workflows/doc-publish.yml index 025c36a577b..8372841fbd6 100644 --- a/.github/workflows/doc-publish.yml +++ b/.github/workflows/doc-publish.yml @@ -2,7 +2,7 @@ name: Publish documentation on: workflow_run: - workflows: ["Build documentation"] + workflows: "Build documentation" types: - completed @@ -12,15 +12,13 @@ permissions: pull-requests: write -# This workflow runs after doc-build workflow, taking the artifact -# (doc/livedoc) and deploying it to a netlify site. +# This workflow runs after doc-build workflow, taking the +# artifact doc and deploying it to a netlify site. # # event (triggered doc-build) URL (of the doc deployed to NETLIFY_SITE) # --------------------------- --------------------------------- # on pull request https://doc-pr-12345--NETLIFY_SITE # on push branch develop https://doc-develop--NETLIFY_SITE -# on push tag https://doc-10-4-beta2--NETLIFY_SITE -# on push tag https://doc-release--NETLIFY_SITE # # where NETLIFY_SITE is presently sagemath.netlify.app for repo sagemath/sage. # @@ -99,68 +97,3 @@ jobs: run: | echo "::notice::The documentation has been deployed - ${{ steps.deploy-netlify.outputs.NETLIFY_URL }}" if: steps.download-doc.outcome == 'success' - - # publish-live-doc: - # runs-on: ubuntu-latest - # if: github.event.workflow_run.conclusion == 'success' - # env: - # CAN_DEPLOY: ${{ secrets.NETLIFY_AUTH_TOKEN != '' && secrets.NETLIFY_SITE_ID != '' }} - # steps: - # - name: Get information about workflow origin - # uses: potiuk/get-workflow-origin@v1_5 - # id: source-run-info - # with: - # token: ${{ secrets.GITHUB_TOKEN }} - # sourceRunId: ${{ github.event.workflow_run.id }} - # if: env.CAN_DEPLOY == 'true' - - # - name: Download live doc - # id: download-doc - # uses: actions/download-artifact@v4 - # with: - # name: livedoc - # github-token: ${{ secrets.GITHUB_TOKEN }} - # repository: ${{ github.repository }} - # run-id: ${{ github.event.workflow_run.id }} - # # if the doc was built for tag push (targetBranch contains the tag) - # if: steps.source-run-info.outputs.sourceEvent == 'push' && steps.source-run-info.outputs.targetBranch != 'develop' - - # - name: Extract live doc - # run: unzip livedoc.zip -d livedoc - # if: steps.download-doc.outcome == 'success' - - # - name: Create _headers file for permissive CORS - # run: | - # cat < livedoc/livedoc/_headers - # /* - # Access-Control-Allow-Origin: * - # Access-Control-Allow-Methods: GET - # Access-Control-Allow-Headers: Content-Type - # EOF - # if: steps.download-doc.outcome == 'success' - - # - name: Deploy to netlify with doc-TAG alias - # id: deploy-netlify - # uses: netlify/actions/cli@master - # with: - # args: deploy --dir=livedoc/livedoc --message ${NETLIFY_MESSAGE} --alias ${NETLIFY_ALIAS} - # env: - # NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - # NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} - # NETLIFY_MESSAGE: doc-${{ steps.source-run-info.outputs.targetBranch }} - # NETLIFY_ALIAS: doc-${{ steps.source-run-info.outputs.targetBranch }} - # if: steps.download-doc.outcome == 'success' - - # - name: Deploy to netlify with doc-release alias - # uses: netlify/actions/cli@master - # with: - # args: deploy --dir=livedoc/livedoc --message doc-release --alias doc-release - # env: - # NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - # NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} - # if: steps.download-doc.outcome == 'success' - - # - name: Report deployment url - # run: | - # echo "::notice::The live documentation has been deployed - ${{ steps.deploy-netlify.outputs.NETLIFY_URL }}" - # if: steps.download-doc.outcome == 'success'