Update sonar_test.yml #7
This file contains hidden or 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: "Test-with-sonar" | |
| on: [push] | |
| permissions: | |
| id-token: write | |
| contents: read | |
| attestations: write | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| env: | |
| JF_ENV_LOCAL: eyJ2ZXJzaW9uIjoxLCJ1cmwiOiJodHRwOi8vMTI3LjAuMC4xOjgwODEvYXJ0aWZhY3RvcnkvIiwidXNlciI6ImFkbWluIiwicGFzc3dvcmQiOiJBUEI3REVaUlBpSHFIRFRRb2tMa3g5aGh6S1QiLCJzZXJ2ZXJJZCI6ImxvY2FsIn0= | |
| steps: | |
| # Checkout and install prerequisites | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup NodeJS | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20.x" | |
| - name: Install jfrog cli | |
| id: setup-cli | |
| uses: jfrog/setup-jfrog-cli@v4 | |
| env: | |
| JF_URL: https://${{ vars.JF_URL }} | |
| JF_PROJECT: "carmit-prj-1" | |
| with: | |
| oidc-provider-name: jfrog-github-oidc | |
| - name: Generate .npmrc | |
| run: jf npm-config --repo-resolve-releases=carmit-prj-1-npm-remote --repo-deploy-releases=carmit-prj-1-npm-local | |
| # Run --version | |
| - name: Check versions | |
| run: jf --version && jfrog --version | |
| # Check local server successfully configured | |
| - name: Sanity | |
| run: jf c show local || jfrog rt config show local | |
| # Check build URL | |
| - name: Check build URL | |
| uses: wei/curl@master | |
| with: | |
| args: -I ${JFROG_CLI_BUILD_URL} | |
| if: runner.os == 'Linux' | |
| # Install and run tests | |
| - name: Install | |
| run: jf npm i --project takoshop | |
| - name: Unit tests | |
| run: npm t | |
| - name: Install SonarQube Scanner | |
| run: | | |
| curl -sL -sSLo sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.2.1.4610.zip | |
| unzip sonar-scanner.zip | |
| export PATH=$PATH:$PWD/sonar-scanner-6.2.1.4610/bin | |
| pwd | |
| ls -l $PWD/sonar-scanner-6.2.1.4610/bin/ | |
| echo "$PWD/sonar-scanner-6.2.1.4610/bin" | |
| - name: Run SonarScanner | |
| id: run-sonar-scanner | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| run: | | |
| $PWD/sonar-scanner-6.2.1.4610/bin/sonar-scanner \ | |
| -Dsonar.projectKey=setup-jfrog-cli \ | |
| -Dsonar.organization=my-evidence-test-org1 \ | |
| -Dsonar.host.url=https://sonarcloud.io \ | |
| -Dsonar.java.jdkHome=$JAVA_HOME \ | |
| -Dsonar.verbose=true \ | |
| -Dsonar.token=$SONAR_TOKEN | |
| - name: get task id | |
| run: | | |
| cat $PWD/.scannerwork/report-task.txt | |
| - name: publish to artifactory | |
| run: | | |
| jf npm publish --project takoshop --registry https://${{ vars.JF_URL }}/artifactory/api/npm/carmit-prj-1-npm-local/ | |
| - name: check file system | |
| run: | | |
| ls -ltr | |