From cf8d2f601507ad38d700474da4cee26cc28d9d54 Mon Sep 17 00:00:00 2001 From: ahnpnl <27772165+ahnpnl@users.noreply.github.com> Date: Tue, 7 May 2024 12:47:47 +0700 Subject: [PATCH 1/2] ci: improve pipeline for documentation - Add cache and restore `node_modules` step - Add path filtering - Add `fetch-depth` and `fetch-tags` for checkout step - Rename file from `doc-generator` -> `doc_ci` --- .github/workflows/doc-generator.yml | 52 ----------------- .github/workflows/doc_ci.yml | 89 +++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 52 deletions(-) delete mode 100644 .github/workflows/doc-generator.yml create mode 100644 .github/workflows/doc_ci.yml diff --git a/.github/workflows/doc-generator.yml b/.github/workflows/doc-generator.yml deleted file mode 100644 index ca2e59f506..0000000000 --- a/.github/workflows/doc-generator.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: doc-generator - -on: - push: - branches: - - main - pull_request: - branches: - - '**' - -concurrency: - group: doc-generator-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - checks: - if: github.event_name != 'push' - runs-on: ubuntu-latest - steps: - - name: Checkout ๐Ÿ›Ž๏ธ - uses: actions/checkout@v4 # If you're using actions/checkout@v3 you must set persist-credentials to false in most cases for the deployment to work correctly. - with: - persist-credentials: false - - - name: Install and Build ๐Ÿ”ง - run: | - cd website - yarn - yarn build - - build-and-deploy: - if: github.event_name != 'pull_request' - runs-on: ubuntu-latest - steps: - - name: Checkout ๐Ÿ›Ž๏ธ - uses: actions/checkout@v4 # If you're using actions/checkout@v3 you must set persist-credentials to false in most cases for the deployment to work correctly. - with: - persist-credentials: false - - - name: Install and Build ๐Ÿ”ง - run: | - cd website - yarn - yarn build - - - name: Deploy ๐Ÿš€ - uses: JamesIves/github-pages-deploy-action@v4.6.0 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: gh-pages # The branch the action should deploy to. - FOLDER: website/build # The folder the action should deploy. - CLEAN: true # Automatically remove deleted files from the deploy branch diff --git a/.github/workflows/doc_ci.yml b/.github/workflows/doc_ci.yml new file mode 100644 index 0000000000..1a3bf9e6c3 --- /dev/null +++ b/.github/workflows/doc_ci.yml @@ -0,0 +1,89 @@ +name: Documentation CI + +on: + push: + branches: + - main + pull_request: + branches: + - '**' + paths: + - 'website/**' + - '.github/**' + - '.yarn/**' + - .yarnrc.yml + - .npmignore + - .gitignore + +concurrency: + group: doc-generator-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + checks: + if: github.event_name != 'push' + runs-on: ubuntu-latest + steps: + - name: Checkout ๐Ÿ›Ž๏ธ + uses: actions/checkout@v4 # If you're using actions/checkout@v3 you must set persist-credentials to false in most cases for the deployment to work correctly. + with: + persist-credentials: false + fetch-depth: 20 + fetch-tags: false + + - name: Restore cached node modules โ™ป๏ธ + id: cache-yarn + uses: actions/cache@v4 + with: + path: | + website/node_modules + website/.yarn + key: ${{ runner.os }}-build-doc-${{ hashFiles('**/yarn.lock') }} + restore-keys: ${{ runner.os }}-build-doc + + - name: Install ๐Ÿ”ง + if: ${{ steps.cache-yarn.outputs.cache-hit != 'true' }} + run: yarn + working-directory: website + + - name: Build ๐Ÿ”จ + run: yarn build + working-directory: website + + build-and-deploy: + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + steps: + - name: Checkout ๐Ÿ›Ž๏ธ + uses: actions/checkout@v4 # If you're using actions/checkout@v3 you must set persist-credentials to false in most cases for the deployment to work correctly. + with: + persist-credentials: false + fetch-depth: 20 + fetch-tags: false + + - name: Restore cached node modules โ™ป๏ธ + id: cache-yarn + uses: actions/cache@v4 + with: + path: | + website/node_modules + website/.yarn + key: ${{ runner.os }}-build-doc-${{ hashFiles('**/yarn.lock') }} + restore-keys: ${{ runner.os }}-build-doc + + - name: Install ๐Ÿ”ง + if: ${{ steps.cache-yarn.outputs.cache-hit != 'true' }} + run: yarn + working-directory: website + + - name: Build ๐Ÿ”จ + run: yarn build + working-directory: website + + - name: Deploy ๐Ÿš€ + uses: JamesIves/github-pages-deploy-action@v4.6.0 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages # The branch the action should deploy to. + FOLDER: website/build # The folder the action should deploy. + CLEAN: true # Automatically remove deleted files from the deploy branch From 91e5710945c5c4f6e73b2b56c98ff18066330708 Mon Sep 17 00:00:00 2001 From: ahnpnl <27772165+ahnpnl@users.noreply.github.com> Date: Tue, 7 May 2024 13:01:44 +0700 Subject: [PATCH 2/2] ci: improve pipeline for source codes verification - Rename CI config file from `ci` -> `source_codes_ci` - Add `paths-ignore` to skip CI running when changing to `website` - Adjust cache restore key name to use workflow input `os` instead of runner OS --- .github/workflows/code_standard_check.yml | 14 ++++++++------ .github/workflows/install.yml | 12 +++++++----- .github/workflows/{ci.yml => source_codes_ci.yml} | 6 +++++- .github/workflows/test.yml | 14 ++++++++------ 4 files changed, 28 insertions(+), 18 deletions(-) rename .github/workflows/{ci.yml => source_codes_ci.yml} (92%) diff --git a/.github/workflows/code_standard_check.yml b/.github/workflows/code_standard_check.yml index 947e427caa..af8ec7d36b 100644 --- a/.github/workflows/code_standard_check.yml +++ b/.github/workflows/code_standard_check.yml @@ -18,12 +18,13 @@ jobs: runs-on: ${{ inputs.os }} steps: - - uses: actions/checkout@v4 + - name: Checkout ๐Ÿ›Ž๏ธ + uses: actions/checkout@v4 with: fetch-depth: 20 fetch-tags: false - - name: Restore cached node modules + - name: Restore cached node modules โ™ป๏ธ id: cache-yarn uses: actions/cache@v4 with: @@ -36,14 +37,15 @@ jobs: examples/example-app-yarn-workspace/node_modules key: ${{ inputs.os }}-${{ inputs.node }}-build-${{ hashFiles('**/yarn.lock') }} restore-keys: | - ${{ runner.os }}-${{ inputs.node }}-build + ${{ inputs.os }}-${{ inputs.node }}-build - - uses: actions/setup-node@v4 + - name: Setup Node version โš™๏ธ + uses: actions/setup-node@v4 with: node-version: ${{ inputs.node }} - - name: Run ESLint check + - name: Run ESLint check ๐Ÿ”๏ธ run: yarn lint - - name: Run Prettier check + - name: Run Prettier check ๐Ÿ”๏ธ run: yarn lint-prettier-ci diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index 54cdd21780..fafb4c2871 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -19,12 +19,13 @@ jobs: runs-on: ${{ inputs.os }} steps: - - uses: actions/checkout@v4 + - name: Checkout ๐Ÿ›Ž๏ธ + uses: actions/checkout@v4 with: fetch-depth: 20 fetch-tags: false - - name: Restore cached node modules + - name: Restore cached node modules โ™ป๏ธ id: cache-yarn uses: actions/cache@v4 with: @@ -37,14 +38,15 @@ jobs: examples/example-app-yarn-workspace/node_modules key: ${{ inputs.os }}-${{ inputs.node }}-build-${{ hashFiles('**/yarn.lock') }} restore-keys: | - ${{ runner.os }}-${{ inputs.node }}-build + ${{ inputs.os }}-${{ inputs.node }}-build - - uses: actions/setup-node@v4 + - name: Setup Node version โš™๏ธ + uses: actions/setup-node@v4 if: ${{ steps.cache-yarn.outputs.cache-hit != 'true' }} with: node-version: ${{ inputs.node }} - - name: Install dependencies + - name: Install ๐Ÿ”ง if: ${{ steps.cache-yarn.outputs.cache-hit != 'true' }} run: | yarn --immutable diff --git a/.github/workflows/ci.yml b/.github/workflows/source_codes_ci.yml similarity index 92% rename from .github/workflows/ci.yml rename to .github/workflows/source_codes_ci.yml index a018ead95b..e91bfa30eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/source_codes_ci.yml @@ -1,12 +1,16 @@ -name: CI +name: Source codes CI on: push: branches: - main + paths-ignore: + - 'website/**' pull_request: branches: - '**' + paths-ignore: + - 'website/**' concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b3d26617f8..1c8a61166f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,12 +18,13 @@ jobs: runs-on: ${{ inputs.os }} steps: - - uses: actions/checkout@v4 + - name: Checkout ๐Ÿ›Ž๏ธ + uses: actions/checkout@v4 with: fetch-depth: 20 fetch-tags: false - - name: Restore cached node modules + - name: Restore cached node modules โ™ป๏ธ id: cache-yarn uses: actions/cache@v4 with: @@ -36,14 +37,15 @@ jobs: examples/example-app-yarn-workspace/node_modules key: ${{ inputs.os }}-${{ inputs.node }}-build-${{ hashFiles('**/yarn.lock') }} restore-keys: | - ${{ runner.os }}-${{ inputs.node }}-build + ${{ inputs.os }}-${{ inputs.node }}-build - - uses: actions/setup-node@v4 + - name: Setup Node version โš™๏ธ + uses: actions/setup-node@v4 with: node-version: ${{ inputs.node }} - - name: Run tests + - name: Run tests ๐Ÿงช run: yarn test - - name: Run tests in example projects + - name: Run tests in example projects ๐Ÿงช run: yarn test-examples