Skip to content

Commit

Permalink
Merge pull request #599 from thornbill/fix-sonar-job
Browse files Browse the repository at this point in the history
Use pull_request_target trigger to run tests with secrets
  • Loading branch information
thornbill authored Nov 14, 2023
2 parents 9919055 + 0046c16 commit 2ee68a2
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 32 deletions.
36 changes: 4 additions & 32 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Code quality

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
push:
branches: [ master ]
Expand Down Expand Up @@ -48,35 +52,3 @@ jobs:

- name: Run TypeScript build
run: npx tsc --noEmit

jest:
name: Test
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Set up Node.js
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
node-version: 16
check-latest: true
cache: npm

- name: Install Node.js dependencies
run: npm ci --no-audit

- name: Run jest
run: npx jest --coverage --group=unit

- name: SonarCloud scan
if: ${{ github.repository == 'jellyfin/jellyfin-sdk-typescript' }}
uses: SonarSource/sonarcloud-github-action@c25d2e7e3def96d0d1781000d3c429da22cd6252 # v2.0.2
env:
GITHUB_TOKEN: ${{ secrets.JF_BOT_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Upload coverage
if: ${{ github.repository == 'jellyfin/jellyfin-sdk-typescript' }}
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
54 changes: 54 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Test

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
push:
branches: [ master ]
pull_request_target:
branches: [ master ]

jobs:
jest:
name: Test
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Node.js
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
node-version: 16
check-latest: true
cache: npm

- name: Install Node.js dependencies
run: npm ci --no-audit

- name: Run jest
run: npx jest --coverage --group=unit

- name: SonarCloud scan
if: ${{ github.repository == 'jellyfin/jellyfin-sdk-typescript' }}
uses: SonarSource/sonarcloud-github-action@c25d2e7e3def96d0d1781000d3c429da22cd6252 # v2.0.2
env:
GITHUB_TOKEN: ${{ secrets.JF_BOT_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.pullrequest.provider=github
-Dsonar.pullrequest.github.repository=${{ github.repository }}
-Dsonar.pullrequest.github.token.secured=${{ secrets.GITHUB_TOKEN }}
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
-Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }}
-Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }}
- name: Upload coverage
if: ${{ github.repository == 'jellyfin/jellyfin-sdk-typescript' }}
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4

0 comments on commit 2ee68a2

Please sign in to comment.