From de4f89b40f29c0e0dadfefc452636e3b9e9765a0 Mon Sep 17 00:00:00 2001 From: mtyszczak <mateusz.tyszczak@gmail.com> Date: Fri, 21 Feb 2025 14:33:36 +0100 Subject: [PATCH 1/4] Fix installing new packages in pnpm workspace root --- pnpm-config/.npmrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pnpm-config/.npmrc b/pnpm-config/.npmrc index 9f4565c..3f2019e 100644 --- a/pnpm-config/.npmrc +++ b/pnpm-config/.npmrc @@ -3,3 +3,6 @@ # Enforce strict engine-versions from package.json engine-strict=true + +# Always install/remove dependencies from the pnpm workspace root +ignore-workspace-root-check=true -- GitLab From 809760aa908707f808b3d49a916e8c7260672cf6 Mon Sep 17 00:00:00 2001 From: mtyszczak <mateusz.tyszczak@gmail.com> Date: Fri, 21 Feb 2025 14:56:09 +0100 Subject: [PATCH 2/4] Use absolute version specifiers in pnpm workspace --- pnpm-config/pnpm-workspace.yaml | 38 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/pnpm-config/pnpm-workspace.yaml b/pnpm-config/pnpm-workspace.yaml index 1c0ec4a..c63c892 100644 --- a/pnpm-config/pnpm-workspace.yaml +++ b/pnpm-config/pnpm-workspace.yaml @@ -5,38 +5,38 @@ catalogs: # Can be referenced through "catalog:rollup-toolset" rollup-toolset: rollup: 4.24.0 - rollup-plugin-copy: ^3.5.0 - rollup-plugin-dts: ^6.1.1 - "@rollup/plugin-commonjs": ^27.0.0 - "@rollup/plugin-node-resolve": ^15.3.1 - "@rollup/plugin-replace": ^6.0.2 + rollup-plugin-copy: 3.5.0 + rollup-plugin-dts: 6.1.1 + "@rollup/plugin-commonjs": 27.0.0 + "@rollup/plugin-node-resolve": 15.3.1 + "@rollup/plugin-replace": 6.0.2 typedoc-toolset: - "typedoc": "0.27.3" - "typedoc-gitlab-wiki-theme": "^2.1.0" - "typedoc-plugin-markdown": "4.3.1" + "typedoc": 0.27.3 + "typedoc-gitlab-wiki-theme": 2.1.0 + "typedoc-plugin-markdown": 4.3.1 typescript-toolset: typescript: 5.7.3 - tslib: ^2.8.1 - tsx: ^4.19.2 + tslib: 2.8.1 + tsx: 4.19.2 proto-toolset: - protobufjs: ^7.2.5 - ts-proto: ^1.172.0 + protobufjs: 7.2.5 + ts-proto: 1.172.0 playwright-toolset: - "@playwright/test": ^1.50.1 - playwright: ^1.50.1 - http-server: ^14.1.1 + "@playwright/test": 1.50.1 + playwright: 1.50.1 + http-server: 14.1.1 husky: - husky: 8.0.3 + husky: 9.1.5 terser: - terser: ^5.39.0 + terser: 5.39.0 size-limit-toolset: - size-limit: ^11.1.6 - "@size-limit/file": ^11.1.6 + size-limit: 11.1.6 + "@size-limit/file": 11.1.6 -- GitLab From 6e560989c5e110ef8713ca1fb3e85ef898c339a7 Mon Sep 17 00:00:00 2001 From: mtyszczak <mateusz.tyszczak@gmail.com> Date: Fri, 21 Feb 2025 15:19:22 +0100 Subject: [PATCH 3/4] Move supplement doc url to build job base --- scripts/bash/npm-helpers/npm_push_doc.sh | 11 ++---- scripts/bash/npm-helpers/npm_set_doc_url.sh | 37 +++++++++++++++++++++ templates/npm_projects.gitlab-ci.yml | 19 +++++------ 3 files changed, 48 insertions(+), 19 deletions(-) create mode 100755 scripts/bash/npm-helpers/npm_set_doc_url.sh diff --git a/scripts/bash/npm-helpers/npm_push_doc.sh b/scripts/bash/npm-helpers/npm_push_doc.sh index 9e731b9..a4e52b2 100755 --- a/scripts/bash/npm-helpers/npm_push_doc.sh +++ b/scripts/bash/npm-helpers/npm_push_doc.sh @@ -46,6 +46,7 @@ PROJECT_ACCESS_TOKEN="${3:?Missing arg #3 pointing a Gitlab repository access to DIST_DIR="${4:?Missing arg #4 pointing the dist directory}" FEATURE_BRANCH_NAME="${5:?Missing arg #5 pointing a branch name}" FINAL_MERGE="${6:?Missing arg #6 pointing the final merge flag value}" +DOC_URL="${7:?Missing arg #7 pointing the documentation URL}" if [ "${FINAL_MERGE}" = "true" ]; then FINAL_MERGE=1 @@ -111,16 +112,8 @@ else git push origin "HEAD:main" fi -if [ ${FINAL_MERGE} -eq 1 ]; then - DOC_URL="${PROJECT_URL}/-/wikis/home" -else - DOC_URL="${PROJECT_URL}/-/wikis/non-stable/${FEATURE_BRANCH_NAME}/home" -fi - perform_wiki_cleanup "${WIKI_REPO_DIR}/non-stable" "${PROJECT_URL}" -echo "Documentation is available at url: ${DOC_URL}" +echo "Documentation url: ${DOC_URL}" popd - -echo GEN_DOC_URL="${DOC_URL}" > "gen_doc.env" diff --git a/scripts/bash/npm-helpers/npm_set_doc_url.sh b/scripts/bash/npm-helpers/npm_set_doc_url.sh new file mode 100755 index 0000000..f79cd2c --- /dev/null +++ b/scripts/bash/npm-helpers/npm_set_doc_url.sh @@ -0,0 +1,37 @@ +#!/bin/bash +set -e + +PROJECT_DIR="${1:?Missing arg #1 specifying a project source directory}" +PROJECT_URL="${2:?Missing arg #2 pointing project url. It is provided by CI_PROJECT_URL variable}" +FEATURE_BRANCH_NAME="${3:?Missing arg #3 pointing a branch name}" +FINAL_MERGE="${4:?Missing arg #4 pointing the final merge flag value}" +REPLACE_ENV_NAME="${5:-GEN_DOC_URL}" +REPLACE_FILE_PATH="${6:-${PROJECT_DIR}/README.md}" + +pushd "${PROJECT_DIR}" + +if [ "${FINAL_MERGE}" = "true" ]; then + FINAL_MERGE=1 +else + FINAL_MERGE=0 +fi + +if [ ${FINAL_MERGE} -eq 1 ]; then + DOC_URL="${PROJECT_URL}/-/wikis/home" +else + DOC_URL="${PROJECT_URL}/-/wikis/non-stable/${FEATURE_BRANCH_NAME}/home" +fi + +echo "Documentation url: ${DOC_URL}" + +sed -i "s<\${${REPLACE_ENV_NAME}}<${DOC_URL}<g" "${REPLACE_FILE_PATH}" +if grep -q "\${${REPLACE_ENV_NAME}}" "${REPLACE_FILE_PATH}"; then + echo "Failed to replace the documentation url in ${REPLACE_FILE_PATH}" + exit 1; +fi # Ensure that the placeholder was replaced + +echo "Replaced the documentation url: \"\${${REPLACE_ENV_NAME}}\" => \"${DOC_URL}\" in file: \"${REPLACE_FILE_PATH}\"" + +popd + +echo ${REPLACE_ENV_NAME}="${DOC_URL}" > "gen_doc.env" diff --git a/templates/npm_projects.gitlab-ci.yml b/templates/npm_projects.gitlab-ci.yml index 2ac1d77..7e56920 100644 --- a/templates/npm_projects.gitlab-ci.yml +++ b/templates/npm_projects.gitlab-ci.yml @@ -110,6 +110,10 @@ variables: # Output directory where should be stored package - it should be overrided by derived job DIST_DIR: "" + PROJECT_URL: "${CI_PROJECT_URL}" + REPLACE_DOC_URL_ENV: "" + REPLACE_FILE_PATH: "${SOURCE_DIR}/README.md" + # Target package scope - it should be overrided by derived job NPM_PACKAGE_SCOPE: "" # Target package name - it should be overrided by derived job @@ -117,15 +121,18 @@ variables: NPM_REGISTRY_URL: "gitlab.syncad.com/api/v4/projects/${CI_PROJECT_ID}/packages/npm/" script: + - if [ -n $REPLACE_DOC_URL_ENV ]; then /home/emscripten/scripts/npm_set_doc_url.sh "${SOURCE_DIR}" "${PROJECT_URL}" "${CI_COMMIT_REF_NAME}" "${CI_COMMIT_REF_PROTECTED}" "${REPLACE_DOC_URL_ENV}" "${REPLACE_FILE_PATH}"; fi - /home/emscripten/scripts/npm_build_package.sh "${SOURCE_DIR}" "${NPM_REGISTRY_URL}" "${NPM_PACKAGE_SCOPE}" "${NPM_PACKAGE_NAME}" "${DIST_DIR}" "${CI_COMMIT_REF_PROTECTED}" "${CI_COMMIT_TAG}" artifacts: reports: dotenv: + - "gen_doc.env" # contains URL to generated documentation pointed by `GEN_DOC_URL` variable - "${SOURCE_DIR}/built_package_info.env" # contains path to produced tgz - "${SOURCE_DIR}/built_package_version_info.env" # contains information related to generated package version and git revision paths: + - "${REPLACE_FILE_PATH}" - "${DIST_DIR}/*.tgz" # Built package - "${DIST_DIR}/built_package_info.json" @@ -224,6 +231,7 @@ variables: variables: # Must be overrided by derived job WIKI_PUSH_TOKEN: "" + DOC_URL: "${GEN_DOC_URL}" # The directory containing sources to be built - it can be overrided by derived job SOURCE_DIR: "${CI_PROJECT_DIR}" @@ -232,14 +240,5 @@ variables: DIST_DIR: "$CI_PROJECT_DIR/dist" script: - # start always at project root dir, to make sure .env file (included in artifacts) is generated there - cd "${CI_PROJECT_DIR}" - - /home/emscripten/scripts/npm_push_doc.sh "${SOURCE_DIR}" "${PROJECT_URL}" "${WIKI_PUSH_TOKEN}" "${DIST_DIR}" "${CI_COMMIT_REF_NAME}" "${CI_COMMIT_REF_PROTECTED}" - - artifacts: - reports: - dotenv: - - "gen_doc.env" # contains URL to generated documentation pointed by `GEN_DOC_URL` variable - - when: always - expire_in: 1 week + - /home/emscripten/scripts/npm_push_doc.sh "${SOURCE_DIR}" "${PROJECT_URL}" "${WIKI_PUSH_TOKEN}" "${DIST_DIR}" "${CI_COMMIT_REF_NAME}" "${CI_COMMIT_REF_PROTECTED}" "${DOC_URL}" -- GitLab From 5806284d3c6feb2ce52bdb6077c20a9a578bb643 Mon Sep 17 00:00:00 2001 From: mtyszczak <mateusz.tyszczak@gmail.com> Date: Mon, 24 Feb 2025 14:55:48 +0100 Subject: [PATCH 4/4] Bump emscripten image tag --- templates/npm_projects.gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/npm_projects.gitlab-ci.yml b/templates/npm_projects.gitlab-ci.yml index 7e56920..8bc7607 100644 --- a/templates/npm_projects.gitlab-ci.yml +++ b/templates/npm_projects.gitlab-ci.yml @@ -3,7 +3,7 @@ include: variables: # uses registry.gitlab.syncad.com/hive/common-ci-configuration/emsdk:4.0.1-2 - EMSCRIPTEN_IMAGE_TAG: "4.0.1-2@sha256:d0c5fbd811ef2447fdf411ee1e2a111c50ad0ec610cf3d6bf2d186530bc883ad" + EMSCRIPTEN_IMAGE_TAG: "4.0.1-2@sha256:a63a3ed761ce99ec858855bbdaf1cda03e383635dd7e88754010a746f7fd2cb3" EMSCRIPTEN_IMAGE: "registry.gitlab.syncad.com/hive/common-ci-configuration/emsdk:$EMSCRIPTEN_IMAGE_TAG" .node_based_job_base: -- GitLab