From e85ed6febd99d1c0445d66a49f5609abfa140ff6 Mon Sep 17 00:00:00 2001 From: avifenesh Date: Wed, 20 Nov 2024 23:54:50 +0000 Subject: [PATCH] Update dependencies in package.json: restore glide-rs and upgrade typescript and uuid versions Signed-off-by: avifenesh --- .github/json_matrices/build-matrix.json | 4 +- .github/workflows/npm-cd.yml | 56 ++++++++++++++++++------- .github/workflows/pypi-cd.yml | 2 +- node/package.json | 4 +- 4 files changed, 47 insertions(+), 19 deletions(-) diff --git a/.github/json_matrices/build-matrix.json b/.github/json_matrices/build-matrix.json index 5e10c38a37..0d0e7c10bb 100644 --- a/.github/json_matrices/build-matrix.json +++ b/.github/json_matrices/build-matrix.json @@ -33,7 +33,7 @@ "ARCH": "arm64", "TARGET": "aarch64-unknown-linux-musl", "RUNNER": ["self-hosted", "Linux", "ARM64"], - "IMAGE": "node:lts-alpine3.19", + "IMAGE": "node:lts-alpine", "CONTAINER_OPTIONS": "--user root --privileged --rm", "PACKAGE_MANAGERS": ["npm"], "languages": ["node"] @@ -44,7 +44,7 @@ "ARCH": "x64", "TARGET": "x86_64-unknown-linux-musl", "RUNNER": "ubuntu-latest", - "IMAGE": "node:lts-alpine3.19", + "IMAGE": "node:lts-alpine", "CONTAINER_OPTIONS": "--user root --privileged", "PACKAGE_MANAGERS": ["npm"], "languages": ["node"] diff --git a/.github/workflows/npm-cd.yml b/.github/workflows/npm-cd.yml index 8ff2936fbc..e2b39bcfe2 100644 --- a/.github/workflows/npm-cd.yml +++ b/.github/workflows/npm-cd.yml @@ -181,21 +181,23 @@ jobs: working-directory: ./node run: | npm pkg fix - set +e - # 2>&1 1>&3- redirects stderr to stdout and then redirects the original stdout to another file descriptor, - # effectively separating stderr and stdout. The 3>&1 at the end redirects the original stdout back to the console. - # https://github.com/npm/npm/issues/118#issuecomment-325440 - ignoring notice messages since currentlly they are directed to stderr - { npm_publish_err=$(npm publish --tag ${{ env.NPM_TAG }} --access public 2>&1 1>&3- | grep -Ev "notice|ExperimentalWarning") ;} 3>&1 - if [[ "$npm_publish_err" == *"You cannot publish over the previously published versions"* ]] - then - echo "Skipping publishing, package already published" - elif [[ ! -z "$npm_publish_err" ]] - then - echo "Failed to publish with error: ${npm_publish_err}" + + # Attempt to publish and capture output and exit code + npm_publish_output=$(npm publish --tag "${NPM_TAG}" --access public 2>&1) + publish_exit_code=$? + + if [[ $publish_exit_code -eq 0 ]]; then + echo "Package published successfully." + elif echo "$npm_publish_output" | grep -q "You cannot publish over the previously published versions"; then + echo "Skipping publishing, package already published." + else + echo "Failed to publish with error: $npm_publish_output" exit 1 fi - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + + echo "npm publish output: $npm_publish_output" + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # Reset the repository to make sure we get the clean checkout of the action later in other actions. # It is not required since in other actions we are cleaning before the action, but it is a good practice to do it here as well. @@ -374,11 +376,37 @@ jobs: npm install npm install --no-save @valkey/valkey-glide@${{ env.NPM_TAG }} npm run test + # fail on purpose to test the unpublish action + exit 1 + + - name: Unpublish packages on failure + if: ${{ always() }} && ${{ failure() }} + shell: bash + run: | + echo "Tests failed, unpublishing packages..." + + # Unpublish the base package + npm unpublish @$valky/valkey-glide@${{ inputs.version }} --force || true + + # Save PLATFORM_MATRIX to a file + echo '${{ needs.load-platform-matrix.outputs.PLATFORM_MATRIX }}' > platform_matrix.json + + # Extract package names from platform matrix + jq -r '.[] | "\(.NAMED_OS)\(.TARGET | test("musl") | if . then "-musl" else "" end)-\(.ARCH)"' platform_matrix.json > package_names.txt + + # Loop over each package name and unpublish + while read -r pkg; do + package_name="@valkey/valkey-glide-${pkg}" + echo "Unpublishing $package_name@${{ inputs.version }}" + npm unpublish ${package_name}@${{ inputs.version }} --force || true + done < package_names.txt + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # Reset the repository to make sure we get the clean checkout of the action later in other actions. # It is not required since in other actions we are cleaning before the action, but it is a good practice to do it here as well. - name: Reset repository - if: ${{ contains(matrix.build.RUNNER, 'self-hosted') }} + if: ${{ always() }} && ${{ contains(matrix.build.RUNNER, 'self-hosted') }} shell: bash run: | git reset --hard diff --git a/.github/workflows/pypi-cd.yml b/.github/workflows/pypi-cd.yml index 32740fce75..25a2044ea3 100644 --- a/.github/workflows/pypi-cd.yml +++ b/.github/workflows/pypi-cd.yml @@ -223,7 +223,7 @@ jobs: - name: Setup self-hosted runner access if: ${{ matrix.build.TARGET == 'aarch64-unknown-linux-gnu' }} run: sudo chown -R $USER:$USER /home/ubuntu/actions-runner/_work/valkey-glide - + - name: checkout uses: actions/checkout@v4 diff --git a/node/package.json b/node/package.json index cda3849de7..62f177898b 100644 --- a/node/package.json +++ b/node/package.json @@ -60,8 +60,8 @@ "semver": "^7.6.3", "ts-jest": "^29.2.5", "ts-node": "^10.9.2", - "typescript": "^5.5.4", - "uuid": "^11.0" + "typescript": "^5.6.3", + "uuid": "^11.0.3" }, "author": "Valkey GLIDE Maintainers", "license": "Apache-2.0",