From 8823e65a40840dd7182f11abdfe58f5921900285 Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Thu, 4 Jul 2024 09:34:48 +0300 Subject: [PATCH 1/7] Setup Yarn Classic through Corepack --- .gitignore | 3 +++ .yarnrc | 5 +++++ package.json | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .yarnrc diff --git a/.gitignore b/.gitignore index 40afcedc..8fab15c1 100644 --- a/.gitignore +++ b/.gitignore @@ -77,3 +77,6 @@ mjolnir.egg-info/ # VS .vs + +# Yarn versions through corepack +.yarn diff --git a/.yarnrc b/.yarnrc new file mode 100644 index 00000000..85b738b8 --- /dev/null +++ b/.yarnrc @@ -0,0 +1,5 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +yarn-path ".yarn/releases/yarn-1.22.22.cjs" diff --git a/package.json b/package.json index 52b80ca0..90066092 100644 --- a/package.json +++ b/package.json @@ -77,5 +77,6 @@ }, "engines": { "node": ">=18.0.0" - } + }, + "packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610" } From 58f615a410432c3a40584cfc1495315ea86bc43d Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Tue, 25 Jun 2024 13:36:56 +0300 Subject: [PATCH 2/7] pre-commit: use corepack and silence warnings, add .eslintignore's --- .eslintignore | 14 ++++++++++++++ .pre-commit-config.yaml | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.eslintignore b/.eslintignore index 6f9a60d7..8f9e81e0 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,17 @@ lib/ node_modules/ .eslintrc.js + +# pre-commit run --all-files +*.conf +Dockerfile +*.gif +*.json +LICENSE +*.lock +*.md +NOTICE +*.py +*.sh +*.yaml +*.yml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8a6cd815..d35b0123 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,5 +23,5 @@ repos: hooks: - id: yarn-lint name: linter - entry: yarn lint --cache + entry: corepack yarn lint --cache --quiet language: system From 3911ecc9e9ec7e0e0fab7c2caa19fa836a17e32e Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Tue, 25 Jun 2024 13:53:06 +0300 Subject: [PATCH 3/7] .github/workflows/mjolnir.yml: use yarn through corepack --- .github/workflows/mjolnir.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/mjolnir.yml b/.github/workflows/mjolnir.yml index f5cc4eff..b2a23bee 100644 --- a/.github/workflows/mjolnir.yml +++ b/.github/workflows/mjolnir.yml @@ -21,9 +21,10 @@ jobs: uses: actions/setup-node@v4 with: node-version: '18' - - run: yarn install - - run: yarn build - - run: yarn lint + - run: corepack enable + - run: corepack yarn install + - run: corepack yarn build + - run: corepack yarn lint unit: name: Unit tests runs-on: ubuntu-latest @@ -33,8 +34,8 @@ jobs: uses: actions/setup-node@v4 with: node-version: '18' - - run: yarn install - - run: yarn test + - run: corepack yarn install + - run: corepack yarn test integration: name: Integration tests runs-on: ubuntu-latest @@ -52,7 +53,7 @@ jobs: - name: Setup image run: RUST_LOG=debug,hyper=info,rusttls=info mx-tester build up - name: Setup dependencies - run: yarn install + run: corepack yarn install - name: Run tests run: RUST_LOG=debug,hyper=info,rusttls=info mx-tester run - name: Cleanup @@ -74,8 +75,8 @@ jobs: - name: Setup image run: RUST_LOG=debug,hyper=info,rusttls=info mx-tester build up - name: Setup dependencies - run: yarn install + run: corepack yarn install - name: Run tests - run: yarn test:appservice:integration + run: corepack yarn test:appservice:integration - name: Cleanup run: mx-tester down From 6ce6de8ae2246208456da55a82de73743d3ac0cf Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Tue, 25 Jun 2024 13:57:10 +0300 Subject: [PATCH 4/7] mx-tester.yml: use corepack --- mx-tester.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mx-tester.yml b/mx-tester.yml index 12e9e5b8..bfb2fe6a 100644 --- a/mx-tester.yml +++ b/mx-tester.yml @@ -7,7 +7,7 @@ up: - until psql postgres://mjolnir-tester:mjolnir-test@127.0.0.1:8083/mjolnir-test-db -c ""; do echo "Waiting for psql..."; sleep 1s; done # Launch the reverse proxy, listening for connections *only* on the local host. - docker run --rm --network host --name mjolnir-test-reverse-proxy -p 127.0.0.1:8081:80 -v $MX_TEST_CWD/test/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx - - yarn install + - corepack yarn install - npx ts-node src/appservice/cli.ts -r -u "http://host.docker.internal:9000" - cp mjolnir-registration.yaml $MX_TEST_SYNAPSE_DIR/data/ after: @@ -16,7 +16,7 @@ up: - echo "Synapse is ready" run: - - yarn test:integration + - corepack yarn test:integration down: finally: From eb46ae35ec891ab521613f79fe8c4cb735b7c0c2 Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Wed, 26 Jun 2024 06:55:05 +0300 Subject: [PATCH 5/7] mx-tester.yml & package.json: replace references to npx and call corepack more At least yarn build didn't break locally for me, so I think it's supported here too --- mx-tester.yml | 2 +- package.json | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mx-tester.yml b/mx-tester.yml index bfb2fe6a..5cd008ae 100644 --- a/mx-tester.yml +++ b/mx-tester.yml @@ -8,7 +8,7 @@ up: # Launch the reverse proxy, listening for connections *only* on the local host. - docker run --rm --network host --name mjolnir-test-reverse-proxy -p 127.0.0.1:8081:80 -v $MX_TEST_CWD/test/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx - corepack yarn install - - npx ts-node src/appservice/cli.ts -r -u "http://host.docker.internal:9000" + - corepack yarn dlx ts-node src/appservice/cli.ts -r -u "http://host.docker.internal:9000" - cp mjolnir-registration.yaml $MX_TEST_SYNAPSE_DIR/data/ after: # Wait until Synapse is ready diff --git a/package.json b/package.json index 90066092..aed44ff2 100644 --- a/package.json +++ b/package.json @@ -9,16 +9,16 @@ "private": true, "scripts": { "build": "tsc --project test/tsconfig.json && tsc > /dev/null 2>&1", - "postbuild": "yarn describe-version", + "postbuild": "corepack yarn describe-version", "describe-version": "(git describe > version.txt.tmp && mv version.txt.tmp version.txt) || true && rm -f version.txt.tmp", "remove-tests-from-lib": "rm -rf lib/test/ && cp -r lib/src/* lib/ && rm -rf lib/src/", "lint": "eslint -c .eslintrc.js src/**/*.ts test/**/*.ts src/**/*.tsx", - "start:dev": "yarn build && node --async-stack-traces lib/index.js", + "start:dev": "corepack yarn build && node --async-stack-traces lib/index.js", "test": "ts-mocha --project ./tsconfig.json test/commands/**/*.ts", "test:integration": "NODE_ENV=harness ts-mocha --async-stack-traces --forbid-only --require test/integration/fixtures.ts --timeout 300000 --project ./tsconfig.json \"test/integration/**/*Test.ts\"", - "test:integration:single": "NODE_ENV=harness npx ts-mocha --require test/integration/fixtures.ts --timeout 300000 --project ./tsconfig.json", + "test:integration:single": "NODE_ENV=harness corepack yarn dlx ts-mocha --require test/integration/fixtures.ts --timeout 300000 --project ./tsconfig.json", "test:appservice:integration": "NODE_ENV=harness ts-mocha --async-stack-traces --forbid-only --timeout 300000 --project ./tsconfig.json \"test/appservice/integration/**/*Test.ts\"", - "test:appservice:integration:single": "NODE_ENV=harness npx ts-mocha --timeout 300000 --project ./tsconfig.json", + "test:appservice:integration:single": "NODE_ENV=harness corepack yarn dlx ts-mocha --timeout 300000 --project ./tsconfig.json", "test:manual": "NODE_ENV=harness ts-node test/integration/manualLaunchScript.ts", "version": "sed -i '/# version automated/s/[0-9][0-9]*\\.[0-9][0-9]*\\.[0-9][^\"]*/'$npm_package_version'/' synapse_antispam/setup.py && git add synapse_antispam/setup.py && cat synapse_antispam/setup.py" }, From ab3f226695717e3f67f5fb054537ede5c69bb191 Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Thu, 4 Jul 2024 09:57:06 +0300 Subject: [PATCH 6/7] rm & gitignore .yarnrc --- .gitignore | 2 ++ .yarnrc | 5 ----- 2 files changed, 2 insertions(+), 5 deletions(-) delete mode 100644 .yarnrc diff --git a/.gitignore b/.gitignore index 8fab15c1..dc2c0c24 100644 --- a/.gitignore +++ b/.gitignore @@ -80,3 +80,5 @@ mjolnir.egg-info/ # Yarn versions through corepack .yarn +# Only contains possibly broken path, replaced by .yarnrc.yml in modern Yarn +.yarnrc diff --git a/.yarnrc b/.yarnrc deleted file mode 100644 index 85b738b8..00000000 --- a/.yarnrc +++ /dev/null @@ -1,5 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -yarn-path ".yarn/releases/yarn-1.22.22.cjs" From d41b18e6be30e8f85501cf8dec7e733004beb164 Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Thu, 4 Jul 2024 10:02:53 +0300 Subject: [PATCH 7/7] mx-tester.yml & package.json: return to npx since yarn dlx doesn't exist in classic --- mx-tester.yml | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mx-tester.yml b/mx-tester.yml index 5cd008ae..427b6e40 100644 --- a/mx-tester.yml +++ b/mx-tester.yml @@ -8,7 +8,7 @@ up: # Launch the reverse proxy, listening for connections *only* on the local host. - docker run --rm --network host --name mjolnir-test-reverse-proxy -p 127.0.0.1:8081:80 -v $MX_TEST_CWD/test/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx - corepack yarn install - - corepack yarn dlx ts-node src/appservice/cli.ts -r -u "http://host.docker.internal:9000" + - corepack npx ts-node src/appservice/cli.ts -r -u "http://host.docker.internal:9000" - cp mjolnir-registration.yaml $MX_TEST_SYNAPSE_DIR/data/ after: # Wait until Synapse is ready diff --git a/package.json b/package.json index aed44ff2..236a6638 100644 --- a/package.json +++ b/package.json @@ -16,9 +16,9 @@ "start:dev": "corepack yarn build && node --async-stack-traces lib/index.js", "test": "ts-mocha --project ./tsconfig.json test/commands/**/*.ts", "test:integration": "NODE_ENV=harness ts-mocha --async-stack-traces --forbid-only --require test/integration/fixtures.ts --timeout 300000 --project ./tsconfig.json \"test/integration/**/*Test.ts\"", - "test:integration:single": "NODE_ENV=harness corepack yarn dlx ts-mocha --require test/integration/fixtures.ts --timeout 300000 --project ./tsconfig.json", + "test:integration:single": "NODE_ENV=harness corepack npx ts-mocha --require test/integration/fixtures.ts --timeout 300000 --project ./tsconfig.json", "test:appservice:integration": "NODE_ENV=harness ts-mocha --async-stack-traces --forbid-only --timeout 300000 --project ./tsconfig.json \"test/appservice/integration/**/*Test.ts\"", - "test:appservice:integration:single": "NODE_ENV=harness corepack yarn dlx ts-mocha --timeout 300000 --project ./tsconfig.json", + "test:appservice:integration:single": "NODE_ENV=harness corepack npx ts-mocha --timeout 300000 --project ./tsconfig.json", "test:manual": "NODE_ENV=harness ts-node test/integration/manualLaunchScript.ts", "version": "sed -i '/# version automated/s/[0-9][0-9]*\\.[0-9][0-9]*\\.[0-9][^\"]*/'$npm_package_version'/' synapse_antispam/setup.py && git add synapse_antispam/setup.py && cat synapse_antispam/setup.py" },