From b005a254e418111716a09be6341c951427d43784 Mon Sep 17 00:00:00 2001 From: Mads Jon Nielsen Date: Mon, 26 Oct 2026 10:24:41 +0100 Subject: [PATCH 1/3] ci: resolve sonarcloud findings and cover error cause fields --- .github/workflows/build.yml | 33 ++++++++++----------------------- src/index.test.ts | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c01778a..cee8c9b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - - uses: ibiqlik/action-yamllint@v3 + - uses: ibiqlik/action-yamllint@2576378a8e339169678f9939646ee3ee325e845c # v3.1.1 eslint: runs-on: ubuntu-latest @@ -24,11 +24,8 @@ jobs: - uses: actions/setup-node@v7 with: node-version: '24' - - uses: actions/cache@v6 - with: - path: 'node_modules' - key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} - - run: npm install + cache: npm + - run: npm ci --ignore-scripts - name: Run ESLint run: npm run lint @@ -39,11 +36,8 @@ jobs: - uses: actions/setup-node@v7 with: node-version: '24' - - uses: actions/cache@v6 - with: - path: 'node_modules' - key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} - - run: npm install + cache: npm + - run: npm ci --ignore-scripts - name: Run Typescipt Compiler run: npm run build @@ -54,11 +48,8 @@ jobs: - uses: actions/setup-node@v7 with: node-version: '24' - - uses: actions/cache@v6 - with: - path: 'node_modules' - key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} - - run: npm install + cache: npm + - run: npm ci --ignore-scripts - name: Run depcheck run: npm run depcheck @@ -69,15 +60,11 @@ jobs: - uses: actions/setup-node@v7 with: node-version: '24' - - uses: actions/cache@v6 - with: - path: 'node_modules' - key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} - - run: npm install + cache: npm + - run: npm ci --ignore-scripts - name: Run tests run: npm run test - name: SonarCloud Scan - uses: sonarsource/sonarcloud-github-action@master + uses: SonarSource/sonarqube-scan-action@d209202bc7d53ff1cc128f7f907dac145c9d6ae9 # v8.3.0 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/src/index.test.ts b/src/index.test.ts index e2be786..bbfe2bc 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -106,6 +106,22 @@ test("Expand meta err or error", () => { expect(spyStderr).toHaveBeenLastCalledWith(expected); }); +test("Expand meta err with errno, syscall and cause", () => { + const logger = create({printTimestamp: false, logLevel: "error"}); + const err = { + message: "connect ECONNREFUSED", + name: "Error", + errno: -111, + syscall: "connect", + cause: {code: "ENOTFOUND", hostname: "elastic.example"}, + }; + + logger.error("HulaHop", {err}); + expect(spyStderr).toHaveBeenCalledTimes(1); + const expected = "{\"log.level\":\"error\",\"message\":\"HulaHop\",\"error.message\":\"connect ECONNREFUSED\",\"error.type\":\"Error\",\"error.errno\":\"-111\",\"error.syscall\":\"connect\",\"error.cause.code\":\"ENOTFOUND\",\"error.cause.hostname\":\"elastic.example\"}\n"; + expect(spyStderr).toHaveBeenLastCalledWith(expected); +}); + test("Expand meta err with fields missing", () => { const logger = create({printTimestamp: false, logLevel: "error"}); const err = { From c24a672821a4ee8664c6fa89f484b13dc088f259 Mon Sep 17 00:00:00 2001 From: Mads Jon Nielsen Date: Mon, 26 Oct 2026 10:26:33 +0100 Subject: [PATCH 2/3] ci: raise yamllint line length for sha pinned actions --- .github/workflows/build.yml | 4 ++-- .yamllint.yml | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .yamllint.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cee8c9b..88e2ea0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - - uses: ibiqlik/action-yamllint@2576378a8e339169678f9939646ee3ee325e845c # v3.1.1 + - uses: ibiqlik/action-yamllint@2576378a8e339169678f9939646ee3ee325e845c eslint: runs-on: ubuntu-latest @@ -65,6 +65,6 @@ jobs: - name: Run tests run: npm run test - name: SonarCloud Scan - uses: SonarSource/sonarqube-scan-action@d209202bc7d53ff1cc128f7f907dac145c9d6ae9 # v8.3.0 + uses: SonarSource/sonarqube-scan-action@d209202bc7d53ff1cc128f7f907dac145c9d6ae9 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 0000000..99a1a87 --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,6 @@ +--- +extends: default + +rules: + line-length: + max: 250 From 29c1648e444dca8b255e0f7564f7561b08439125 Mon Sep 17 00:00:00 2001 From: Mads Jon Nielsen Date: Mon, 26 Oct 2026 10:26:52 +0100 Subject: [PATCH 3/3] ci: skip gitignored paths in yamllint --- .yamllint.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.yamllint.yml b/.yamllint.yml index 99a1a87..f83dde4 100644 --- a/.yamllint.yml +++ b/.yamllint.yml @@ -1,6 +1,8 @@ --- extends: default +ignore-from-file: .gitignore + rules: line-length: max: 250