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
lint:
name: Lint changes
runs-on: ubuntu-latest
name: Lint
uses: ./.github/workflows/linting-reusable.yml
needs: install-and-build
steps:
- uses: actions/checkout@v4.1.1
with:
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
cacheKey: ${{ github.sha }}-base:build
notify-on-failure:
name: Notify Slack on failure

View file

@ -3,7 +3,7 @@ name: Build, unit test and lint branch
on: [pull_request]
jobs:
install:
install-and-build:
name: Install & Build
runs-on: ubuntu-latest
steps:
@ -36,35 +36,15 @@ jobs:
unit-test:
name: Unit tests
uses: ./.github/workflows/units-tests-reusable.yml
needs: install
needs: install-and-build
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
cacheKey: ${{ github.sha }}-base:build
lint:
name: Lint changes
runs-on: ubuntu-latest
needs: install
steps:
- uses: actions/checkout@v4.1.1
name: Lint
uses: ./.github/workflows/linting-reusable.yml
needs: install-and-build
with:
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
cacheKey: ${{ github.sha }}-base:build

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:
inputs:
ref:
description: 'GitHub ref to test.'
description: GitHub ref to test.
required: false
type: string
default: 'master'
default: master
nodeVersion:
description: 'Version of node to use.'
description: Version of node to use.
required: false
type: string
default: 20.x
cacheKey:
description: 'Cache key for modules and build artifacts.'
description: Cache key for modules and build artifacts.
required: false
default: ''
type: string
collectCoverage:
required: false
default: 'false'
type: string
default: false
type: boolean
jobs:
unit-test:
@ -66,7 +66,7 @@ jobs:
run: pnpm test:frontend
- name: Upload coverage to Codecov
if: ${{ inputs.collectCoverage == 'true' }}
if: inputs.collectCoverage
uses: codecov/codecov-action@v3
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

View file

@ -20,6 +20,9 @@
"format": "turbo run format && node scripts/format.mjs",
"lint": "turbo run lint",
"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",
"start": "run-script-os",
"start:default": "cd packages/cli/bin && ./n8n",