Skip to content

Commit

Permalink
setup-yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenliang123 committed Nov 8, 2024
1 parent 172c7eb commit 23e291b
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 34 deletions.
26 changes: 26 additions & 0 deletions .github/actions/setup-yarn/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Setup Yarn and NodeJS

inputs:
node-version:
description: NodeJS version to use and the Yarn installed with
required: true
default: 20
yarn-lockfile:
description: Path to the Yarn lockfile to restore cache from
required: true

runs:
using: composite
steps:
- name: Set up Python ${{ inputs.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: yarn
cache-dependency-path: ${{ inputs.yarn-lockfile }}

- name: Install Yarn packages
shell: bash
run: |
cd "$(dirname "${{ inputs.yarn-lockfile }}")"
yarn install --frozen-lockfile
16 changes: 6 additions & 10 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,15 @@ jobs:
id: changed-files
uses: tj-actions/changed-files@v45
with:
files: web/**
files: |
web/**
.github/workflows/style.yml
- name: Setup NodeJS
uses: actions/setup-node@v4
- name: Setup NodeJS and Install Yarn dependencies
uses: ./.github/actions/setup-yarn
if: steps.changed-files.outputs.any_changed == 'true'
with:
node-version: 20
cache: yarn
cache-dependency-path: ./web/package.json

- name: Web dependencies
if: steps.changed-files.outputs.any_changed == 'true'
run: yarn install --frozen-lockfile
yarn-lockfile: web/yarn.lock

- name: Web style check
if: steps.changed-files.outputs.any_changed == 'true'
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/tool-test-sdks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
paths:
- sdks/**
- .github/workflows/tool-test-sdks.yaml

concurrency:
group: sdk-tests-${{ github.head_ref || github.run_id }}
Expand All @@ -27,15 +28,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
- name: Setup NodeJS ${{ matrix.node-version }} and Install Yarn dependencies
uses: ./.github/actions/setup-yarn
with:
node-version: ${{ matrix.node-version }}
cache: ''
cache-dependency-path: 'yarn.lock'

- name: Install Dependencies
run: yarn install
yarn-lockfile: sdks/nodejs-client/yarn.lock

- name: Test
run: yarn test
9 changes: 3 additions & 6 deletions .github/workflows/translate-i18n-base-on-english.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@ jobs:
echo "FILES_CHANGED=false" >> $GITHUB_ENV
fi
- name: Set up Node.js
- name: Setup NodeJS and Install Yarn dependencies
uses: ./.github/actions/setup-yarn
if: env.FILES_CHANGED == 'true'
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
yarn-lockfile: ./web/yarn.lock

- name: Install dependencies
if: env.FILES_CHANGED == 'true'
run: yarn install --frozen-lockfile

- name: Run npm script
if: env.FILES_CHANGED == 'true'
Expand Down
17 changes: 7 additions & 10 deletions .github/workflows/web-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
paths:
- web/**
- .github/workflows/web-tests.yml

concurrency:
group: web-tests-${{ github.head_ref || github.run_id }}
Expand All @@ -27,19 +28,15 @@ jobs:
id: changed-files
uses: tj-actions/changed-files@v45
with:
files: web/**
files: |
web/**
.github/workflows/web-tests.yml
- name: Setup Node.js
uses: actions/setup-node@v4
- name: Setup NodeJS and Install Yarn dependencies
uses: ./.github/actions/setup-yarn
if: steps.changed-files.outputs.any_changed == 'true'
with:
node-version: 20
cache: yarn
cache-dependency-path: ./web/package.json

- name: Install dependencies
if: steps.changed-files.outputs.any_changed == 'true'
run: yarn install --frozen-lockfile
yarn-lockfile: web/yarn.lock

- name: Run tests
if: steps.changed-files.outputs.any_changed == 'true'
Expand Down
1 change: 0 additions & 1 deletion web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ If you are not familiar with writing tests, here is some code to refer to:




## Documentation

Visit <https://docs.dify.ai/getting-started/readme> to view the full documentation.
Expand Down

0 comments on commit 23e291b

Please sign in to comment.