From 5007cc931eaff033bcadc4652857f7d3f4915aa5 Mon Sep 17 00:00:00 2001 From: sahithiacn Date: Tue, 7 Mar 2023 10:28:34 +0000 Subject: [PATCH] [github] Automatically generate the Book --- .github/workflows/ci-post-land.yml | 124 +++--------------- .../{ci-test.yml => ci-pre-land.yml} | 10 +- 2 files changed, 24 insertions(+), 110 deletions(-) rename .github/workflows/{ci-test.yml => ci-pre-land.yml} (98%) diff --git a/.github/workflows/ci-post-land.yml b/.github/workflows/ci-post-land.yml index 2eb21c5987..e5ba437abc 100644 --- a/.github/workflows/ci-post-land.yml +++ b/.github/workflows/ci-post-land.yml @@ -1,116 +1,30 @@ +# CI jobs to be run upon the code lands to the main branch or GitHub Action test branches. + name: ci-post-land on: - create: - branches: [main, release-*] push: - branches: [main, release-*, gha-test-*] - -defaults: - run: - shell: bash - -env: - max_threads: 16 - pre_command: cd /opt/git/diem/ + branches: [main, gha-test-*] jobs: - prepare: + generate-documentation: + name: Generate the Move Book using mdBook runs-on: ubuntu-20.04 - outputs: - changes-target-branch: ${{ steps.changes.outputs.changes-target-branch }} - changes-base-git-rev: ${{ steps.changes.outputs.changes-base-git-rev }} - changes-base-githash: ${{ steps.changes.outputs.changes-base-githash }} - changes-pull-request-number: ${{ steps.changes.outputs.changes-pull-request-number }} - rust-changes: ${{ steps.rust-changes.outputs.changes-found }} - base-image-changes: ${{ steps.base-image-changes.outputs.changes-found }} + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} steps: - - uses: actions/checkout@v2.4.0 - with: - # This ensures that the tip of the PR is checked out instead of the merge between the base ref and the tip - # On `push` this value will be empty and will "do-the-right-thing" - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 #get all the history!!! - - name: Git Hooks and Checks - run: ./scripts/git-checks.sh - - id: changes - name: determine changes - uses: diem/actions/changes@faadd16607b77dfa2231a8f366883e01717b3225 - with: - workflow-file: ci-post-land.yml - github-token: ${{secrets.GITHUB_TOKEN}} - - id: rust-changes - name: find rust/cargo changes. - uses: diem/actions/matches@faadd16607b77dfa2231a8f366883e01717b3225 - with: - pattern: '^documentation\|^docker\|^scripts\|^developers.diem.com' - invert: "true" - - id: base-image-changes - name: find dev-setup.sh/base docker image changes - uses: diem/actions/matches@faadd16607b77dfa2231a8f366883e01717b3225 - with: - pattern: '.github/workflows/ci-post-land.yml\|.github/actions/dockerhub_login/action.yml\|docker/ci/github/Dockerfile\|scripts/dev_setup.sh\|rust-toolchain' + - uses: actions/checkout@v2 - build_ci_base_docker_image: - needs: prepare - runs-on: ubuntu-20.04-xl - if: ${{ needs.prepare.outputs.base-image-changes == 'true' || github.event_name == 'create' }} - env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }}_build_environment - IMAGE_TAG: ${{ needs.prepare.outputs.changes-target-branch }} - steps: - - uses: actions/checkout@v2.4.0 - with: - # This ensures that the tip of the PR is checked out instead of the merge between the base ref and the tip - # On `push` this value will be empty and will "do-the-right-thing" - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 #get all the history!!! - - name: Log in to the Container registry - uses: docker/login-action@v1 + - name: Setup mdBook + uses: peaceiris/actions-mdbook@v1 with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: build image - run: docker build -f docker/ci/github/Dockerfile -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} . - - name: Push to ghcr - run: | - docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} + mdbook-version: '0.4.10' + # mdbook-version: 'latest' - # rustdoc: - # needs: prepare - # if: ${{ needs.prepare.outputs.changes-target-branch == 'main' && needs.prepare.outputs.rust-changes == 'true'}} - # runs-on: ubuntu-20.04 - # container: - # image: ghcr.io/diem/diem_build_environment:${{ needs.prepare.outputs.changes-target-branch }} - # volumes: - # - "${{github.workspace}}:/opt/git/diem" - # steps: - # - name: Checkout repository - # uses: actions/checkout@v2.4.0 - # - uses: ./.github/actions/build-setup - # - uses: actions/cache@v2.1.6 - # with: - # path: "/opt/cargo/git\n/opt/cargo/registry\n/opt/cargo/.package-cache" - # key: crates-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - # restore-keys: "crates-${{ runner.os }}" - # - name: Build Documentation - # # Build the rust crate docs - # # Use `RUSTC_BOOTSTRAP` in order to use the `--enable-index-page` flag of rustdoc - # # This is needed in order to generate a landing page `index.html` for workspaces - # run: cargo doc --no-deps --workspace --lib - # env: - # RUSTC_BOOTSTRAP: 1 - # RUSTDOCFLAGS: "-Z unstable-options --enable-index-page" - # CARGO_INCREMENTAL: 0 - # RUSTFLAGS: -D warnings - # - name: copy API specification doc into target/doc/diem_api - # run : cp api/doc/openapi.yaml target/doc/diem_api/openapi.yaml && cp api/doc/spec.html target/doc/diem_api/spec.html - # - name: Deploy Docs - # uses: peaceiris/actions-gh-pages@v3.8.0 - # with: - # github_token: ${{ secrets.GITHUB_TOKEN }} - # publish_branch: gh-pages - # publish_dir: ./target/doc - # force_orphan: true + - run: mdbook build language/documentation/book + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./language/documentation/book/book diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-pre-land.yml similarity index 98% rename from .github/workflows/ci-test.yml rename to .github/workflows/ci-pre-land.yml index fc5150d0d9..2f1aa6274f 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-pre-land.yml @@ -1,10 +1,10 @@ -name: ci-test +# CI jobs to be run upon the code lands to the main branch or GitHub Action test branches. + +name: ci-pre-land on: - push: - branches: [auto, canary, gha-test-*] pull_request: - branches: [main, release-*, gha-test-*] + branches: [main, gha-test-*] defaults: run: @@ -39,7 +39,7 @@ jobs: name: determine changes uses: diem/actions/changes@faadd16607b77dfa2231a8f366883e01717b3225 with: - workflow-file: ci-test.yml + workflow-file: ci.yml github-token: ${{secrets.GITHUB_TOKEN}} - id: any-changes-found name: determine if there are any files listed in the CHANGES_CHANGED_FILE_OUTPUTFILE.