@@ -516,7 +516,7 @@ test-wasmer-sandbox:
516516 variables :
517517 << : *default-vars
518518 script :
519- - time cargo test --release --features runtime-benchmarks,wasmer-sandbox
519+ - time cargo test --release --features runtime-benchmarks,wasmer-sandbox,disable-ui-tests
520520 - sccache -s
521521
522522cargo-check-macos :
@@ -618,6 +618,7 @@ build-rustdoc:
618618 variables :
619619 << : *default-vars
620620 SKIP_WASM_BUILD : 1
621+ DOC_INDEX_PAGE : " sc_service/index.html" # default redirected page
621622 artifacts :
622623 name : " ${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}-doc"
623624 when : on_success
@@ -632,7 +633,7 @@ build-rustdoc:
632633 - mv ./target/doc ./crate-docs
633634 # FIXME: remove me after CI image gets nonroot
634635 - chown -R nonroot:nonroot ./crate-docs
635- - echo "<meta http-equiv=refresh content=0;url=sc_service/index.html >" > ./crate-docs/index.html
636+ - echo "<meta http-equiv=refresh content=0;url=${DOC_INDEX_PAGE} >" > ./crate-docs/index.html
636637 - sccache -s
637638
638639# ### stage: publish
@@ -728,42 +729,73 @@ publish-rustdoc:
728729 stage : publish
729730 << : *kubernetes-env
730731 << : *vault-secrets
731- image : paritytech/tools:latest
732+ image : node:16
732733 variables :
733734 GIT_DEPTH : 100
735+ # --- Following variables are for rustdocs deployment ---
736+ # Space separated values of branches and tags to generate rustdocs
737+ RUSTDOCS_DEPLOY_REFS : " master monthly-2021-09+1 monthly-2021-08 v3.0.0"
738+ # Location of the docs index template
739+ INDEX_TPL : " .maintain/docs-index-tpl.ejs"
740+ # Where the `/latest` symbolic link links to. One of the $RUSTDOCS_DEPLOY_REFS value.
741+ LATEST : " monthly-2021-09+1"
734742 rules :
735743 - if : $CI_PIPELINE_SOURCE == "pipeline"
736744 when : never
737745 - if : $CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_REF_NAME == "master"
738746 - if : $CI_COMMIT_REF_NAME == "master"
747+ - if : $CI_COMMIT_REF_NAME =~ /^monthly-20[0-9]{2}-[0-9]{2}.*$/ # to support: monthly-2021-09+1
748+ - if : $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
739749 # `needs:` can be removed after CI image gets nonroot. In this case `needs:` stops other
740750 # artifacts from being dowloaded by this job.
741751 needs :
742752 - job : build-rustdoc
743753 artifacts : true
744754 script :
755+ # If $CI_COMMIT_REF_NAME doesn't match one of $RUSTDOCS_DEPLOY_REFS space-separated values, we
756+ # exit immediately.
757+ # Putting spaces at the front and back to ensure we are not matching just any substring, but the
758+ # whole space-separated value.
759+ - ' [[ " ${RUSTDOCS_DEPLOY_REFS} " =~ " ${CI_COMMIT_REF_NAME} " ]] || exit 0'
745760 - rm -rf /tmp/*
746761 # Set git config
747762 - rm -rf .git/config
748763 - git config user.email "devops-team@parity.io"
749764 - git config user.name "${GITHUB_USER}"
750- - git config remote.origin.url "https://${GITHUB_TOKEN}@github.com/paritytech/substrate .git"
765+ - git config remote.origin.url "https://${GITHUB_TOKEN}@github.com/paritytech/${CI_PROJECT_NAME} .git"
751766 - git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
752767 - git fetch origin gh-pages
768+ # Install `ejs` and generate index.html based on RUSTDOCS_DEPLOY_REFS
769+ - yarn global add ejs
770+ - ' ejs ${INDEX_TPL} -i "{\"deploy_refs\":\"${RUSTDOCS_DEPLOY_REFS}\",\"repo_name\":\"${CI_PROJECT_NAME}\",\"latest\":\"${LATEST}\"}" > /tmp/index.html'
753771 # Save README and docs
754772 - cp -r ./crate-docs/ /tmp/doc/
755773 - cp README.md /tmp/doc/
756774 - git checkout gh-pages
757- # Remove everything and restore generated docs and README
758- - rm -rf ./*
759- - mv /tmp/doc/* .
775+ # Remove directories no longer necessary, as specified in $RUSTDOCS_DEPLOY_REFS.
776+ # Also ensure $RUSTDOCS_DEPLOY_REFS is non-space
777+ - if [[ ! -z ${RUSTDOCS_DEPLOY_REFS// } ]]; then
778+ for FILE in *; do
779+ if [[ ! " $RUSTDOCS_DEPLOY_REFS " =~ " $FILE " ]]; then
780+ echo "Removing ${FILE}..."
781+ rm -rf $FILE
782+ fi
783+ done
784+ fi
785+ # Move the index page & built back
786+ - mv -f /tmp/index.html .
787+ # Ensure the destination dir doesn't exist.
788+ - rm -rf ${CI_COMMIT_REF_NAME}
789+ - mv -f /tmp/doc ${CI_COMMIT_REF_NAME}
790+ # Add the symlink
791+ - ' [[ -e "$LATEST" ]] && ln -sf "${LATEST}" latest'
760792 # Upload files
761793 - git add --all --force
762794 # `git commit` has an exit code of > 0 if there is nothing to commit.
763795 # This causes GitLab to exit immediately and marks this job failed.
764796 # We don't want to mark the entire job failed if there's nothing to
765797 # publish though, hence the `|| true`.
766- - git commit -m "Updated docs for ${CI_COMMIT_REF_NAME}" ||
798+ - git commit -m "___Updated docs for ${CI_COMMIT_REF_NAME}___ " ||
767799 echo "___Nothing to commit___"
768800 - git push origin gh-pages --force
769801 after_script :
0 commit comments