diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c01778a..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@v3 + - uses: ibiqlik/action-yamllint@2576378a8e339169678f9939646ee3ee325e845c 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 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 0000000..f83dde4 --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,8 @@ +--- +extends: default + +ignore-from-file: .gitignore + +rules: + line-length: + max: 250 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 = {