From 05e60497e4f7bd0e949db6c360e761050f64500d Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Mon, 2 Oct 2023 11:54:24 +0200 Subject: [PATCH] Switch to dependabot for node_modules updates Pin our devDependencies, as they will now be updated via dependabot in a more controlled fashion. --- .github/dependabot.yml | 26 +++++++++ .github/workflows/dependabot.yml | 82 +++++++++++++++++++++++++++++ .github/workflows/npm-update-pf.yml | 43 --------------- .github/workflows/npm-update.yml | 43 --------------- node_modules | 2 +- package.json | 62 +++++++++++----------- 6 files changed, 140 insertions(+), 118 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/dependabot.yml delete mode 100644 .github/workflows/npm-update-pf.yml delete mode 100644 .github/workflows/npm-update.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000000..24fae822e97e --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,26 @@ +version: 2 +updates: + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "daily" + commit-message: + prefix: "[no-test]" + labels: + - "node_modules" + groups: + eslint: + patterns: + - "eslint*" + esbuild: + patterns: + - "esbuild*" + stylelint: + patterns: + - "stylelint*" + xterm: + patterns: + - "xterm*" + patternfly: + patterns: + - "@patternfly*" diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml new file mode 100644 index 000000000000..d69587b129ab --- /dev/null +++ b/.github/workflows/dependabot.yml @@ -0,0 +1,82 @@ +name: update node_modules +on: + pull_request_target: + types: [opened, reopened, synchronize, labeled] + +jobs: + dependabot: + environment: npm-update + permissions: + contents: read + pull-requests: write + timeout-minutes: 5 + # 22.04's podman has issues with piping and causes tar errors + runs-on: ubuntu-20.04 + if: ${{ contains(github.event.pull_request.labels.*.name, 'node_modules') }} + + steps: + - name: Clone repository + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + fetch-depth: 0 + + - name: Clear node_modules label + uses: actions/github-script@v6 + with: + script: | + try { + await github.rest.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + name: 'node_modules' + }); + } catch (e) { + if (e.name == 'HttpError' && e.status == 404) { + /* expected: 404 if label is unset */ + } else { + throw e; + } + } + + - name: Update node_modules for package.json changes + run: | + make tools/node-modules + git config --global user.name "GitHub Workflow" + git config --global user.email "cockpituous@cockpit-project.org" + eval $(ssh-agent) + ssh-add - <<< '${{ secrets.NODE_CACHE_DEPLOY_KEY }}' + ./tools/node-modules install + ./tools/node-modules push + git add node_modules + ssh-add -D + ssh-agent -k + + - name: Clear [no-test] prefix from PR title + if: ${{ contains(github.event.pull_request.title, '[no-test]') }} + uses: actions/github-script@v6 + env: + TITLE: '${{ github.event.pull_request.title }}' + with: + script: | + const title = process.env['TITLE'].replace(/\[no-test\]\W+ /, '') + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number, + title, + }); + + - name: Force push node_modules update + run: | + # Dependabot prefixes the commit with [no-test] which we don't want to keep in the commit + title=$(git show --pretty="%s" -s | sed -E "s/\[no-test\]\W+ //") + body=$(git show -s --pretty="%b") + git commit --amend -m "${title}" -m "${body}" --no-edit node_modules + eval $(ssh-agent) + ssh-add - <<< '${{ secrets.SELF_DEPLOY_KEY }}' + git push --force 'git@github.com:${{ github.repository }}' '${{ github.head_ref }}' + ssh-add -D + ssh-agent -k diff --git a/.github/workflows/npm-update-pf.yml b/.github/workflows/npm-update-pf.yml deleted file mode 100644 index 9d17d0433da3..000000000000 --- a/.github/workflows/npm-update-pf.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: npm-update-pf -on: - schedule: - - cron: '0 3 * * 1' - # can be run manually on https://github.com/cockpit-project/cockpit/actions - workflow_dispatch: -jobs: - npm-update: - environment: npm-update - permissions: - pull-requests: write - contents: write - # 22.04's podman has issues with piping and causes tar errors - runs-on: ubuntu-20.04 - steps: - - name: Clone repository - uses: actions/checkout@v3 - - - name: Run npm-update bot - run: | - test/common/make-bots - git config --global user.name "GitHub Workflow" - git config --global user.email "cockpituous@cockpit-project.org" - mkdir -p ~/.config/cockpit-dev - echo ${{ github.token }} >> ~/.config/cockpit-dev/github-token - eval $(ssh-agent) - ssh-add - <<< '${{ secrets.NODE_CACHE_DEPLOY_KEY }}' - bots/npm-update @patternfly >&2 - ssh-add -D - ssh-agent -k - - - name: Force push the change to trigger testing workflows - run: | - # Don't force-push if no branch was created - test "$(git symbolic-ref HEAD)" = '${{ github.ref }}' && exit - - sleep 1 # make sure the timestamp changes - git commit --amend --no-edit - eval $(ssh-agent) - ssh-add - <<< '${{ secrets.COCKPIT_DEPLOY_KEY }}' - git push --force 'git@github.com:${{ github.repository }}' HEAD - ssh-add -D - ssh-agent -k diff --git a/.github/workflows/npm-update.yml b/.github/workflows/npm-update.yml deleted file mode 100644 index 78d941ef1acc..000000000000 --- a/.github/workflows/npm-update.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: npm-update -on: - schedule: - - cron: '0 3 * * 2,4,6' - # can be run manually on https://github.com/cockpit-project/cockpit/actions - workflow_dispatch: -jobs: - npm-update: - environment: npm-update - permissions: - pull-requests: write - contents: write - # 22.04's podman has issues with piping and causes tar errors - runs-on: ubuntu-20.04 - steps: - - name: Clone repository - uses: actions/checkout@v3 - - - name: Run npm-update bot - run: | - test/common/make-bots - git config --global user.name "GitHub Workflow" - git config --global user.email "cockpituous@cockpit-project.org" - mkdir -p ~/.config/cockpit-dev - echo ${{ github.token }} >> ~/.config/cockpit-dev/github-token - eval $(ssh-agent) - ssh-add - <<< '${{ secrets.NODE_CACHE_DEPLOY_KEY }}' - bots/npm-update ~@patternfly >&2 - ssh-add -D - ssh-agent -k - - - name: Force push the change to trigger testing workflows - run: | - # Don't force-push if no branch was created - test "$(git symbolic-ref HEAD)" = '${{ github.ref }}' && exit - - sleep 1 # make sure the timestamp changes - git commit --amend --no-edit - eval $(ssh-agent) - ssh-add - <<< '${{ secrets.COCKPIT_DEPLOY_KEY }}' - git push --force 'git@github.com:${{ github.repository }}' HEAD - ssh-add -D - ssh-agent -k diff --git a/node_modules b/node_modules index 9a7012b9741f..ba1ddbae761d 160000 --- a/node_modules +++ b/node_modules @@ -1 +1 @@ -Subproject commit 9a7012b9741f9986921dab1371d0ece88e2cc6b2 +Subproject commit ba1ddbae761d649d3570c94948ed865e47ce537a diff --git a/package.json b/package.json index 4b061be19773..3e920b66d383 100644 --- a/package.json +++ b/package.json @@ -25,37 +25,37 @@ "xterm-addon-canvas": "0.5.0" }, "devDependencies": { - "argparse": "^2.0.1", - "axe-core": "^3.5.2", - "chrome-remote-interface": "^0.32.1", - "cssnano-preset-lite": "^2.0.1", - "esbuild": "^0.19.1", - "esbuild-plugin-copy": "^2.1.1", - "esbuild-plugin-replace": "^1.3.0", - "esbuild-sass-plugin": "^2.10.0", - "esbuild-wasm": "^0.19.1", - "eslint": "^8.29.0", - "eslint-config-standard": "^17.0.0", - "eslint-config-standard-jsx": "^11.0.0", - "eslint-config-standard-react": "^13.0.0", - "eslint-plugin-import": "^2.27.5", - "eslint-plugin-jsx-a11y": "^6.7.1", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^6.1.1", - "eslint-plugin-react": "^7.32.2", - "eslint-plugin-react-hooks": "^4.6.0", - "gettext-parser": "^7.0.1", - "htmlparser": "^1.7.7", - "jed": "^1.1.1", - "qunit": "^2.19.0", - "qunit-tap": "^1.5.1", - "sass": "^1.59.3", - "sizzle": "^2.3.5", - "stylelint": "^14.16.1", - "stylelint-config-standard": "^25.0.0", - "stylelint-config-standard-scss": "^4.0.0", - "stylelint-formatter-pretty": "^3.1.1", - "stylelint-use-logical-spec": "^5.0.0" + "argparse": "2.0.1", + "axe-core": "3.5.2", + "chrome-remote-interface": "0.32.1", + "cssnano-preset-lite": "2.0.1", + "esbuild": "0.19.1", + "esbuild-plugin-copy": "2.1.1", + "esbuild-plugin-replace": "1.3.0", + "esbuild-sass-plugin": "2.15.0", + "esbuild-wasm": "0.19.1", + "eslint": "8.29.0", + "eslint-config-standard": "17.0.0", + "eslint-config-standard-jsx": "11.0.0", + "eslint-config-standard-react": "13.0.0", + "eslint-plugin-import": "2.27.5", + "eslint-plugin-jsx-a11y": "6.7.1", + "eslint-plugin-node": "11.1.0", + "eslint-plugin-promise": "6.1.1", + "eslint-plugin-react": "7.32.2", + "eslint-plugin-react-hooks": "4.6.0", + "gettext-parser": "7.0.1", + "htmlparser": "1.7.7", + "jed": "1.1.1", + "qunit": "2.19.0", + "qunit-tap": "1.5.1", + "sass": "1.59.3", + "sizzle": "2.3.5", + "stylelint": "14.16.1", + "stylelint-config-standard": "25.0.0", + "stylelint-config-standard-scss": "4.0.0", + "stylelint-formatter-pretty": "3.1.1", + "stylelint-use-logical-spec": "5.0.0" }, "scripts": { "eslint": "eslint --ext .js --ext .jsx pkg/ test/common/",