summaryrefslogtreecommitdiffstats
path: root/.github
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-10-10 08:58:10 +0200
committerJoas Schilling <coding@schilljs.com>2023-10-10 11:39:52 +0200
commit552cb8a64d79c0b4e4c8657311bc10c4bfe6eded (patch)
tree25135bf991265038d545405640389597d132b4bb /.github
parente4c2803895609a95d18691bca91dcd0376bcf47e (diff)
chore(CI): Update NPM and eslint workflows
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/lint-eslint-when-unrelated.yml102
-rw-r--r--.github/workflows/lint-eslint.yml68
-rw-r--r--.github/workflows/node-when-unrelated.yml107
-rw-r--r--.github/workflows/node.yml64
4 files changed, 98 insertions, 243 deletions
diff --git a/.github/workflows/lint-eslint-when-unrelated.yml b/.github/workflows/lint-eslint-when-unrelated.yml
deleted file mode 100644
index 2bd6c9212..000000000
--- a/.github/workflows/lint-eslint-when-unrelated.yml
+++ /dev/null
@@ -1,102 +0,0 @@
-# This workflow is provided via the organization template repository
-#
-# https://github.com/nextcloud/.github
-# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
-#
-# Use lint-eslint together with lint-eslint-when-unrelated to make eslint a required check for GitHub actions
-# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks
-
-name: Lint eslint
-
-on:
- pull_request:
- paths-ignore:
- - '.github/workflows/**'
- - 'src/**'
- - 'appinfo/info.xml'
- - 'package.json'
- - 'package-lock.json'
- - 'tsconfig.json'
- - '.eslintrc.*'
- - '.eslintignore'
- - '**.js'
- - '**.ts'
- - '**.vue'
-
-env:
- PATHS_IGNORE: '.github/workflows/**;src/**;appinfo/info.xml;package.json;package-lock.json;tsconfig.json;.eslintrc.*;.eslintignore;**.js;**.ts;**.vue'
-
-permissions:
- contents: read
-
-jobs:
- action-no-eslint:
- permissions:
- contents: none
- runs-on: ubuntu-latest
-
- name: action-not-src
- outputs:
- found_file: ${{ steps.confirm-negative-list.outputs.result }}
-
- steps:
- - uses: actions/checkout@v3
- with:
- fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
-
- - name: Get changed files from diff
- id: changed-files
- run: |
- if ${{ github.event_name == 'pull_request' }}; then
- echo "changed_files=$(git diff --name-only -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
- else
- echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
- fi
-
- - name: Set up node 20
- uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3
- with:
- node-version: 20
-
- - name: Install minimatch
- run: npm i minimatch
-
- - name: Check if a file is in paths-ignored
- id: confirm-negative-list
- uses: actions/github-script@v5
- with:
- github-token: ${{secrets.GITHUB_TOKEN}}
- result-encoding: string
- script: |
- const { minimatch } = require('minimatch')
- const changedPaths = "${{ steps.changed-files.outputs.changed_files }}".split(' ')
-
- let matched = ''
- process.env.PATHS_IGNORE.split(';').every(pattern => {
- changedPaths.every(path => {
- console.info('Testing ' + path + ' for pattern ' + pattern)
- if (minimatch(path, pattern)) {
- console.info(path + ' matched, aborting "unrelated summary"')
- matched = '1'
- return false
- }
- return true
- })
- return !matched
- })
- return matched
-
- lint:
- permissions:
- contents: none
-
- runs-on: ubuntu-latest
-
- needs: action-no-eslint
-
- name: eslint
-
- if: needs.action-no-eslint.outputs.found_file == ''
-
- steps:
- - run: 'echo "No eslint required"'
diff --git a/.github/workflows/lint-eslint.yml b/.github/workflows/lint-eslint.yml
index 508d71395..096e397fb 100644
--- a/.github/workflows/lint-eslint.yml
+++ b/.github/workflows/lint-eslint.yml
@@ -10,18 +10,6 @@ name: Lint eslint
on:
pull_request:
- paths:
- - '.github/workflows/**'
- - 'src/**'
- - 'appinfo/info.xml'
- - 'package.json'
- - 'package-lock.json'
- - 'tsconfig.json'
- - '.eslintrc.*'
- - '.eslintignore'
- - '**.js'
- - '**.ts'
- - '**.vue'
permissions:
contents: read
@@ -31,24 +19,51 @@ concurrency:
cancel-in-progress: true
jobs:
+ changes:
+ runs-on: ubuntu-latest
+
+ outputs:
+ src: ${{ steps.changes.outputs.src}}
+
+ steps:
+ - uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
+ id: changes
+ with:
+ filters: |
+ src:
+ - '.github/workflows/**'
+ - 'src/**'
+ - 'appinfo/info.xml'
+ - 'package.json'
+ - 'package-lock.json'
+ - 'tsconfig.json'
+ - '.eslintrc.*'
+ - '.eslintignore'
+ - '**.js'
+ - '**.ts'
+ - '**.vue'
+
lint:
runs-on: ubuntu-latest
- name: eslint
+ needs: changes
+ if: needs.changes.outputs.src == 'true'
+
+ name: NPM lint
steps:
- name: Checkout
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
+ uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Read package.json node and npm engines version
- uses: skjnldsv/read-package-engines-version-actions@0ce2ed60f6df073a62a77c0a4958dd0fc68e32e7 # v2.1
+ uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2
id: versions
with:
- fallbackNode: '^16'
- fallbackNpm: '^7'
+ fallbackNode: '^20'
+ fallbackNpm: '^9'
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
+ uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}
@@ -56,7 +71,24 @@ jobs:
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
- name: Install dependencies
+ env:
+ CYPRESS_INSTALL_BINARY: 0
run: npm ci
- name: Lint
run: npm run lint
+
+ summary:
+ permissions:
+ contents: none
+ runs-on: ubuntu-latest
+ needs: [changes, lint]
+
+ if: always()
+
+ # This is the summary, we just avoid to rename it so that branch protection rules still match
+ name: eslint
+
+ steps:
+ - name: Summary status
+ run: if ${{ needs.changes.outputs.src == 'true' && needs.lint.result != 'success' }}; then exit 1; fi
diff --git a/.github/workflows/node-when-unrelated.yml b/.github/workflows/node-when-unrelated.yml
deleted file mode 100644
index f41952993..000000000
--- a/.github/workflows/node-when-unrelated.yml
+++ /dev/null
@@ -1,107 +0,0 @@
-# This workflow is provided via the organization template repository
-#
-# https://github.com/nextcloud/.github
-# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
-#
-# Use node together with node-when-unrelated to make eslint a required check for GitHub actions
-# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks
-
-name: Node
-
-on:
- pull_request:
- paths-ignore:
- - '.github/workflows/**'
- - 'src/**'
- - 'appinfo/info.xml'
- - 'package.json'
- - 'package-lock.json'
- - 'tsconfig.json'
- - '**.js'
- - '**.ts'
- - '**.vue'
- push:
- branches:
- - main
- - master
- - stable*
-
-env:
- PATHS_IGNORE: '.github/workflows/**;src/**;appinfo/info.xml;package.json;package-lock.json;tsconfig.json;**.js;**.ts;**.vue'
-
-concurrency:
- group: node-${{ github.head_ref || github.run_id }}
- cancel-in-progress: true
-
-jobs:
- action-no-build:
- permissions:
- contents: none
- runs-on: ubuntu-latest
-
- name: action-not-src
- outputs:
- found_file: ${{ steps.confirm-negative-list.outputs.result }}
-
- steps:
- - uses: actions/checkout@v3
- with:
- fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
-
- - name: Get changed files from diff
- id: changed-files
- run: |
- if ${{ github.event_name == 'pull_request' }}; then
- echo "changed_files=$(git diff --name-only -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
- else
- echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
- fi
-
- - name: Set up node 20
- uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3
- with:
- node-version: 20
-
- - name: Install minimatch
- run: npm i minimatch
-
- - name: Check if a file is in paths-ignored
- id: confirm-negative-list
- uses: actions/github-script@v5
- with:
- github-token: ${{secrets.GITHUB_TOKEN}}
- result-encoding: string
- script: |
- const { minimatch } = require('minimatch')
- const changedPaths = "${{ steps.changed-files.outputs.changed_files }}".split(' ')
-
- let matched = ''
- process.env.PATHS_IGNORE.split(';').every(pattern => {
- changedPaths.every(path => {
- console.info('Testing ' + path + ' for pattern ' + pattern)
- if (minimatch(path, pattern)) {
- console.info(path + ' matched, aborting "unrelated summary"')
- matched = '1'
- return false
- }
- return true
- })
- return !matched
- })
- return matched
-
- build:
- permissions:
- contents: none
-
- runs-on: ubuntu-latest
-
- needs: action-no-build
-
- name: node
-
- if: needs.action-no-build.outputs.found_file == ''
-
- steps:
- - name: Skip
- run: 'echo "No JS/TS files changed, skipped Node"'
diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml
index 1774e0b27..71e8fde34 100644
--- a/.github/workflows/node.yml
+++ b/.github/workflows/node.yml
@@ -7,16 +7,6 @@ name: Node
on:
pull_request:
- paths:
- - '.github/workflows/**'
- - 'src/**'
- - 'appinfo/info.xml'
- - 'package.json'
- - 'package-lock.json'
- - 'tsconfig.json'
- - '**.js'
- - '**.ts'
- - '**.vue'
push:
branches:
- main
@@ -31,23 +21,48 @@ concurrency:
cancel-in-progress: true
jobs:
+ changes:
+ runs-on: ubuntu-latest
+
+ outputs:
+ src: ${{ steps.changes.outputs.src}}
+
+ steps:
+ - uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
+ id: changes
+ with:
+ filters: |
+ src:
+ - '.github/workflows/**'
+ - 'src/**'
+ - 'appinfo/info.xml'
+ - 'package.json'
+ - 'package-lock.json'
+ - 'tsconfig.json'
+ - '**.js'
+ - '**.ts'
+ - '**.vue'
+
build:
runs-on: ubuntu-latest
- name: node
+ needs: changes
+ if: needs.changes.outputs.src == 'true'
+
+ name: NPM build
steps:
- name: Checkout
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
+ uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Read package.json node and npm engines version
- uses: skjnldsv/read-package-engines-version-actions@0ce2ed60f6df073a62a77c0a4958dd0fc68e32e7 # v2.1
+ uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2
id: versions
with:
- fallbackNode: '^16'
- fallbackNpm: '^7'
+ fallbackNode: '^20'
+ fallbackNpm: '^9'
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
+ uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}
@@ -55,6 +70,8 @@ jobs:
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
- name: Install dependencies & build
+ env:
+ CYPRESS_INSTALL_BINARY: 0
run: |
npm ci
npm run build --if-present
@@ -69,3 +86,18 @@ jobs:
git status
git --no-pager diff
exit 1 # make it red to grab attention
+
+ summary:
+ permissions:
+ contents: none
+ runs-on: ubuntu-latest
+ needs: [changes, build]
+
+ if: always()
+
+ # This is the summary, we just avoid to rename it so that branch protection rules still match
+ name: node
+
+ steps:
+ - name: Summary status
+ run: if ${{ needs.changes.outputs.src == 'true' && needs.build.result != 'success' }}; then exit 1; fi