ci: Refactor linting workflow (no-changelog) (#9714)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2024-06-13 13:10:51 +02:00 committed by GitHub
parent cfef49e60a
commit ab29ba9b58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 77 additions and 62 deletions

View file

@ -46,34 +46,12 @@ jobs:
collectCoverage: true collectCoverage: true
lint: lint:
name: Lint changes name: Lint
runs-on: ubuntu-latest uses: ./.github/workflows/linting-reusable.yml
needs: install-and-build needs: install-and-build
steps: with:
- uses: actions/checkout@v4.1.1 ref: ${{ inputs.branch }}
with: cacheKey: ${{ github.sha }}-base:build
repository: n8n-io/n8n
ref: ${{ inputs.branch }}
- run: corepack enable
- uses: actions/setup-node@v4.0.2
with:
node-version: 20.x
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Restore cached build artifacts
uses: actions/cache/restore@v4.0.0
with:
path: ./packages/**/dist
key: ${{ github.sha }}-base:build
- name: Lint
env:
CI_LINT_MASTER: true
run: pnpm lint
notify-on-failure: notify-on-failure:
name: Notify Slack on failure name: Notify Slack on failure

View file

@ -3,7 +3,7 @@ name: Build, unit test and lint branch
on: [pull_request] on: [pull_request]
jobs: jobs:
install: install-and-build:
name: Install & Build name: Install & Build
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -36,35 +36,15 @@ jobs:
unit-test: unit-test:
name: Unit tests name: Unit tests
uses: ./.github/workflows/units-tests-reusable.yml uses: ./.github/workflows/units-tests-reusable.yml
needs: install needs: install-and-build
with: with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge ref: refs/pull/${{ github.event.pull_request.number }}/merge
cacheKey: ${{ github.sha }}-base:build cacheKey: ${{ github.sha }}-base:build
lint: lint:
name: Lint changes name: Lint
runs-on: ubuntu-latest uses: ./.github/workflows/linting-reusable.yml
needs: install needs: install-and-build
steps: with:
- uses: actions/checkout@v4.1.1 ref: refs/pull/${{ github.event.pull_request.number }}/merge
with: cacheKey: ${{ github.sha }}-base:build
repository: n8n-io/n8n
ref: refs/pull/${{ github.event.pull_request.number }}/merge
- run: corepack enable
- uses: actions/setup-node@v4.0.2
with:
node-version: 20.x
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Restore cached build artifacts
uses: actions/cache/restore@v4.0.0
with:
path: ./packages/**/dist
key: ${{ github.sha }}-base:build
- name: Lint
run: pnpm lint

54
.github/workflows/linting-reusable.yml vendored Normal file
View file

@ -0,0 +1,54 @@
name: Reusable linting workflow
on:
workflow_call:
inputs:
ref:
description: GitHub ref to lint.
required: false
type: string
default: master
cacheKey:
description: Cache key for modules and build artifacts.
required: false
default: ''
type: string
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
with:
repository: n8n-io/n8n
ref: ${{ inputs.ref }}
- run: corepack enable
- uses: actions/setup-node@v4.0.2
with:
node-version: 20.x
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
if: ${{ inputs.cacheKey == '' }}
run: pnpm build
- name: Restore cached build artifacts
if: ${{ inputs.cacheKey != '' }}
uses: actions/cache/restore@v4.0.0
with:
path: ./packages/**/dist
key: ${{ inputs.cacheKey }}
- name: Lint Backend
run: pnpm lint:backend
- name: Lint Nodes
run: pnpm lint:nodes
- name: Lint Frontend
run: pnpm lint:frontend

View file

@ -4,24 +4,24 @@ on:
workflow_call: workflow_call:
inputs: inputs:
ref: ref:
description: 'GitHub ref to test.' description: GitHub ref to test.
required: false required: false
type: string type: string
default: 'master' default: master
nodeVersion: nodeVersion:
description: 'Version of node to use.' description: Version of node to use.
required: false required: false
type: string type: string
default: 20.x default: 20.x
cacheKey: cacheKey:
description: 'Cache key for modules and build artifacts.' description: Cache key for modules and build artifacts.
required: false required: false
default: '' default: ''
type: string type: string
collectCoverage: collectCoverage:
required: false required: false
default: 'false' default: false
type: string type: boolean
jobs: jobs:
unit-test: unit-test:
@ -66,7 +66,7 @@ jobs:
run: pnpm test:frontend run: pnpm test:frontend
- name: Upload coverage to Codecov - name: Upload coverage to Codecov
if: ${{ inputs.collectCoverage == 'true' }} if: inputs.collectCoverage
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3
with: with:
files: packages/@n8n/chat/coverage/cobertura-coverage.xml,packages/@n8n/nodes-langchain/coverage/cobertura-coverage.xml,packages/@n8n/permissions/coverage/cobertura-coverage.xml,packages/@n8n/client-oauth2/coverage/cobertura-coverage.xml,packages/cli/coverage/cobertura-coverage.xml,packages/core/coverage/cobertura-coverage.xml,packages/design-system/coverage/cobertura-coverage.xml,packages/@n8n/codemirror-lang/coverage/cobertura-coverage.xml,packages/editor-ui/coverage/cobertura-coverage.xml,packages/nodes-base/coverage/cobertura-coverage.xml,packages/workflow/coverage/cobertura-coverage.xml files: packages/@n8n/chat/coverage/cobertura-coverage.xml,packages/@n8n/nodes-langchain/coverage/cobertura-coverage.xml,packages/@n8n/permissions/coverage/cobertura-coverage.xml,packages/@n8n/client-oauth2/coverage/cobertura-coverage.xml,packages/cli/coverage/cobertura-coverage.xml,packages/core/coverage/cobertura-coverage.xml,packages/design-system/coverage/cobertura-coverage.xml,packages/@n8n/codemirror-lang/coverage/cobertura-coverage.xml,packages/editor-ui/coverage/cobertura-coverage.xml,packages/nodes-base/coverage/cobertura-coverage.xml,packages/workflow/coverage/cobertura-coverage.xml

View file

@ -20,6 +20,9 @@
"format": "turbo run format && node scripts/format.mjs", "format": "turbo run format && node scripts/format.mjs",
"lint": "turbo run lint", "lint": "turbo run lint",
"lintfix": "turbo run lintfix", "lintfix": "turbo run lintfix",
"lint:backend": "pnpm --filter=!@n8n/chat --filter=!@n8n/codemirror-lang --filter=!n8n-design-system --filter=!n8n-editor-ui --filter=!n8n-nodes-base --filter=!@n8n/n8n-nodes-langchain lint",
"lint:nodes": "pnpm --filter=n8n-nodes-base --filter=@n8n/n8n-nodes-langchain lint",
"lint:frontend": "pnpm --filter=@n8n/chat --filter=@n8n/codemirror-lang --filter=n8n-design-system --filter=n8n-editor-ui lint",
"optimize-svg": "find ./packages -name '*.svg' ! -name 'pipedrive.svg' -print0 | xargs -0 -P16 -L20 npx svgo", "optimize-svg": "find ./packages -name '*.svg' ! -name 'pipedrive.svg' -print0 | xargs -0 -P16 -L20 npx svgo",
"start": "run-script-os", "start": "run-script-os",
"start:default": "cd packages/cli/bin && ./n8n", "start:default": "cd packages/cli/bin && ./n8n",