From c42d34265b7f77703e5eefdaf7c9eccc50673b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Jarz=C4=99bski?= Date: Wed, 26 May 2021 13:22:07 +0200 Subject: [PATCH 01/18] Add missing 'chalk' dependency. --- package-lock.json | 6 +++--- package.json | 4 ++-- tests/config.js | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 89160cd..3f413d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -231,9 +231,9 @@ } }, "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", + "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" diff --git a/package.json b/package.json index 1a44958..2c15b27 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "homepage": "https://github.com/ckeditor/ckeditor4-workflows-common#readme", "dependencies": { "@octokit/request": "^5.4.14", - "dotenv": "^8.2.0", - "chalk": "^4.1.0" + "chalk": "^4.1.1", + "dotenv": "^8.2.0" } } diff --git a/tests/config.js b/tests/config.js index 918f493..bd10aab 100644 --- a/tests/config.js +++ b/tests/config.js @@ -1,4 +1,5 @@ const dotenv = require( 'dotenv' ); +const chalk = require( 'chalk' ); function config() { dotenv.config(); From afcbd9923c63f8ae25f00a5f2ad67f0dc8b544ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Jarz=C4=99bski?= Date: Thu, 27 May 2021 11:18:22 +0200 Subject: [PATCH 02/18] Make the log a bit more readable. --- tests/helpers/test-runner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/helpers/test-runner.js b/tests/helpers/test-runner.js index dcb400b..7081b33 100644 --- a/tests/helpers/test-runner.js +++ b/tests/helpers/test-runner.js @@ -71,7 +71,7 @@ async function runTest( testCase ) { console.log( `Status: ${ chalk.yellow( workflowObject.status ) }. Result: ${ chalk.yellow( workflowObject.conclusion ) }. Next check in ${ waitingTime }ms` ); } ); - console.log( chalk.green( result.name + 'run is finished!' ) + ' Result: ' + chalk.yellow( result.conclusion ) ); + console.log( chalk.green( '"' + result.name + '" run is finished!' ) + ' Result: ' + chalk.yellow( result.conclusion ) ); console.log( `Details: https://github.com/${ process.env.OWNER }/${ process.env.REPO }/actions/runs/${ workflow.id }` ); } From e61ca57a64b06e6cbad53b2023d919da47f11e61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Jarz=C4=99bski?= Date: Thu, 27 May 2021 11:42:30 +0200 Subject: [PATCH 03/18] Add some details to the testing description. --- README.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f913e38..f8941ba 100644 --- a/README.md +++ b/README.md @@ -116,18 +116,31 @@ Workflow responsible for updating NPM dependencies. It is run on 1st and 15th da ### Running tests -To run tests, create `.env` file with the following variables: +To run tests, in the `ckeditor4-workflows-common` repo create an `.env` file with the following variables: -* `AUTH_KEY` - GitHub key with permissions to commit files, read and run workflows / actions. +* `AUTH_KEY` - GitHub key with permissions to commit files, read and run workflows / actions. To get a token follow [Creating a personal access token](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token) tutorial. * `OWNER` - Owner of tests repo, e.g. `ckeditor`. -* `REPO` - Tests repo name, e.g. `workflow-tests`. It should be an empty repository with `master` branch and `README.md` file only. +* `REPO` - Tests repo name, e.g. `workflow-tests`. It should be an empty repository with `master` branch and `README.md` file only. Remember it also requires setting your GH Secrets on repo level (the ones inherited from organization level probably won't work). For now to run all workflows you need 3 secrets: + * `GH_WORKFLOWS_TOKEN` (same as `AUTH_KEY` variable); + * `GH_BOT_EMAIL` (most likely you ); + * `GH_BOT_USERNAME`. -Then run: +So the file should look like this: + +``` +AUTH_KEY="ghp_heregoesquitealonghash" +OWNER="ckeditor" +REPO="workflow-tests-PR-100" +``` + +Then (still being in `ckeditor4-workflows-common` repo) run: ``` npm test ``` +Remember to use appropriate Node.js version (v14). After tests are finished, you need to manually check in testing repo if everything was done as it should be (tests only check if workflows were executed). + ### Adding tests Tests case for new workflows should be added in `tests/fixtures` directory - for example `new-workflow.yml` should be covered with tests from `tests/fixtures/new-workflow.js`. The test file should export array of tests cases (see example below). From 54f276fbaededb706422cbbb0b13e037f859561e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Jarz=C4=99bski?= Date: Thu, 27 May 2021 14:55:04 +0200 Subject: [PATCH 04/18] Add more test cases for 'update-deps' workflow. --- ...ackage.json => deps-package-outdated.json} | 0 tests/assets/deps-package-up-to-date.json | 18 ++++++ tests/fixtures/update-deps.js | 63 +++++++++++++++---- 3 files changed, 68 insertions(+), 13 deletions(-) rename tests/assets/{deps-package.json => deps-package-outdated.json} (100%) create mode 100644 tests/assets/deps-package-up-to-date.json diff --git a/tests/assets/deps-package.json b/tests/assets/deps-package-outdated.json similarity index 100% rename from tests/assets/deps-package.json rename to tests/assets/deps-package-outdated.json diff --git a/tests/assets/deps-package-up-to-date.json b/tests/assets/deps-package-up-to-date.json new file mode 100644 index 0000000..a63581c --- /dev/null +++ b/tests/assets/deps-package-up-to-date.json @@ -0,0 +1,18 @@ +{ + "name": "fixtures", + "version": "1.0.0", + "description": "", + "main": "setup-workflows.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "core-js": "^3.13.0", + "eslint": "^7.27.0" + }, + "dependencies": { + "chalk": "^4.1.1" + } +} diff --git a/tests/fixtures/update-deps.js b/tests/fixtures/update-deps.js index 96b4379..cc02066 100644 --- a/tests/fixtures/update-deps.js +++ b/tests/fixtures/update-deps.js @@ -1,14 +1,51 @@ -module.exports = [ { - name:'update-deps PR', - workflow:'update-deps.yml', - branch: 'master', - config: { - 'updateDeps': { - 'targetBranch': 'master' +module.exports = [ + { + name: 'update-deps branch without package.json file', + workflow: 'update-deps.yml', + branch: 'master', + config: { + 'updateDeps': { + 'targetBranch': 'master' + } } - }, - fileList: [ { - src: 'deps-package.json', - dest: 'package.json' - } ] -} ]; + }, { + name: 'update-deps on up-to-date branch', + workflow: 'update-deps.yml', + branch: 'master', + config: { + 'updateDeps': { + 'targetBranch': 'master' + } + }, + fileList: [ { + src: 'deps-package-up-to-date.json', + dest: 'package.json' + } ] + }, { + name: 'update-deps PR', + workflow: 'update-deps.yml', + branch: 'master', + config: { + 'updateDeps': { + 'targetBranch': 'master' + } + }, + fileList: [ { + src: 'deps-package-outdated.json', + dest: 'package.json' + } ] + }, { + name: 'update-deps on non-existing branch', + workflow: 'update-deps.yml', + branch: 'master', + config: { + 'updateDeps': { + 'targetBranch': 'main' + } + }, + fileList: [ { + src: 'deps-package-outdated.json', + dest: 'package.json' + } ] + } +]; From eaf29257f966c588e7a662f7954b70728148b918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Jarz=C4=99bski?= Date: Thu, 27 May 2021 17:19:37 +0200 Subject: [PATCH 05/18] Add handling of missing 'package.json' file to 'update-deps.js' workflow. --- workflows/update-deps.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/workflows/update-deps.yml b/workflows/update-deps.yml index e63ac8b..1853615 100644 --- a/workflows/update-deps.yml +++ b/workflows/update-deps.yml @@ -69,6 +69,10 @@ jobs: - name: Update NPM dependencies if: env.BRANCH_UPDATE != 0 run: | + if [[ ! -f "./package.json" ]]; then + echo "'package.json' file not found, with nothing to update the workflow ends here." + exit 0 + fi npm i npm install -g npm-check git checkout -b ${{ env.BRANCH_UPDATE }} From 20ed2c08e957563e477f314d1515fa756d52fd73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Jarz=C4=99bski?= Date: Thu, 27 May 2021 18:21:00 +0200 Subject: [PATCH 06/18] Fix config options in test fixtures. --- tests/fixtures/setup-workflows.js | 8 ++------ tests/fixtures/update-deps.js | 16 ++++------------ 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/tests/fixtures/setup-workflows.js b/tests/fixtures/setup-workflows.js index b3c27a0..22c2e32 100644 --- a/tests/fixtures/setup-workflows.js +++ b/tests/fixtures/setup-workflows.js @@ -3,9 +3,7 @@ module.exports = [ { workflow: 'setup-workflows.yml', branch: 'master', config: { - 'setupWorkflows': { - 'pushAsPullRequest': 'false' - } + 'pushAsPullRequest': 'false' } }, { name: 'setup-workflows direct push (no config)', @@ -16,9 +14,7 @@ module.exports = [ { workflow: 'setup-workflows.yml', branch: 'master', config: { - 'setupWorkflows': { - 'pushAsPullRequest': 'true' - } + 'pushAsPullRequest': 'true' } } ]; diff --git a/tests/fixtures/update-deps.js b/tests/fixtures/update-deps.js index cc02066..5aae24a 100644 --- a/tests/fixtures/update-deps.js +++ b/tests/fixtures/update-deps.js @@ -4,18 +4,14 @@ module.exports = [ workflow: 'update-deps.yml', branch: 'master', config: { - 'updateDeps': { - 'targetBranch': 'master' - } + 'targetBranch': 'master' } }, { name: 'update-deps on up-to-date branch', workflow: 'update-deps.yml', branch: 'master', config: { - 'updateDeps': { - 'targetBranch': 'master' - } + 'targetBranch': 'master' }, fileList: [ { src: 'deps-package-up-to-date.json', @@ -26,9 +22,7 @@ module.exports = [ workflow: 'update-deps.yml', branch: 'master', config: { - 'updateDeps': { - 'targetBranch': 'master' - } + 'targetBranch': 'master' }, fileList: [ { src: 'deps-package-outdated.json', @@ -39,9 +33,7 @@ module.exports = [ workflow: 'update-deps.yml', branch: 'master', config: { - 'updateDeps': { - 'targetBranch': 'main' - } + 'targetBranch': 'main' }, fileList: [ { src: 'deps-package-outdated.json', From 507e4aa4d65ce52df8a9d7af3d1df32bb73dec5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Jarz=C4=99bski?= Date: Mon, 31 May 2021 18:13:22 +0200 Subject: [PATCH 07/18] Add possibility to run either npm-check or npm update on target day in month. --- tests/fixtures/update-deps.js | 15 +++++++++++++++ workflows/update-deps.yml | 27 ++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/tests/fixtures/update-deps.js b/tests/fixtures/update-deps.js index 5aae24a..f8bc295 100644 --- a/tests/fixtures/update-deps.js +++ b/tests/fixtures/update-deps.js @@ -1,3 +1,7 @@ +let date = new Date(); +let testNpmCheck = true; +let npmCheckDate = testNpmCheck ? date.getDate() : date.getDate() + 1; + module.exports = [ { name: 'update-deps branch without package.json file', @@ -28,6 +32,17 @@ module.exports = [ src: 'deps-package-outdated.json', dest: 'package.json' } ] + }, { + name: 'update-deps with npm-check on custom day of month', + workflow: 'update-deps.yml', + branch: 'master', + config: { + 'npmCheckDate': npmCheckDate + }, + fileList: [ { + src: 'deps-package-outdated.json', + dest: 'package.json' + } ] }, { name: 'update-deps on non-existing branch', workflow: 'update-deps.yml', diff --git a/workflows/update-deps.yml b/workflows/update-deps.yml index 1853615..5fcddab 100644 --- a/workflows/update-deps.yml +++ b/workflows/update-deps.yml @@ -59,9 +59,18 @@ jobs: fi echo "BRANCH_TARGET=$BRANCH_TARGET" >> $GITHUB_ENV + DAY=$(date +"%d") + NPM_CHECK_DATE=$(echo '${{ env.CONFIG }}' | jq -r ".npmCheckDate") + + if [[ "$DAY" == "$NPM_CHECK_DATE" ]]; then + echo "DEPS_BUMP_METHOD=npm-check" >> $GITHUB_ENV + else + echo "DEPS_BUMP_METHOD=npm_update" >> $GITHUB_ENV + fi + - name: Check if update branch already exists run: | - echo "BRANCH_UPDATE=deps-update_${{ env.BRANCH_TARGET }}_${{ matrix.deps }}" >> $GITHUB_ENV + echo "BRANCH_UPDATE=deps-${{ env.DEPS_BUMP_METHOD}}_${{ env.BRANCH_TARGET }}_${{ matrix.deps }}" >> $GITHUB_ENV if [[ $(git ls-remote --heads | grep deps-update_${{ env.BRANCH_TARGET }}_${{ matrix.deps }} | wc -c) -ne 0 ]]; then echo "BRANCH_UPDATE=0" >> $GITHUB_ENV fi @@ -73,10 +82,18 @@ jobs: echo "'package.json' file not found, with nothing to update the workflow ends here." exit 0 fi - npm i - npm install -g npm-check - git checkout -b ${{ env.BRANCH_UPDATE }} - npm-check -y --${{ matrix.deps }} + + if [[ "${{ env.DEPS_BUMP_METHOD }}" == "npm_update" ]]; then + echo "Just npm update today!" + git checkout -b ${{ env.BRANCH_UPDATE }} + npm update + else + echo "Running npm-check!" + npm i + npm install -g npm-check + git checkout -b ${{ env.BRANCH_UPDATE }} + npm-check -y --${{ matrix.deps }} + fi - name: Add changes if: env.BRANCH_UPDATE != 0 From 11b165349a3eb598a8175f3a41d1082bf136beb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Jarz=C4=99bski?= Date: Mon, 31 May 2021 18:17:38 +0200 Subject: [PATCH 08/18] Rename npmCheckDate -> npmCheckDay. --- tests/fixtures/update-deps.js | 4 ++-- workflows/update-deps.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/fixtures/update-deps.js b/tests/fixtures/update-deps.js index f8bc295..02ce60b 100644 --- a/tests/fixtures/update-deps.js +++ b/tests/fixtures/update-deps.js @@ -1,6 +1,6 @@ let date = new Date(); let testNpmCheck = true; -let npmCheckDate = testNpmCheck ? date.getDate() : date.getDate() + 1; +let npmCheckDay = testNpmCheck ? date.getDate() : date.getDate() + 1; module.exports = [ { @@ -37,7 +37,7 @@ module.exports = [ workflow: 'update-deps.yml', branch: 'master', config: { - 'npmCheckDate': npmCheckDate + 'npmCheckDay': npmCheckDay }, fileList: [ { src: 'deps-package-outdated.json', diff --git a/workflows/update-deps.yml b/workflows/update-deps.yml index 5fcddab..73cb7fb 100644 --- a/workflows/update-deps.yml +++ b/workflows/update-deps.yml @@ -60,9 +60,9 @@ jobs: echo "BRANCH_TARGET=$BRANCH_TARGET" >> $GITHUB_ENV DAY=$(date +"%d") - NPM_CHECK_DATE=$(echo '${{ env.CONFIG }}' | jq -r ".npmCheckDate") + NPM_CHECK_DAY=$(echo '${{ env.CONFIG }}' | jq -r ".npmCheckDay") - if [[ "$DAY" == "$NPM_CHECK_DATE" ]]; then + if [[ "$DAY" == "$NPM_CHECK_DAY" ]]; then echo "DEPS_BUMP_METHOD=npm-check" >> $GITHUB_ENV else echo "DEPS_BUMP_METHOD=npm_update" >> $GITHUB_ENV From a4a5dda5ec87063fd5881a540dd2f637d5e3a7cd Mon Sep 17 00:00:00 2001 From: sculpt0r Date: Mon, 2 Aug 2021 11:28:19 +0200 Subject: [PATCH 09/18] Handle 'bump' property from config --- workflows/update-deps.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/workflows/update-deps.yml b/workflows/update-deps.yml index 73cb7fb..4cbeb3c 100644 --- a/workflows/update-deps.yml +++ b/workflows/update-deps.yml @@ -59,10 +59,8 @@ jobs: fi echo "BRANCH_TARGET=$BRANCH_TARGET" >> $GITHUB_ENV - DAY=$(date +"%d") - NPM_CHECK_DAY=$(echo '${{ env.CONFIG }}' | jq -r ".npmCheckDay") - - if [[ "$DAY" == "$NPM_CHECK_DAY" ]]; then + SHOULD_BUMP=$(echo '${{ env.CONFIG }}' | jq -r ".bump") + if [[ "$SHOULD_BUMP" == "true" ]]; then echo "DEPS_BUMP_METHOD=npm-check" >> $GITHUB_ENV else echo "DEPS_BUMP_METHOD=npm_update" >> $GITHUB_ENV From fdffb85b9cc533eff7c3ee77722c2ee3bea396c0 Mon Sep 17 00:00:00 2001 From: sculpt0r Date: Tue, 3 Aug 2021 11:10:29 +0200 Subject: [PATCH 10/18] create bump-deps workflow --- workflows/bump-deps.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 workflows/bump-deps.yml diff --git a/workflows/bump-deps.yml b/workflows/bump-deps.yml new file mode 100644 index 0000000..4047be1 --- /dev/null +++ b/workflows/bump-deps.yml @@ -0,0 +1,40 @@ +name: Bump dependencies +on: + schedule: + - cron: "0 0 1 * *" + workflow_dispatch: + inputs: + config: + description: 'Config' + required: false + default: '' + +jobs: + update: + runs-on: ubuntu-latest + steps: + - name: Read config + run: | + CONFIG='{}' + if [[ ! -z '${{ github.event.inputs.config }}' ]]; then + CONFIG='${{ github.event.inputs.config }}' + elif [[ -f "./.github/workflows-config.json" ]]; then + CONFIG=$( jq -c .updateDeps './.github/workflows-config.json' ) + fi + echo "Workflow config: $CONFIG" + echo "CONFIG=$CONFIG" >> $GITHUB_ENV + - name: Merge configs + run: | + CONFIG=$(echo '${{ env.CONFIG }}' | jq -c '. += {"bump": "true"}') + # echo "${CONFIG}" + INPUT_1='{ "config": "' + INPUT_2=$(echo "${CONFIG//\"/\\\"}") + INPUT_3='"}' + INPUT_ALL="${INPUT_1} ${INPUT_2} ${INPUT_3}" + echo "INPUT_ALL=$INPUT_ALL" >> $GITHUB_ENV + - name: Invoke workflow with inputs + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: Update NPM dependencies + token: ${{ secrets.GH_WORKFLOWS_TOKEN }} + inputs: ${{ env.INPUT_ALL }} From f2fc5c01e3a0b8e8f7341be4ac6849ce801aa50c Mon Sep 17 00:00:00 2001 From: sculpt0r Date: Tue, 3 Aug 2021 11:10:53 +0200 Subject: [PATCH 11/18] empty cfg test case for bump deps --- tests/fixtures/bump-deps.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/fixtures/bump-deps.js diff --git a/tests/fixtures/bump-deps.js b/tests/fixtures/bump-deps.js new file mode 100644 index 0000000..880861c --- /dev/null +++ b/tests/fixtures/bump-deps.js @@ -0,0 +1,12 @@ +module.exports = [ + { + name: 'update-deps with empty init cfg', + workflow: 'bump-deps.yml', + branch: 'master', + config: {}, + fileList: [ { + src: 'deps-package-outdated.json', + dest: 'package.json' + } ] + } +]; \ No newline at end of file From cfb99ba8a75a6d04ae149c66aaf319d924a219e4 Mon Sep 17 00:00:00 2001 From: sculpt0r Date: Tue, 3 Aug 2021 11:15:39 +0200 Subject: [PATCH 12/18] Add test case with config to merge --- tests/fixtures/bump-deps.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/fixtures/bump-deps.js b/tests/fixtures/bump-deps.js index 880861c..b0c00aa 100644 --- a/tests/fixtures/bump-deps.js +++ b/tests/fixtures/bump-deps.js @@ -8,5 +8,17 @@ module.exports = [ src: 'deps-package-outdated.json', dest: 'package.json' } ] + }, + { + name: 'update-deps with targetBranch in cfg', + workflow: 'bump-deps.yml', + branch: 'master', + config: { + targetBranch: 'master' + }, + fileList: [ { + src: 'deps-package-outdated.json', + dest: 'package.json' + } ] } ]; \ No newline at end of file From 247f9faf36fb1f54da17e849f37dab639ea7b0f0 Mon Sep 17 00:00:00 2001 From: sculpt0r Date: Tue, 3 Aug 2021 11:20:10 +0200 Subject: [PATCH 13/18] Add test case with bump on false in cfg --- tests/fixtures/bump-deps.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/fixtures/bump-deps.js b/tests/fixtures/bump-deps.js index b0c00aa..eb3c1e6 100644 --- a/tests/fixtures/bump-deps.js +++ b/tests/fixtures/bump-deps.js @@ -20,5 +20,18 @@ module.exports = [ src: 'deps-package-outdated.json', dest: 'package.json' } ] + }, + { + name: 'update-deps with bump on false in cfg', + workflow: 'bump-deps.yml', + branch: 'master', + config: { + targetBranch: 'master', + bump: 'false' + }, + fileList: [ { + src: 'deps-package-outdated.json', + dest: 'package.json' + } ] } ]; \ No newline at end of file From a9fa54cfc9f8ea1b7be50d18b2a3046447e1796b Mon Sep 17 00:00:00 2001 From: sculpt0r Date: Tue, 3 Aug 2021 11:40:39 +0200 Subject: [PATCH 14/18] Lower version of package in test input --- tests/assets/deps-package-up-to-date.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/assets/deps-package-up-to-date.json b/tests/assets/deps-package-up-to-date.json index a63581c..8a436b3 100644 --- a/tests/assets/deps-package-up-to-date.json +++ b/tests/assets/deps-package-up-to-date.json @@ -9,7 +9,7 @@ "author": "", "license": "ISC", "devDependencies": { - "core-js": "^3.13.0", + "core-js": "^2.6.12", "eslint": "^7.27.0" }, "dependencies": { From c8f2585cd1331f64721d36fa8f1680a4317aeccf Mon Sep 17 00:00:00 2001 From: sculpt0r Date: Mon, 27 Sep 2021 08:58:20 +0200 Subject: [PATCH 15/18] Switch to less precise node version --- .nvmrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nvmrc b/.nvmrc index 5d6e794..958b5a3 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v14.16.1 +v14 From 87959badb50db6968fc6f53d6bd725499630755b Mon Sep 17 00:00:00 2001 From: sculpt0r Date: Mon, 27 Sep 2021 09:43:14 +0200 Subject: [PATCH 16/18] Update workflows naming --- .../deps-package-outdated-fixed-version.json | 18 ++++++++++++++++++ ...pdate-deps.js => update-deps-semversion.js} | 10 +++++----- .../{bump-deps.js => update-deps-to-newest.js} | 14 +++++++------- ...ate-deps.yml => update-deps-semversion.yml} | 2 +- ...bump-deps.yml => update-deps-to-newest.yml} | 4 ++-- 5 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 tests/assets/deps-package-outdated-fixed-version.json rename tests/fixtures/{update-deps.js => update-deps-semversion.js} (83%) rename tests/fixtures/{bump-deps.js => update-deps-to-newest.js} (63%) rename workflows/{update-deps.yml => update-deps-semversion.yml} (99%) rename workflows/{bump-deps.yml => update-deps-to-newest.yml} (92%) diff --git a/tests/assets/deps-package-outdated-fixed-version.json b/tests/assets/deps-package-outdated-fixed-version.json new file mode 100644 index 0000000..4a66cb7 --- /dev/null +++ b/tests/assets/deps-package-outdated-fixed-version.json @@ -0,0 +1,18 @@ +{ + "name": "fixtures", + "version": "1.0.0", + "description": "", + "main": "setup-workflows.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "core-js": "2.0.0", + "eslint": "5.0.0" + }, + "dependencies": { + "chalk": "3.0.0" + } +} diff --git a/tests/fixtures/update-deps.js b/tests/fixtures/update-deps-semversion.js similarity index 83% rename from tests/fixtures/update-deps.js rename to tests/fixtures/update-deps-semversion.js index 02ce60b..9f6066f 100644 --- a/tests/fixtures/update-deps.js +++ b/tests/fixtures/update-deps-semversion.js @@ -5,14 +5,14 @@ let npmCheckDay = testNpmCheck ? date.getDate() : date.getDate() + 1; module.exports = [ { name: 'update-deps branch without package.json file', - workflow: 'update-deps.yml', + workflow: 'update-deps-semversion.yml', branch: 'master', config: { 'targetBranch': 'master' } }, { name: 'update-deps on up-to-date branch', - workflow: 'update-deps.yml', + workflow: 'update-deps-semversion.yml', branch: 'master', config: { 'targetBranch': 'master' @@ -23,7 +23,7 @@ module.exports = [ } ] }, { name: 'update-deps PR', - workflow: 'update-deps.yml', + workflow: 'update-deps-semversion.yml', branch: 'master', config: { 'targetBranch': 'master' @@ -34,7 +34,7 @@ module.exports = [ } ] }, { name: 'update-deps with npm-check on custom day of month', - workflow: 'update-deps.yml', + workflow: 'update-deps-semversion.yml', branch: 'master', config: { 'npmCheckDay': npmCheckDay @@ -45,7 +45,7 @@ module.exports = [ } ] }, { name: 'update-deps on non-existing branch', - workflow: 'update-deps.yml', + workflow: 'update-deps-semversion.yml', branch: 'master', config: { 'targetBranch': 'main' diff --git a/tests/fixtures/bump-deps.js b/tests/fixtures/update-deps-to-newest.js similarity index 63% rename from tests/fixtures/bump-deps.js rename to tests/fixtures/update-deps-to-newest.js index eb3c1e6..6c4d1ff 100644 --- a/tests/fixtures/bump-deps.js +++ b/tests/fixtures/update-deps-to-newest.js @@ -1,37 +1,37 @@ module.exports = [ { name: 'update-deps with empty init cfg', - workflow: 'bump-deps.yml', + workflow: 'update-deps-to-newest.yml', branch: 'master', config: {}, fileList: [ { - src: 'deps-package-outdated.json', + src: 'deps-package-outdated-fixed-version.json', dest: 'package.json' } ] }, { name: 'update-deps with targetBranch in cfg', - workflow: 'bump-deps.yml', + workflow: 'update-deps-to-newest.yml', branch: 'master', config: { targetBranch: 'master' }, fileList: [ { - src: 'deps-package-outdated.json', + src: 'deps-package-outdated-fixed-version.json', dest: 'package.json' } ] }, { name: 'update-deps with bump on false in cfg', - workflow: 'bump-deps.yml', + workflow: 'update-deps-to-newest.yml', branch: 'master', config: { targetBranch: 'master', bump: 'false' }, fileList: [ { - src: 'deps-package-outdated.json', + src: 'deps-package-outdated-fixed-version.json', dest: 'package.json' } ] } -]; \ No newline at end of file +]; diff --git a/workflows/update-deps.yml b/workflows/update-deps-semversion.yml similarity index 99% rename from workflows/update-deps.yml rename to workflows/update-deps-semversion.yml index 4cbeb3c..e8ce5bc 100644 --- a/workflows/update-deps.yml +++ b/workflows/update-deps-semversion.yml @@ -1,4 +1,4 @@ -name: Update NPM dependencies +name: Update NPM dependencies(semversion) on: schedule: diff --git a/workflows/bump-deps.yml b/workflows/update-deps-to-newest.yml similarity index 92% rename from workflows/bump-deps.yml rename to workflows/update-deps-to-newest.yml index 4047be1..c0d69ed 100644 --- a/workflows/bump-deps.yml +++ b/workflows/update-deps-to-newest.yml @@ -1,4 +1,4 @@ -name: Bump dependencies +name: Update NPM dependencies(to newest) on: schedule: - cron: "0 0 1 * *" @@ -35,6 +35,6 @@ jobs: - name: Invoke workflow with inputs uses: benc-uk/workflow-dispatch@v1 with: - workflow: Update NPM dependencies + workflow: Update NPM dependencies(semversion) token: ${{ secrets.GH_WORKFLOWS_TOKEN }} inputs: ${{ env.INPUT_ALL }} From 8add31c70d1341a01d3011abc771aab3328a7a4f Mon Sep 17 00:00:00 2001 From: sculpt0r Date: Mon, 27 Sep 2021 09:53:10 +0200 Subject: [PATCH 17/18] Rename workflow file to match new naming. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8941ba..ce4ba84 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ Since this workflow uses labels to mark stale issues/PRs, labels should be alrea ### update-deps -Workflow responsible for updating NPM dependencies. It is run on 1st and 15th day of each month (at 05:00 UTC) and creates two PRs - one for dev dependencies and one for production ones (if there are any outdated dependencies). It checks `package.json` file in the repository root and uses `npm-check` to update all dev/prod dependencies (which means `package.json` versioning is not respected). It is a cron job task so will be triggered only on main repository branch. See `workflows/update-deps.yml` file. +Workflow responsible for updating NPM dependencies. It is run on 1st and 15th day of each month (at 05:00 UTC) and creates two PRs - one for dev dependencies and one for production ones (if there are any outdated dependencies). It checks `package.json` file in the repository root and uses `npm-check` to update all dev/prod dependencies (which means `package.json` versioning is not respected). It is a cron job task so will be triggered only on main repository branch. See `workflows/update-deps-semversion.yml` file. #### Required secrets From fd43312dda5910b03c91c04449ed3341a070b95d Mon Sep 17 00:00:00 2001 From: sculpt0r Date: Mon, 27 Sep 2021 10:07:58 +0200 Subject: [PATCH 18/18] Update workflows description --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ce4ba84..0c0ad29 100644 --- a/README.md +++ b/README.md @@ -99,9 +99,13 @@ Since this workflow uses labels to mark stale issues/PRs, labels should be alrea * `resolution:expired` - label added to stale issues which got closed due to inactivity. * `pr:frozen ❄` - label added to stale PRs which got closed due to inactivity. -### update-deps +### update-deps-semversion -Workflow responsible for updating NPM dependencies. It is run on 1st and 15th day of each month (at 05:00 UTC) and creates two PRs - one for dev dependencies and one for production ones (if there are any outdated dependencies). It checks `package.json` file in the repository root and uses `npm-check` to update all dev/prod dependencies (which means `package.json` versioning is not respected). It is a cron job task so will be triggered only on main repository branch. See `workflows/update-deps-semversion.yml` file. +Workflow responsible for updating NPM dependencies. It is run on 1st and 15th day of each month (at 05:00 UTC) and creates two PRs - one for dev dependencies and one for production ones (if there are any outdated dependencies). It checks `package.json` file in the repository root. Depends on provided config, it will use `npm-check` (`semversion` compatibility mode) or `npm_update` (bump version to newest available) to update all dev/prod dependencies. It is a cron job task so will be triggered only on main repository branch. See `workflows/update-deps-semversion.yml` file. + +### update-deps-to-newest + +Workflow responsible for running `update-deps-semversion` workflow, but with config that disables semversion compatibility. It is scheduled to run once a month. See `workflows/update-deps-to-newest.yml` file. #### Required secrets