Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANSI codes were not removed when saving linter report to a file as part of an AzDO pipeline #175

Closed
marcelschork opened this issue Jun 24, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@marcelschork
Copy link

marcelschork commented Jun 24, 2024

Expected Behavior

When saving the results of the linter to a file the ANSI codes should always be removed.

Current Behavior

When saving the results of the linter to a file within a CI pipeline on AzDO the ANSI codes were not removed. Running the same command on the terminal (MacOS 13.2.1 + zsh/bash) the ANSI codes are removed and everything is fine.

We are writing the lint results back to a pull request in AzDO and this is how it is looking like (without the sed workaround being applied)

image

I did not yet check any other CI/CD platform like GitHub Actions, Jenkins, etc.

Steps to Reproduce the Issue

  1. Take any UI5 application with some ui5lint errors
  2. Create a build pipeline in AzDo
pool:
  vmImage: 'ubuntu-latest'

steps:
  - script: |
       corepack enable
       corepack prepare pnpm@latest-9 --activate
    displayName: "🛠 Setup pnpm..."
  - script: >
       pnpm install -D @ui5/linter@0.2.5
    displayName: "🛠 Install dependencies..."
  - script: 
       npx ui5lint --details &> $(Build.ArtifactStagingDirectory)/ui5lint-results.txt || true
       # sed 's/\x1b\[[0-9;]*m//g' $(Build.ArtifactStagingDirectory)/ui5lint-results.txt > $(Build.ArtifactStagingDirectory)/ui5lint-results-no-color.txt # workaround
    displayName: "🔍 Run ui5lint..."
  - task: PublishBuildArtifacts@1
    displayName: "📦 Publish build..."

Context

  • UI5 linter version: 0.2.5
  • Node.js Version: 20.14.0
  • npm Version: pnpm 9.4.0
  • OS/Platform: Ubuntu 22.04
  • Other information regarding your environment (optional): bash environment running on agent with image ubuntu-22.04
@RandomByte
Copy link
Member

It looks like that environment does not support the formatting/coloring we are doing using chalk. Such environments should be detected by chalk itself (through supports-color). But I recall similar issues with Azure in the past.

If possible, could you test whether setting the environment variable CI=true for the ui5lint command resolves this?

@flovogt flovogt added the information required Further information is required label Jul 4, 2024
@marcelschork
Copy link
Author

marcelschork commented Jul 5, 2024

I just tested it. Setting the env variable CI to true and running the linter does not solve the issue. Then I checked the chalk GitHub repo and FORCE_COLOR=0 is what I was looking for. We may can add it to the documentation.

@RandomByte
Copy link
Member

Glad to hear that you were able to resolve the issue. I'm still not sure whether this is an issue with chalk or Azure, knowing that Azure can display colors in other places. I'll close this issue for now. If more people run into this, we may add something to the documentation.

@RandomByte RandomByte removed the information required Further information is required label Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants