Skip to content

Commit

Permalink
chore: update to node v20 (#871)
Browse files Browse the repository at this point in the history
## fixes part of KILTprotocol/ticket#3081

- Makes sure the `package.json` specifies `yarn` version. 
- Upgrades the used **node version**  on the `.nvmrc`  to `lts/Iron`. 
- Makes sure the **GitHub workflows** uses node version 20. 
  For this following must be set: 
  - `actions/checkout@v4`
  - `actions/setup-node@v4` **with:**  _either_
    - **node-version-file:** '`package.json`' or '`.nvmrc`' 
    -  **node-version:**  `'`<Node.js version using [SemVer](https://semver.org/) or [aliases](https://github.com/nodejs/Release?tab=readme-ov-file#release-schedule) > `'`
    - `actions/download-artifact@v4`
    - _optional, but done:_ `actions/cache@v4`
  -  `aws-actions/configure-aws-credentials@v4`
  -  `aws-actions/amazon-ecr-login@v2`
 - Makes sure the **Dockerfiles** also use the node version 20. 
  This means that the following must be set: 
      - `FROM node:20-alpine as builder`
  • Loading branch information
kilted-andres authored Jul 8, 2024
1 parent 2ea03c9 commit f79fa0b
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/actions/cached-image-pull/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ runs:
- name: check image cache
id: image-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.image-file.outputs.path }}
key: image-cache-${{ inputs.image }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/devpackpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ jobs:
runs-on: ubuntu-latest
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && github.repository == 'kiltprotocol/sdk-js'"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# fetch-depth 0 and token needed to push changes on the package.json files back.
fetch-depth: 0
token: ${{ secrets.REPO_ACCESS_TOKEN }}
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install and Build
run: |
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/npmpublish-rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
Expand All @@ -31,8 +31,8 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
Expand All @@ -44,9 +44,9 @@ jobs:
run: yarn run bundle
- name: Get current package version
id: package_version
run: echo "package_version=$(node -pe "require('./package.json').version")" >> $GITHUB_OUTPUT
run: echo "package_version=$(node -pe "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Publish to NPM
run: yarn run publish --tag ${{ inputs.npm_tag }}
run: yarn run publish --tag ${{ inputs.npm_tag }}
env:
YARN_NPM_AUTH_TOKEN: ${{secrets.npm_token}}
- name: Repository Dispatch
Expand All @@ -55,4 +55,4 @@ jobs:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: KILTProtocol/docs
event-type: sdk-update
client-payload: '{"latestTag": "${{ steps.package_version.outputs.package_version }}"}'
client-payload: '{"latestTag": "${{ steps.package_version.outputs.package_version }}"}'
12 changes: 6 additions & 6 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
Expand All @@ -19,8 +19,8 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
Expand All @@ -32,7 +32,7 @@ jobs:
run: yarn run bundle
- name: Get current package version
id: package_version
run: echo "package_version=$(node -pe "require('./package.json').version")" >> $GITHUB_OUTPUT
run: echo "package_version=$(node -pe "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Publish to NPM
run: yarn run publish --tag latest
env:
Expand All @@ -43,4 +43,4 @@ jobs:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: KILTProtocol/docs
event-type: sdk-update
client-payload: '{"latestTag": "${{ steps.package_version.outputs.package_version }}"}'
client-payload: '{"latestTag": "${{ steps.package_version.outputs.package_version }}"}'
33 changes: 16 additions & 17 deletions .github/workflows/test-node-candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ env:
TESTCONTAINERS_WATCHER_IMG: testcontainers/ryuk:0.3.2

jobs:

build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
Expand All @@ -30,7 +29,7 @@ jobs:
- name: zip build
run: zip -r build.zip .
- name: upload build
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: build
path: build.zip
Expand All @@ -39,7 +38,7 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: make sure testcontainers image is in cache
uses: ./.github/actions/cached-image-pull
with:
Expand All @@ -51,28 +50,28 @@ jobs:
needs: cache_imgs

steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: build
- name: unzip
run: unzip build.zip -d .
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Log out node version
run: node --version

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
uses: aws-actions/amazon-ecr-login@v2

- name: pull image
env:
Expand All @@ -97,19 +96,19 @@ jobs:
needs: build

steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: build
- name: unzip
run: unzip build.zip -d .
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: yarn bundle
run: yarn bundle
- name: upload bundle artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: checked-nonmin-bundle
path: packages/sdk-js/dist/sdk-js.umd.js
Expand All @@ -120,29 +119,29 @@ jobs:
needs: [cache_imgs, bundle_cache]

steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: build
- name: unzip
run: unzip build.zip -d .
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: checked-nonmin-bundle
path: packages/sdk-js/dist
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- run: basename /packages/sdk-js/dist/
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
uses: aws-actions/amazon-ecr-login@v2
- name: pull node image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
Expand Down
22 changes: 12 additions & 10 deletions .github/workflows/tests-polkadot-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:

strategy:
matrix:
node-version: [18.x, 20.x]
node-version: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: master
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
Expand All @@ -35,7 +35,7 @@ jobs:
- name: list dependencies
run: echo "$(yarn info -A --name-only --json)" > locked_dependencies.txt
- name: upload dependencies list
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: deps-${{ matrix.node-version }}
path: |
Expand All @@ -47,7 +47,7 @@ jobs:
- name: zip build
run: zip -r build.zip .
- name: upload build
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.node-version }}
path: build.zip
Expand All @@ -63,11 +63,13 @@ jobs:
include:
- node-version: 16.x
required: 'optional'
- node-version: 22.x
required: 'optional'

continue-on-error: ${{ matrix.required == 'optional' }}

steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: build-${{ matrix.node-version }}
- name: unzip
Expand All @@ -91,7 +93,7 @@ jobs:
continue-on-error: ${{ matrix.required == 'optional' }}

steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: build-20.x
- name: unzip
Expand All @@ -106,9 +108,9 @@ jobs:

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
uses: aws-actions/amazon-ecr-login@v2

- name: pull image
- name: pull node image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: kilt/prototype-chain
Expand All @@ -135,7 +137,7 @@ jobs:
needs: [test, integration_test]
if: failure()
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: deps-20.x
- name: set dependencies env
Expand Down
Loading

0 comments on commit f79fa0b

Please sign in to comment.