This commit is contained in:
Bowen Liang 2024-11-15 16:31:55 +08:00 committed by GitHub
commit 0d089740e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 47 additions and 34 deletions

26
.github/actions/setup-yarn/action.yml vendored Normal file
View File

@ -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

View File

@ -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'

View File

@ -6,6 +6,7 @@ on:
- main
paths:
- sdks/**
- .github/workflows/tool-test-sdks.yaml
concurrency:
group: sdk-tests-${{ github.head_ref || github.run_id }}
@ -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

View File

@ -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'

View File

@ -6,6 +6,7 @@ on:
- main
paths:
- web/**
- .github/workflows/web-tests.yml
concurrency:
group: web-tests-${{ github.head_ref || github.run_id }}
@ -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'

View File

@ -23,3 +23,4 @@ TODO move to another place
## Node.js
TODO move to another place

View File

@ -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.