From 9ff0ecfbc8b1d64b4b552b9ac41437b8e90c47cc Mon Sep 17 00:00:00 2001 From: Chef Jerry <144641937+ChefJerry@users.noreply.github.com> Date: Thu, 29 Aug 2024 17:31:43 +0800 Subject: [PATCH] feat: install actions (#10573) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ## PR-Codex overview The focus of this PR is to refactor workflow files to use a custom action for installing dependencies and standardize the checkout action. ### Detailed summary - Created a custom action `Install Dependencies` to install dependencies with `pnpm` - Updated workflow files to use the custom action for installing dependencies - Standardized the `Checkout` action in all workflow files to use `actions/checkout@v4` > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .github/actions/install-deps/action.yml | 19 ++++++ .github/workflows/deploy-apis.yml | 12 +--- .github/workflows/farmConfig.yml | 26 +------- .github/workflows/format.yml | 28 ++------- .github/workflows/lint.yml | 28 ++------- .github/workflows/release.yml | 28 ++------- .github/workflows/testConfig.yml | 28 +-------- .github/workflows/unitTests.yml | 28 +-------- .github/workflows/updateCron.yml | 84 ++++--------------------- 9 files changed, 53 insertions(+), 228 deletions(-) create mode 100644 .github/actions/install-deps/action.yml diff --git a/.github/actions/install-deps/action.yml b/.github/actions/install-deps/action.yml new file mode 100644 index 0000000000000..d5fcd5981ccde --- /dev/null +++ b/.github/actions/install-deps/action.yml @@ -0,0 +1,19 @@ +name: 'Install Dependencies' +description: 'Install dependencies with pnpm' + +runs: + using: 'composite' + steps: + - uses: pnpm/action-setup@v4 + with: + version: 9.8.0 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: '18.20.0' + cache: 'pnpm' + + - name: Install Dependencies + shell: bash + run: pnpm install --ignore-scripts diff --git a/.github/workflows/deploy-apis.yml b/.github/workflows/deploy-apis.yml index 85a5b6ee91468..bb18331ccaa55 100644 --- a/.github/workflows/deploy-apis.yml +++ b/.github/workflows/deploy-apis.yml @@ -31,20 +31,12 @@ jobs: name: Publish API steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 2 - - name: Set up pnpm - uses: pnpm/action-setup@v4 - - name: Set up node@18 - uses: actions/setup-node@v3 - with: - cache: 'pnpm' - node-version: 18.18.2 - - name: Install dependencies - run: pnpm i --ignore-scripts + uses: './.github/actions/install-deps' - name: Build package run: pnpm build:packages diff --git a/.github/workflows/farmConfig.yml b/.github/workflows/farmConfig.yml index ed5d1dcd5237d..6c1ea17f0ff1b 100644 --- a/.github/workflows/farmConfig.yml +++ b/.github/workflows/farmConfig.yml @@ -22,34 +22,12 @@ jobs: name: Publish Farm Config to Cloudflare Pages steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 2 - - name: Set up pnpm - uses: pnpm/action-setup@v4 - - name: Set up node@18 - uses: actions/setup-node@v3 - with: - cache: 'pnpm' - node-version: 18.18.2 - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Install dependencies - run: pnpm i --ignore-scripts + uses: './.github/actions/install-deps' - name: Build package run: pnpm build:packages diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index d6c16a7433b53..94a617eb83e7b 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -9,33 +9,13 @@ jobs: timeout-minutes: 6 steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up pnpm - uses: pnpm/action-setup@v4 - - name: Set up node@18 - uses: actions/setup-node@v3 - with: - cache: 'pnpm' - node-version: 18.18.2 - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache + - name: Checkout + uses: actions/checkout@v4 with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- + fetch-depth: 2 - name: Install dependencies - run: pnpm i --ignore-scripts + uses: './.github/actions/install-deps' - name: Run Prettier run: pnpm format:check diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8fe571269eae8..a94026a7003b6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,33 +12,13 @@ jobs: timeout-minutes: 4 steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up pnpm - uses: pnpm/action-setup@v4 - - name: Set up node@18 - uses: actions/setup-node@v3 - with: - cache: 'pnpm' - node-version: 18.18.2 - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache + - name: Checkout + uses: actions/checkout@v4 with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- + fetch-depth: 2 - name: Install dependencies - run: pnpm i --ignore-scripts + uses: './.github/actions/install-deps' - name: Run ESLint run: pnpm lint:report diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2f602f675c46b..779e98c937546 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,33 +14,13 @@ jobs: runs-on: ubuntu-latest if: github.repository == 'pancakeswap/pancake-frontend' steps: - - name: Checkout Repo - uses: actions/checkout@v3 - - - name: Set up pnpm - uses: pnpm/action-setup@v4 - - name: Set up node@18 - uses: actions/setup-node@v3 - with: - cache: 'pnpm' - node-version: 18.18.2 - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache + - name: Checkout + uses: actions/checkout@v4 with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- + fetch-depth: 2 - name: Install dependencies - run: pnpm i --ignore-scripts + uses: './.github/actions/install-deps' - name: Create Release Pull Request or Publish to npm id: changesets diff --git a/.github/workflows/testConfig.yml b/.github/workflows/testConfig.yml index 3993b9f28a29e..300d51592de59 100644 --- a/.github/workflows/testConfig.yml +++ b/.github/workflows/testConfig.yml @@ -24,35 +24,13 @@ jobs: name: Config (Jest) steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v4 with: fetch-depth: 2 - - name: Set up pnpm - uses: pnpm/action-setup@v4 - - name: Set up node@18 - uses: actions/setup-node@v3 - with: - cache: 'pnpm' - node-version: 18.18.2 - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Install dependencies - run: pnpm i --ignore-scripts + uses: './.github/actions/install-deps' - name: Run tests run: pnpm test:config diff --git a/.github/workflows/unitTests.yml b/.github/workflows/unitTests.yml index 9e5a9205bbf1f..2b2f61b47ce8c 100644 --- a/.github/workflows/unitTests.yml +++ b/.github/workflows/unitTests.yml @@ -19,35 +19,13 @@ jobs: name: Unit tests (Jest) steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v4 with: fetch-depth: 2 - - name: Set up pnpm - uses: pnpm/action-setup@v4 - - name: Set up node@18 - uses: actions/setup-node@v3 - with: - cache: 'pnpm' - node-version: 18.18.2 - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Install dependencies - run: pnpm i --ignore-scripts + uses: './.github/actions/install-deps' - name: Run tests run: pnpm test:ci diff --git a/.github/workflows/updateCron.yml b/.github/workflows/updateCron.yml index d1008044b57f2..624db7b5b1b8b 100644 --- a/.github/workflows/updateCron.yml +++ b/.github/workflows/updateCron.yml @@ -12,33 +12,13 @@ jobs: runs-on: ubuntu-latest if: github.repository == 'pancakeswap/pancake-frontend' steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up pnpm - uses: pnpm/action-setup@v4 - - name: Set up node@18 - uses: actions/setup-node@v3 - with: - cache: 'pnpm' - node-version: 18.18.2 - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache + - name: Checkout + uses: actions/checkout@v4 with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- + fetch-depth: 2 - name: Install dependencies - run: pnpm i --ignore-scripts + uses: './.github/actions/install-deps' - name: Fetch and save Aptos LP APR data run: pnpm updateAptosLPsAPR @@ -66,33 +46,13 @@ jobs: runs-on: ubuntu-latest if: github.repository == 'pancakeswap/pancake-frontend' steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up pnpm - uses: pnpm/action-setup@v4 - - name: Set up node@18 - uses: actions/setup-node@v3 - with: - cache: 'pnpm' - node-version: 18.18.2 - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache + - name: Checkout + uses: actions/checkout@v4 with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- + fetch-depth: 2 - name: Install dependencies - run: pnpm i --ignore-scripts + uses: './.github/actions/install-deps' - name: Fetch and save LP APR data run: pnpm updateLPsAPR @@ -123,33 +83,13 @@ jobs: runs-on: ubuntu-latest if: github.repository == 'pancakeswap/pancake-frontend' steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up pnpm - uses: pnpm/action-setup@v4 - - name: Set up node@18 - uses: actions/setup-node@v3 - with: - cache: 'pnpm' - node-version: 18.18.2 - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache + - name: Checkout + uses: actions/checkout@v4 with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- + fetch-depth: 2 - name: Install dependencies - run: pnpm i --ignore-scripts + uses: './.github/actions/install-deps' - name: Fetch and save Merkl data run: pnpm updateMerkl