Merge pull request #1194 from internxt/fvsegarra-patch-1 #2003
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SonarCloud analysis | |
on: | |
push: | |
branches: ['main'] | |
pull_request: | |
types: [opened, synchronize, reopened] | |
branches: ['main'] | |
workflow_dispatch: | |
permissions: | |
pull-requests: read # allows SonarCloud to decorate PRs with analysis results | |
jobs: | |
Analysis: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node_version: [18.x] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node_version }} | |
cache: yarn | |
# Generate a .npmrc file with the NPM_TOKEN | |
- run: echo '${{ secrets.CYPRESS_ENV }}' > cypress.env.json | |
- run: echo '${{ secrets.ENV_LOCAL }}' > .env.local | |
# Install dependencies, build and run tests | |
- name: Test and coverage | |
uses: cypress-io/github-action@v6 | |
with: | |
install: yarn install | |
build: yarn build | |
start: yarn start | |
browser: chrome | |
- name: Cypress artifacts | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: cypress-videos | |
path: cypress/videos/**/* | |
# Analyze with SonarCloud | |
- name: Analyze with SonarCloud | |
uses: SonarSource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret) |