Skip to content

Commit 9bcd257

Browse files
committed
Simplify sonarqube workflow
1 parent c614ed2 commit 9bcd257

File tree

4 files changed

+31
-30
lines changed

4 files changed

+31
-30
lines changed

.github/workflows/ci-cd.yml renamed to .github/workflows/ci.yml

+20-29
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
name: ci-cd
1+
name: ci
2+
23
on:
4+
push:
5+
branches:
6+
- '**'
37
pull_request:
48
branches:
59
- master
610
- development
7-
push:
8-
branches:
9-
- '*'
1011

1112
concurrency:
12-
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.run_number || github.event.pull_request.number }}
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
1314
cancel-in-progress: true
1415

1516
permissions:
@@ -44,41 +45,39 @@ jobs:
4445
- name: npm build
4546
run: BUILD_BRANCH=$(echo "${GITHUB_REF#refs/heads/}") BUILD_COMMIT=${{ github.sha }} npm run build
4647

48+
- name: Set VERSION env
49+
run: echo "VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV
50+
4751
- name: SonarQube Scan (Push)
48-
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/development' || github.ref == 'refs/heads/master') }}
49-
uses: SonarSource/sonarcloud-github-action@v1.8
52+
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/development')
53+
uses: SonarSource/sonarcloud-github-action@v1.9
5054
env:
5155
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5257
with:
5358
projectBaseDir: .
5459
args: >
5560
-Dsonar.host.url=${{ secrets.SONARQUBE_HOST }}
56-
-Dsonar.projectName=${{ github.event.repository.name }}
57-
-Dsonar.projectKey=${{ github.event.repository.name }}
58-
-Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info
59-
-Dsonar.links.ci="https://github.com/splitio/${{ github.event.repository.name }}/actions"
60-
-Dsonar.links.scm="https://github.com/splitio/${{ github.event.repository.name }}"
61+
-Dsonar.projectVersion=${{ env.VERSION }}
62+
-Dsonar.branch.name=${{ github.ref_name }}
6163
6264
- name: SonarQube Scan (Pull Request)
6365
if: github.event_name == 'pull_request'
64-
uses: SonarSource/sonarcloud-github-action@v1.8
66+
uses: SonarSource/sonarcloud-github-action@v1.9
6567
env:
6668
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6770
with:
6871
projectBaseDir: .
6972
args: >
7073
-Dsonar.host.url=${{ secrets.SONARQUBE_HOST }}
71-
-Dsonar.projectName=${{ github.event.repository.name }}
72-
-Dsonar.projectKey=${{ github.event.repository.name }}
73-
-Dsonar.links.ci="https://github.com/splitio/${{ github.event.repository.name }}/actions"
74-
-Dsonar.links.scm="https://github.com/splitio/${{ github.event.repository.name }}"
75-
-Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info
74+
-Dsonar.projectVersion=${{ env.VERSION }}
7675
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
7776
-Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }}
7877
-Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }}
7978
8079
- name: Store assets
81-
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/development' || github.ref == 'refs/heads/master') }}
80+
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/development')
8281
uses: actions/upload-artifact@v3
8382
with:
8483
name: assets
@@ -89,19 +88,15 @@ jobs:
8988
name: Upload assets
9089
runs-on: ubuntu-latest
9190
needs: build
92-
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/development' }}
91+
if: github.event_name == 'push' && github.ref == 'refs/heads/development'
9392
strategy:
9493
matrix:
9594
environment:
9695
- stage
97-
#- stage-eu
9896
include:
9997
- environment: stage
10098
account_id: "079419646996"
10199
bucket: split-public-stage
102-
# - environment: stage-eu
103-
# account_id: "901851837056"
104-
# bucket: split-public-stage-eu-west-1
105100

106101
steps:
107102
- name: Download assets
@@ -132,19 +127,15 @@ jobs:
132127
name: Upload assets
133128
runs-on: ubuntu-latest
134129
needs: build
135-
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
130+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
136131
strategy:
137132
matrix:
138133
environment:
139134
- prod
140-
#- prod-eu
141135
include:
142136
- environment: prod
143137
account_id: "825951051969"
144138
bucket: split-public
145-
# - environment: prod-eu
146-
# account_id: "842946900133"
147-
# bucket: split-public-eu-west-1
148139

149140
steps:
150141
- name: Download assets

.github/workflows/update-license-year.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v3
1717
with:
1818
fetch-depth: 0
1919

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/es
66
/umd
77
/coverage
8+
.scannerwork

sonar-project.properties

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
sonar.projectName=react-client
2+
sonar.projectKey=react-client
3+
sonar.sources=src
4+
sonar.inclusions=**/*.ts,**/*.tsx
5+
sonar.tests=src
6+
sonar.test.inclusions=**/*.test.ts,**/*.test.tsx
7+
sonar.javascript.lcov.reportPaths=coverage/lcov.info
8+
sonar.links.ci=https://github.com/splitio/react-client
9+
sonar.links.scm=https://github.com/splitio/react-client/actions

0 commit comments

Comments
 (0)