From 050d73cf84268e43f02a9c44411f57cedff62fe2 Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Thu, 9 May 2024 16:49:04 -0400 Subject: [PATCH 1/3] [CONFIG] Node script for github-actions. Split in 2: One for Coverage, the another to run multi-version/multi-OS tests. --- .github/workflows/node-coverage.js.yml | 45 ++++++++++++++++++++++++++ .github/workflows/node.js.yml | 8 +---- 2 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/node-coverage.js.yml diff --git a/.github/workflows/node-coverage.js.yml b/.github/workflows/node-coverage.js.yml new file mode 100644 index 00000000..23942e7d --- /dev/null +++ b/.github/workflows/node-coverage.js.yml @@ -0,0 +1,45 @@ +name: Node.js CI Coverage + +on: + push: + branches: [ "main", "develop", "feature/*" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + os: [ + "ubuntu-latest" + ] + node-version: [20.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - name: Checkout repository + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 + with: + fetch-depth: 0 + - name: Set up Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + run: npm ci --verbose + + - name: Lint + run: npm run lint + + - name: Run the tests + run: npm test -- --coverage + + - name: Upload coverage reports to Codecov with GitHub Action + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} # required + verbose: true # optional (default = false) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 3c1a3211..d77a3210 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -1,7 +1,7 @@ # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions -name: Node.js CI +name: Node.js CI Tests on: push: @@ -40,9 +40,3 @@ jobs: - name: Test run: npm run test - - - name: Upload coverage reports to Codecov with GitHub Action - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} # required - verbose: true # optional (default = false) From 619c51573be2af41a71eeb50a6f8bb6baa35c74f Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Thu, 9 May 2024 16:49:33 -0400 Subject: [PATCH 2/3] [CONFIG] Node script for github-actions, sonarcloud automatic scan disabled (to enable coverage support): https://docs.sonarsource.com/sonarcloud/enriching/test-coverage/javascript-typescript-test-coverage/ --- .github/workflows/node-coverage.js.yml | 6 ++++++ sonar-project.properties | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 sonar-project.properties diff --git a/.github/workflows/node-coverage.js.yml b/.github/workflows/node-coverage.js.yml index 23942e7d..dc5176e3 100644 --- a/.github/workflows/node-coverage.js.yml +++ b/.github/workflows/node-coverage.js.yml @@ -43,3 +43,9 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} # required verbose: true # optional (default = false) + + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..00705887 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,17 @@ +sonar.projectKey=sir-gon_algorithm-exercises-js +sonar.organization=sir-gon + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=algorithm-exercises-ts +#sonar.projectVersion=1.0 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +sonar.sources=src +sonar.exclusions=**/*.json,**/*.test.js,**/*.bruteforce-test.js,src/logger.js + +# Encoding of the source code. Default is default system encoding +sonar.sourceEncoding=UTF-8 + +# Coverage +sonar.javascript.lcov.reportPaths=./coverage/lcov.info From 8bd8101b16c42dc3c0b6e24253a67bb9ef4b1750 Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Thu, 9 May 2024 17:04:06 -0400 Subject: [PATCH 3/3] [CONFIG] Node runtime version updated to 22.x. --- .github/workflows/node-coverage.js.yml | 2 +- .github/workflows/node.js.yml | 2 +- Dockerfile | 4 ++-- README.md | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/node-coverage.js.yml b/.github/workflows/node-coverage.js.yml index dc5176e3..a4ddb36b 100644 --- a/.github/workflows/node-coverage.js.yml +++ b/.github/workflows/node-coverage.js.yml @@ -16,7 +16,7 @@ jobs: os: [ "ubuntu-latest" ] - node-version: [20.x] + node-version: [22.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index d77a3210..d127983b 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -21,7 +21,7 @@ jobs: "ubuntu-latest", "macOS-latest" ] - node-version: [18.x, 19.x, 20.x] + node-version: [18.x, 20.x, 22.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: diff --git a/Dockerfile b/Dockerfile index 97d59456..f2a38f4e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM node:20.2.0-alpine3.16 AS base +FROM node:22.1.0-alpine3.19 AS base RUN apk add --update --no-cache make ENV WORKDIR=/app WORKDIR ${WORKDIR} -FROM node:20.2.0-alpine3.16 AS lint +FROM node:22.1.0-alpine3.19 AS lint ENV WORKDIR=/app WORKDIR ${WORKDIR} diff --git a/README.md b/README.md index 43fbe3e8..ef46579b 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ Developed with runtime: ```text node --version -v20.5.0 +v22.1.0 ``` ### License