Skip to content

Commit ee76b9f

Browse files
authored
CI: publish rustdocs (paritytech#9527)
* CI: publish docs to gh-pages * CI: debug * CI: add CI image * CI: chmod for dox * CI: typo * CI: remove ownership debug * CI: unfixme * Revert "CI: debug" This reverts commit f058b73. * CI: build-rust-doc can not fail now * CI: remove publish-s3-doc * CI: chore * CI: less needs * CI: pwd ruins the prettiness * CI: return needs
1 parent 2717d98 commit ee76b9f

File tree

1 file changed

+43
-27
lines changed

1 file changed

+43
-27
lines changed

.gitlab-ci.yml

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -529,13 +529,10 @@ build-macos-subkey:
529529
tags:
530530
- osx
531531

532-
build-rust-doc:
532+
build-rustdoc:
533533
stage: build
534534
<<: *docker-env
535535
<<: *test-refs
536-
needs:
537-
- job: test-linux-stable
538-
artifacts: false
539536
variables:
540537
<<: *default-vars
541538
SKIP_WASM_BUILD: 1
@@ -546,13 +543,15 @@ build-rust-doc:
546543
paths:
547544
- ./crate-docs/
548545
script:
546+
# FIXME: it fails with `RUSTDOCFLAGS="-Dwarnings"`
549547
- RUSTDOCFLAGS="--html-in-header $(pwd)/.maintain/rustdoc-header.html"
550548
time cargo +nightly doc --no-deps --workspace --all-features --verbose
551549
- rm -f ./target/doc/.lock
552550
- mv ./target/doc ./crate-docs
551+
# FIXME: remove me after CI image gets nonroot
552+
- chown -R nonroot:nonroot ./crate-docs
553553
- echo "<meta http-equiv=refresh content=0;url=sc_service/index.html>" > ./crate-docs/index.html
554554
- sccache -s
555-
allow_failure: true
556555

557556
#### stage: publish
558557

@@ -641,32 +640,49 @@ publish-s3-release:
641640
- aws s3 ls s3://${BUCKET}/${PREFIX}/latest/
642641
--recursive --human-readable --summarize
643642

644-
publish-s3-doc:
643+
publish-rustdoc:
645644
stage: publish
646-
image: paritytech/awscli:latest
647-
allow_failure: true
648-
needs:
649-
- job: build-rust-doc
650-
artifacts: true
651-
- job: build-linux-substrate
652-
artifacts: false
653-
<<: *build-refs
654645
<<: *kubernetes-env
646+
image: paritytech/tools:latest
655647
variables:
656-
GIT_STRATEGY: none
657-
BUCKET: "releases.parity.io"
658-
PREFIX: "substrate-rustdoc"
659-
script:
660-
- test -r ./crate-docs/index.html || (
661-
echo "./crate-docs/index.html not present, build:rust:doc:release job not complete";
662-
exit 1
663-
)
664-
- ls -lah crate-docs
665-
- aws s3 sync --delete --size-only --only-show-errors
666-
./crate-docs/ s3://${BUCKET}/${PREFIX}/
648+
GIT_DEPTH: 100
649+
rules:
650+
- if: $CI_PIPELINE_SOURCE == "pipeline"
651+
when: never
652+
- if: $CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_REF_NAME == "master"
653+
- if: $CI_COMMIT_REF_NAME == "master"
654+
# `needs:` can be removed after CI image gets nonroot. In this case `needs:` stops other
655+
# artifacts from being dowloaded by this job.
656+
needs:
657+
- job: build-rustdoc
658+
artifacts: true
659+
script:
660+
- rm -rf /tmp/*
661+
# Set git config
662+
- rm -rf .git/config
663+
- git config user.email "devops-team@parity.io"
664+
- git config user.name "${GITHUB_USER}"
665+
- git config remote.origin.url "https://${GITHUB_TOKEN}@github.com/paritytech/substrate.git"
666+
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
667+
- git fetch origin gh-pages
668+
# Save README and docs
669+
- cp -r ./crate-docs/ /tmp/doc/
670+
- cp README.md /tmp/doc/
671+
- git checkout gh-pages
672+
# Remove everything and restore generated docs and README
673+
- rm -rf ./*
674+
- mv /tmp/doc/* .
675+
# Upload files
676+
- git add --all --force
677+
# `git commit` has an exit code of > 0 if there is nothing to commit.
678+
# This causes GitLab to exit immediately and marks this job failed.
679+
# We don't want to mark the entire job failed if there's nothing to
680+
# publish though, hence the `|| true`.
681+
- git commit -m "Updated docs for ${CI_COMMIT_REF_NAME}" ||
682+
echo "___Nothing to commit___"
683+
- git push origin gh-pages --force
667684
after_script:
668-
- aws s3 ls s3://${BUCKET}/${PREFIX}/
669-
--human-readable --summarize
685+
- rm -rf .git/ ./*
670686

671687
publish-draft-release:
672688
stage: publish

0 commit comments

Comments
 (0)