Skip to content

Commit 539cb55

Browse files
avifeneshcyip10
authored andcommitted
* fixed CD for last changes * Change to using json file for our matrix * Remove issues with many package.json variation in deployed package * minor fixes * error looking fix * fixed adding package.json-e in mac * added fix to avoid typo in tag to release rc version as real one * fixed matrix of tests * added sudo to ts install * updated to run tests also in real release * updated README to include supported versions * return setup node since tests break when doing it manually * comments fix * HOT-FIX: CRITICAL - fixed set command optional arguments and added tests to set command (valkey-io#1508) fixed set command optional arguments and added tests to set command * added 0.4.1 bug fix to changelog * fix platform_matrix generating * fix npm notice err * fix usage of global tsc * fix usage of global tsc -p
1 parent 90e7a4b commit 539cb55

File tree

10 files changed

+211
-127
lines changed

10 files changed

+211
-127
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
[
2+
{
3+
"OS": "ubuntu",
4+
"NAMED_OS": "linux",
5+
"RUNNER": "ubuntu-latest",
6+
"ARCH": "x64",
7+
"TARGET": "x86_64-unknown-linux-gnu",
8+
"PACKAGE_MANAGERS": ["pypi", "npm"]
9+
},
10+
{
11+
"OS": "ubuntu",
12+
"NAMED_OS": "linux",
13+
"RUNNER": ["self-hosted", "Linux", "ARM64"],
14+
"ARCH": "arm64",
15+
"TARGET": "aarch64-unknown-linux-gnu",
16+
"PACKAGE_MANAGERS": ["pypi", "npm"],
17+
"CONTAINER": "2_28"
18+
},
19+
{
20+
"OS": "macos",
21+
"NAMED_OS": "darwin",
22+
"RUNNER": "macos-12",
23+
"ARCH": "x64",
24+
"TARGET": "x86_64-apple-darwin",
25+
"PACKAGE_MANAGERS": ["pypi", "npm"]
26+
},
27+
{
28+
"OS": "macos",
29+
"NAMED_OS": "darwin",
30+
"RUNNER": "macos-13-xlarge",
31+
"ARCH": "arm64",
32+
"TARGET": "aarch64-apple-darwin",
33+
"PACKAGE_MANAGERS": ["pypi", "npm"]
34+
},
35+
{
36+
"OS": "ubuntu",
37+
"NAMED_OS": "linux",
38+
"ARCH": "arm64",
39+
"TARGET": "aarch64-unknown-linux-musl",
40+
"RUNNER": ["self-hosted", "Linux", "ARM64"],
41+
"IMAGE": "node:alpine",
42+
"CONTAINER_OPTIONS": "--user root --privileged --rm",
43+
"PACKAGE_MANAGERS": ["npm"]
44+
},
45+
{
46+
"OS": "ubuntu",
47+
"NAMED_OS": "linux",
48+
"ARCH": "x64",
49+
"TARGET": "x86_64-unknown-linux-musl",
50+
"RUNNER": "ubuntu-latest",
51+
"IMAGE": "node:alpine",
52+
"CONTAINER_OPTIONS": "--user root --privileged",
53+
"PACKAGE_MANAGERS": ["npm"]
54+
}
55+
]

.github/workflows/node-create-package-file/action.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,19 @@ runs:
6969
# set the registry scope
7070
export registry_scope=`if [ "${{ inputs.npm_scope }}" != '' ]; then echo "${{ inputs.npm_scope }}:"; fi`
7171
# remove the current name section
72-
SED_FOR_MACOS=`if [[ "${{ inputs.os }}" =~ .*"macos".* ]]; then echo "''"; fi`
73-
sed -i $SED_FOR_MACOS '/"name":/d' ./package.json
72+
if [[ "${{ inputs.os }}" =~ .*"macos".* ]]; then
73+
sed '/"name":/d' ./package.json > temp.json && mv temp.json package.json
74+
else
75+
sed -i '/"name":/d' ./package.json
76+
fi
7477
# Remove all `///` occurrences to enable the commented out sections
75-
sed -i -e 's|///||g' package.json
78+
if [[ "${{ inputs.os }}" =~ .*"macos".* ]]; then
79+
sed 's|///||g' package.json > temp.json && mv temp.json package.json
80+
else
81+
sed -i 's|///||g' package.json
82+
fi
7683
# generate package.json from the template
7784
mv package.json package.json.tmpl
7885
envsubst < package.json.tmpl > "package.json"
7986
cat package.json
87+
echo $(ls *json*)

.github/workflows/npm-cd.yml

Lines changed: 88 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22

33
name: Continuous Deployment
44

5-
env:
6-
MATRIX: '[{"OS": "ubuntu","NAMED_OS": "linux","RUNNER": "ubuntu-latest","ARCH": "x64","TARGET": "x86_64-unknown-linux-gnu"},
7-
{"OS": "ubuntu","NAMED_OS": "linux","RUNNER": ["self-hosted", "Linux", "ARM64"],"ARCH": "arm64","TARGET": "aarch64-unknown-linux-gnu"},
8-
{"OS": "macos","NAMED_OS": "darwin","RUNNER": "macos-12","ARCH": "x64","TARGET": "x86_64-apple-darwin"},
9-
{"OS": "macos","NAMED_OS": "darwin","RUNNER": "macos-13-xlarge","ARCH": "arm64","TARGET": "aarch64-apple-darwin"},
10-
{"OS": "ubuntu","NAMED_OS": "linux","ARCH": "arm64","TARGET": "aarch64-unknown-linux-musl","RUNNER": ["self-hosted", "Linux", "ARM64"],"IMAGE": "node:alpine","CONTAINER_OPTIONS": "--user root --privileged --rm"},
11-
{"OS": "ubuntu","NAMED_OS": "linux","ARCH": "x64","TARGET": "x86_64-unknown-linux-musl","RUNNER": "ubuntu-latest","IMAGE": "node:alpine","CONTAINER_OPTIONS": "--user root --privileged"}]'
12-
135
on:
146
pull_request:
157
paths:
@@ -29,16 +21,6 @@ permissions:
2921
id-token: write
3022

3123
jobs:
32-
output-matrix:
33-
runs-on: ubuntu-latest
34-
outputs:
35-
matrix: ${{ steps.set-matrix.outputs.matrix }}
36-
steps:
37-
- name: Set matrix
38-
id: set-matrix
39-
run: |
40-
echo "::set-output name=matrix::${{toJson( env.MATRIX )}}"
41-
4224
start-self-hosted-runner:
4325
if: github.repository_owner == 'aws'
4426
runs-on: ubuntu-latest
@@ -56,8 +38,24 @@ jobs:
5638
aws-region: ${{ secrets.AWS_REGION }}
5739
ec2-instance-id: ${{ secrets.AWS_EC2_INSTANCE_ID }}
5840

41+
load-platform-matrix:
42+
runs-on: ubuntu-latest
43+
outputs:
44+
PLATFORM_MATRIX: ${{ steps.load-platform-matrix.outputs.PLATFORM_MATRIX }}
45+
steps:
46+
- name: Checkout
47+
uses: actions/checkout@v4
48+
49+
- name: load-platform-matrix
50+
id: load-platform-matrix
51+
shell: bash
52+
run: |
53+
# Get the matrix from the matrix.json file, without the object that has the IMAGE key
54+
export "PLATFORM_MATRIX=$(jq 'map(select(.PACKAGE_MANAGERS | contains(["npm"])))' < .github/workflows/build-matrix.json | jq -c .)"
55+
echo "PLATFORM_MATRIX=${PLATFORM_MATRIX}" >> $GITHUB_OUTPUT
56+
5957
publish-binaries:
60-
needs: [start-self-hosted-runner, output-matrix]
58+
needs: [start-self-hosted-runner, load-platform-matrix]
6159
if: github.repository_owner == 'aws'
6260
name: Publish packages to NPM
6361
runs-on: ${{ matrix.build.RUNNER }}
@@ -67,9 +65,7 @@ jobs:
6765
strategy:
6866
fail-fast: false
6967
matrix:
70-
build:
71-
${{fromJson(needs.output-matrix.outputs.matrix)}}
72-
68+
build: ${{fromJson(needs.load-platform-matrix.outputs.PLATFORM_MATRIX)}}
7369
steps:
7470
- name: Setup self-hosted runner access
7571
if: ${{ contains(matrix.build.RUNNER, 'self-hosted') && matrix.build.TARGET != 'aarch64-unknown-linux-musl' }}
@@ -108,7 +104,7 @@ jobs:
108104
if: ${{ matrix.build.TARGET != 'aarch64-unknown-linux-musl' }}
109105
uses: actions/setup-node@v3
110106
with:
111-
node-version: "16"
107+
node-version: "20"
112108
registry-url: "https://registry.npmjs.org"
113109
architecture: ${{ matrix.build.ARCH }}
114110
scope: "${{ vars.NPM_SCOPE }}"
@@ -139,15 +135,38 @@ jobs:
139135
npm_scope: ${{ vars.NPM_SCOPE }}
140136
publish: "true"
141137
github-token: ${{ secrets.GITHUB_TOKEN }}
138+
139+
- name: Check if RC and set a distribution tag for the package
140+
shell: bash
141+
run: |
142+
if [[ "${GITHUB_REF:11}" == *"rc"* ]]
143+
then
144+
echo "This is a release candidate: ${GITHUB_REF:11}"
145+
export npm_tag="next"
146+
else
147+
echo "This is a stable release: ${GITHUB_REF:11}"
148+
export npm_tag="latest"
149+
fi
150+
echo "NPM_TAG=${npm_tag}" >> $GITHUB_ENV
151+
152+
- name: Check that the release version dont have typo init
153+
if: ${{ github.event_name != 'pull_request' && contains(github.ref, '-') && !contains(github.ref, 'rc') }}
154+
run: |
155+
echo "The release version "${GITHUB_REF:11}" contains a typo, please fix it"
156+
echo "The release version should be in the format v{major-version}.{minor-version}.{patch-version}-rc{release-candidate-number} when it a release candidate or v{major-version}.{minor-version}.{patch-version} in a stable release."
157+
exit 1
142158
143159
- name: Publish to NPM
144160
if: github.event_name != 'pull_request'
145161
shell: bash
146162
working-directory: ./node
147163
run: |
164+
npm pkg fix
148165
set +e
149-
# Redirect only stderr
150-
{ npm_publish_err=$(npm publish --access public 2>&1 >&3 3>&-); } 3>&1
166+
# 2>&1 1>&3- redirects stderr to stdout and then redirects the original stdout to another file descriptor,
167+
# effectively separating stderr and stdout. The 3>&1 at the end redirects the original stdout back to the console.
168+
# https://github.com/npm/npm/issues/118#issuecomment-325440 - ignoring notice messages since currentlly they are directed to stderr
169+
{ npm_publish_err=$(npm publish --tag ${{ env.NPM_TAG }} --access public 2>&1 1>&3- | grep -v "notice") ;} 3>&1
151170
if [[ "$npm_publish_err" == *"You cannot publish over the previously published versions"* ]]
152171
then
153172
echo "Skipping publishing, package already published"
@@ -159,27 +178,6 @@ jobs:
159178
env:
160179
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
161180

162-
- name: Pack the Node package
163-
shell: bash
164-
working-directory: ./node
165-
run: |
166-
# Remove the "cpu" and "os" fileds so the base package would be able to install it on ubuntu
167-
SED_FOR_MACOS=`if [[ "${{ matrix.build.OS }}" =~ .*"macos".* ]]; then echo "''"; fi`
168-
sed -i $SED_FOR_MACOS '/"\/\/\/cpu": \[/,/]/d' ./package.json && sed -i $SED_FOR_MACOS '/"\/\/\/os": \[/,/]/d' ./package.json
169-
mkdir -p bin
170-
npm pack --pack-destination ./bin
171-
ls ./bin
172-
env:
173-
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
174-
175-
- name: Upload the Node package
176-
if: github.event_name != 'pull_request'
177-
uses: actions/upload-artifact@v3
178-
with:
179-
name: ${{ matrix.build.TARGET }}
180-
path: ./node/bin
181-
if-no-files-found: error
182-
183181
# Reset the repository to make sure we get the clean checkout of the action later in other actions.
184182
# 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.
185183
- name: Reset repository
@@ -196,14 +194,14 @@ jobs:
196194
runs-on: ubuntu-latest
197195
steps:
198196
- name: Checkout
199-
uses: actions/checkout@v3
197+
uses: actions/checkout@v4
200198
with:
201199
submodules: "true"
202200

203201
- name: Install node
204202
uses: actions/setup-node@v3
205203
with:
206-
node-version: "16"
204+
node-version: "20"
207205
registry-url: "https://registry.npmjs.org"
208206
scope: "${{ vars.NPM_SCOPE }}"
209207
always-auth: true
@@ -230,33 +228,7 @@ jobs:
230228
os: ubuntu
231229
target: "x86_64-unknown-linux-gnu"
232230
github-token: ${{ secrets.GITHUB_TOKEN }}
233-
234-
- name: Create a directory for the packed packages
235-
shell: bash
236-
working-directory: ./node/npm/glide
237-
run: mkdir packages
238-
239-
- name: Download the packed packages
240-
id: download
241-
uses: actions/download-artifact@v3
242-
with:
243-
path: ./node/npm/glide/packages
244-
245-
- name: Install the packed packages
246-
shell: bash
247-
working-directory: ./node/npm/glide
248-
run: |
249-
ls -LR packages/
250-
packages_list=`find ${{steps.download.outputs.download-path}} -type f -follow -print`
251-
for package in $packages_list
252-
do
253-
if [[ "${package}" == *.tgz ]]
254-
then
255-
echo "Installing package $package"
256-
npm i --no-save "$package"
257-
fi
258-
done
259-
231+
260232
- name: Check if RC and set a distribution tag for the package
261233
shell: bash
262234
run: |
@@ -283,19 +255,18 @@ jobs:
283255
env:
284256
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
285257

286-
test-release-candidate:
287-
if: github.event_name != 'pull_request' && contains(github.ref, 'rc')
288-
name: Test the release candidate
289-
needs: [publish-base-to-npm, output-matrix]
258+
test-release:
259+
if: github.event_name != 'pull_request'
260+
name: Test the release
261+
needs: [publish-base-to-npm, load-platform-matrix]
290262
runs-on: ${{ matrix.build.RUNNER }}
291263
container:
292264
image: ${{ matrix.build.IMAGE || '' }}
293265
options: ${{ matrix.build.CONTAINER_OPTIONS || 'none'}}
294266
strategy:
295267
fail-fast: false
296268
matrix:
297-
build:
298-
${{fromJson(needs.output-matrix.outputs.matrix)}}
269+
build: ${{fromJson(needs.load-platform-matrix.outputs.PLATFORM_MATRIX)}}
299270
steps:
300271
- name: Setup self-hosted runner access
301272
if: ${{ matrix.build.TARGET == 'aarch64-unknown-linux-gnu' }}
@@ -306,18 +277,25 @@ jobs:
306277
run: |
307278
apk update
308279
apk add redis git
280+
node -v
309281
310282
- name: install Redis and Python for ubuntu
311283
if: ${{ contains(matrix.build.TARGET, 'linux-gnu') }}
312284
run: |
313285
sudo apt-get update
314-
sudo apt-get install redis-server python3
286+
sudo apt-get install redis-server python3
315287
316-
- name: install Redis and Python for macos
288+
- name: install Redis, Python for macos
317289
if: ${{ contains(matrix.build.RUNNER, 'mac') }}
318290
run: |
319291
brew install redis python3
320292
293+
- name: Checkout
294+
if: ${{ matrix.build.TARGET != 'aarch64-unknown-linux-musl'}}
295+
uses: actions/checkout@v4
296+
with:
297+
submodules: "true"
298+
321299
- name: Setup for musl
322300
if: ${{ contains(matrix.build.TARGET, 'musl') }}
323301
uses: ./.github/workflows/setup-musl-on-linux
@@ -327,26 +305,44 @@ jobs:
327305
npm-auth-token: ${{ secrets.NPM_AUTH_TOKEN }}
328306
arch: ${{ matrix.build.ARCH }}
329307

330-
- name: Checkout
331-
if: ${{ matrix.build.TARGET != 'aarch64-unknown-linux-musl'}}
332-
uses: actions/checkout@v4
333-
with:
334-
submodules: "true"
335-
336-
- name: Install node
337-
if: ${{ !contains(matrix.build.TARGET, 'musl') }}
308+
- name: Setup node
309+
if: ${{ matrix.build.TARGET != 'aarch64-unknown-linux-musl' }}
338310
uses: actions/setup-node@v3
339311
with:
340312
node-version: "16"
341313
registry-url: "https://registry.npmjs.org"
314+
architecture: ${{ matrix.build.ARCH }}
342315
scope: "${{ vars.NPM_SCOPE }}"
343316
always-auth: true
317+
token: ${{ secrets.NPM_AUTH_TOKEN }}
318+
319+
- name: Install tsc and compile utils
320+
shell: bash
321+
working-directory: ./utils
322+
run: |
323+
npm install
324+
npm install -g typescript
325+
npx tsc -p ./tsconfig.json
326+
327+
- name: Check if RC and set a distribution tag for the package
328+
shell: bash
329+
run: |
330+
if [[ "${GITHUB_REF:11}" == *"rc"* ]]
331+
then
332+
echo "This is a release candidate"
333+
export npm_tag="next"
334+
else
335+
echo "This is a stable release"
336+
export npm_tag="latest"
337+
fi
338+
echo "NPM_TAG=${npm_tag}" >> $GITHUB_ENV
344339
345340
- name: Run the tests
346341
shell: bash
347342
working-directory: ./utils/release-candidate-testing/node
348343
run: |
349-
npm install --no-save @aws/glide-for-redis@next
344+
npm install
345+
npm install --no-save @aws/glide-for-redis@${{ env.NPM_TAG }}
350346
npm run test
351347
352348
# Reset the repository to make sure we get the clean checkout of the action later in other actions.

0 commit comments

Comments
 (0)