Skip to content

Commit

Permalink
feat: install actions (#10573)
Browse files Browse the repository at this point in the history
<!--
Before opening a pull request, please read the [contributing
guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md)
first
-->

<!-- start pr-codex -->

---

## 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}`

<!-- end pr-codex -->
  • Loading branch information
ChefJerry authored Aug 29, 2024
1 parent 5b98344 commit 9ff0ecf
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 228 deletions.
19 changes: 19 additions & 0 deletions .github/actions/install-deps/action.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 2 additions & 10 deletions .github/workflows/deploy-apis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 2 additions & 24 deletions .github/workflows/farmConfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 4 additions & 24 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 4 additions & 24 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 4 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 3 additions & 25 deletions .github/workflows/testConfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 3 additions & 25 deletions .github/workflows/unitTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
84 changes: 12 additions & 72 deletions .github/workflows/updateCron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9ff0ecf

Please sign in to comment.