diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 0ef88e4099..938335558e 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -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 + with: + ref: ${{ inputs.branch }} + cacheKey: ${{ github.sha }}-base:build notify-on-failure: name: Notify Slack on failure diff --git a/.github/workflows/ci-pull-requests.yml b/.github/workflows/ci-pull-requests.yml index f6e9d8a7d5..1bdd6c60b9 100644 --- a/.github/workflows/ci-pull-requests.yml +++ b/.github/workflows/ci-pull-requests.yml @@ -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 - 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 + name: Lint + uses: ./.github/workflows/linting-reusable.yml + needs: install-and-build + with: + ref: refs/pull/${{ github.event.pull_request.number }}/merge + cacheKey: ${{ github.sha }}-base:build diff --git a/.github/workflows/linting-reusable.yml b/.github/workflows/linting-reusable.yml new file mode 100644 index 0000000000..69bccd9ce6 --- /dev/null +++ b/.github/workflows/linting-reusable.yml @@ -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 diff --git a/.github/workflows/units-tests-reusable.yml b/.github/workflows/units-tests-reusable.yml index 5ad5c24f71..61ed73672e 100644 --- a/.github/workflows/units-tests-reusable.yml +++ b/.github/workflows/units-tests-reusable.yml @@ -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 diff --git a/package.json b/package.json index c8021594dc..151beeb2bf 100644 --- a/package.json +++ b/package.json @@ -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",