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

ci: collect coverage from platforms and upload to Sonar #213

Merged
merged 42 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7ce6d4a
ci: collect coverage from TS files and upload to Sonar
semirp May 15, 2024
0c8f330
ci: update node setup
semirp May 15, 2024
96a071a
chore: rename sonar action
semirp May 15, 2024
e5d4c04
chore: exclude C, CPP and ObjC files
semirp May 15, 2024
3bd70af
chore: modify sources
semirp May 15, 2024
5d419bf
ci: added Android coverage
semirp May 15, 2024
e07fb0f
ci: added Ruby install action
semirp May 15, 2024
6c4c01a
ci: split jobs
semirp May 15, 2024
e6b5a8a
ci: use pinned SHAs for actions
semirp May 16, 2024
68d0a5b
ci: fixes
semirp May 16, 2024
79d9e2e
fix: remove group
semirp May 16, 2024
4b82e11
Add unit tests for iOS
NQuinn27 May 16, 2024
924169d
Add latest UIColor Tests
NQuinn27 May 16, 2024
a96a3db
Define same iOS version as SDK
NQuinn27 May 16, 2024
522ba5c
Add options
NQuinn27 May 16, 2024
0577111
Change to iPhone SE
NQuinn27 May 16, 2024
931c999
Remove excluded archs
NQuinn27 May 16, 2024
85487ca
remove destination
NQuinn27 May 16, 2024
670d934
Add sdk
NQuinn27 May 16, 2024
9cf324d
Up version
NQuinn27 May 16, 2024
b3c3073
iPhone SE
NQuinn27 May 16, 2024
7fc45c7
Add sim version
NQuinn27 May 16, 2024
497761a
change sim version
semirp May 16, 2024
64a640f
added supported platfroms
semirp May 16, 2024
bd9f303
added supported platfroms
semirp May 16, 2024
484243d
updated gems
semirp May 16, 2024
ac22ae2
updated gems
semirp May 16, 2024
028b083
updated gems
semirp May 16, 2024
bdc70d0
updated gems
semirp May 16, 2024
9c4a567
updated gems
semirp May 16, 2024
810996a
updated gems
semirp May 16, 2024
6061558
updated gems
semirp May 16, 2024
78257c5
added executable
semirp May 16, 2024
d53dba3
update device
semirp May 16, 2024
5ef1dfd
Try app bundle if
NQuinn27 May 16, 2024
8eaa079
Do pre build action
NQuinn27 May 16, 2024
4339fa6
Try destination
NQuinn27 May 16, 2024
7dbcf63
Cleanup
NQuinn27 May 16, 2024
8f58e55
chore: updated sonar sources
semirp May 17, 2024
0d4c361
chore: updated sonar sources
semirp May 17, 2024
3519903
chore: updated sonar sources
semirp May 17, 2024
e5a1066
chore: remove Gemfile duplication
semirp May 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/actions/ios-sdk-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: 'Run iOS SDK tests'
description: 'Test the iOS SDK'
inputs:
ssh-private-key:
description: SSH private key
required: true
known-hosts:
description: Known Hosts
required: true
match-password:
description: Match password
required: true
match-git-private-key:
description: Match git private key
required: true
fastlane-password:
description: Fastlane password
required: true
fastlane-session:
description: Fastlane session
required: true
match-keychain-name:
description: Match keychain name
required: true
match-keychain-password:
description: Match keychain password
required: true
source-branch:
description: Source branch
required: true
coverage-file-name:
description: Name of the generic coverage file
required: true
runs:
using: "composite"
steps:
- name: Select Xcode Version
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
with:
xcode-version: '15.2'
- name: Install SSH key
uses: shimataro/ssh-key-action@d4fffb50872869abe2d9a9098a6d9c5aa7d16be4 #v2.7.0
with:
key: ${{ inputs.ssh-private-key }}
name: id_rsa_github_actions
known_hosts: ${{ inputs.known-hosts }}
- uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0
with:
ssh-private-key: ${{ inputs.ssh-private-key }}
- uses: ruby/setup-ruby@d4526a55538b775af234ba4af27118ed6f8f6677 # v1.172.0
with:
ruby-version: "3.2"
bundler-cache: true

- name: Install packages
shell: bash
run: |
yarn install

- name: pod install
shell: bash
run: |
yarn pods

- name: Create main.jsbundle
shell: bash
run: |
yarn --cwd packages/example build:ios

- name: Test SDK bridge
shell: bash
run: |
bundle exec fastlane ios tests
env:
MATCH_PASSWORD: ${{ inputs.match-password }}
MATCH_GIT_PRIVATE_KEY: ${{ inputs.ssh-private-key }}
FASTLANE_PASSWORD: ${{ inputs.fastlane-password }}
FASTLANE_SESSION: ${{ inputs.fastlane-session }}
MATCH_KEYCHAIN_NAME: ${{ inputs.match-keychain-name }}
MATCH_KEYCHAIN_PASSWORD: ${{ inputs.match-password }}
SOURCE_BRANCH: ${{ inputs.source-branch }}
- name: Prepare coverage reports
shell: bash
run: |
bash scripts/xccov-to-sonarqube-generic.sh fastlane/test_output/example_0_70_6Tests.xcresult/ > coverage.xml
sed "s#$PWD/##g" coverage.xml > ${{ inputs.coverage-file-name }}
55 changes: 55 additions & 0 deletions .github/actions/sonar/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: 'Run Sonar tests'
description: 'Upload code quality scans to Sonar'
inputs:
github-token:
description: GitHub token
required: true
sonar-token:
description: Sonar token
required: true
sonar-host:
description: Sonar host URL
required: true
coverage-file-name:
description: Name of the LCOV coverage file
required: true
coverage-file-name-android:
description: Name of the Kover coverage file
required: true
coverage-file-name-ios:
description: Name of the iOS generic coverage file
required: true
branch:
description: Branch
required: true
pull-request-number:
description: PR number
required: false
base-branch:
description: PR target branch
required: false
pull-request-sha:
description: PR commit SHA
required: false

runs:
using: "composite"
steps:
- name: Install Sonar
shell: bash
run: |
brew install sonar-scanner
- name: Update sonar-project.properties
shell: bash
run: |
echo "sonar.pullrequest.key=${{ inputs.pull-request-number }}" >> sonar-project.properties
echo "sonar.pullrequest.branch=${{ inputs.branch }}" >> sonar-project.properties
echo "sonar.pullrequest.base=${{ inputs.base-branch }}" >> sonar-project.properties
echo "sonar.scm.revision=${{ inputs.pull-request-sha }}" >> sonar-project.properties
echo "sonar.javascript.lcov.reportPaths=${{ inputs.coverage-file-name }}" >> sonar-project.properties
echo "sonar.coverage.jacoco.xmlReportPaths=${{ inputs.coverage-file-name-android }}" >> sonar-project.properties
echo "sonar.coverageReportPaths=${{ inputs.coverage-file-name-ios }}" >> sonar-project.properties
- name: Run Sonar
shell: bash
run: |
sonar-scanner -Dsonar.token=${{ inputs.sonar-token }}
2 changes: 1 addition & 1 deletion .github/workflows/android-build-and-distribute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- uses: ruby/setup-ruby@6bd3d993c602f6b675728ebaecb2b569ff86e99b # v1.174.0
with:
ruby-version: "2.7"
ruby-version: "3.2"
bundler-cache: true

- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
Expand Down
39 changes: 0 additions & 39 deletions .github/workflows/run-tests.yml

This file was deleted.

128 changes: 128 additions & 0 deletions .github/workflows/unit-tests-and-code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Unit Tests and Code Quality
on: push
jobs:
run-unit-tests:
name: Run RN unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Setup Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
cache: 'yarn'

- name: Install modules
run: yarn install --immutable

- name: Run tests and generate lcov report
run: yarn test:unit:coverage:lcov -- --maxWorkers=1

- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: coverage-file-rn
path: coverage

run-unit-tests-android:
name: Run Android unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Setup Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
cache: 'yarn'

- name: Install modules
run: yarn install --immutable

- uses: ruby/setup-ruby@6bd3d993c602f6b675728ebaecb2b569ff86e99b # v1.174.0
with:
ruby-version: "3.2"
bundler-cache: true

- name: Install packages
shell: bash
run: |
yarn install

- name: Run Android unit tests and generate coverage
run: bundle exec fastlane android run_unit_tests_coverage

- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: coverage-file-android
path: packages/sdk/android/build/reports

run-unit-tests-ios:
name: Run iOS unit tests
runs-on: macos-13-large
timeout-minutes: 20
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Setup Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
cache: 'yarn'

- name: Install modules
run: yarn install --immutable

- name: Run SDK tests
uses: ./.github/actions/ios-sdk-tests
with:
ssh-private-key: ${{ secrets.SSH_KEY }}
known-hosts: ${{ secrets.KNOWN_HOSTS }}
match-password: ${{ secrets.MATCH_PASSWORD }}
match-git-private-key: ${{ secrets.FASTLANE_PASSWORD }}
fastlane-session: ${{ secrets.FASTLANE_SESSION }}
fastlane-password: ${{ secrets.FASTLANE_PASSWORD }}
match-keychain-name: ${{ secrets.MATCH_KEYCHAIN_NAME }}
match-keychain-password: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }}
coverage-file-name: sonar-coverage.xml

- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: coverage-file-ios
path: sonar-coverage.xml

sonarcloud:
needs:
- run-unit-tests
- run-unit-tests-android
- run-unit-tests-ios
name: Run Code checks using Sonar
runs-on: macos-13-large
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: coverage-file-rn
path: coverage

- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: coverage-file-android

- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: coverage-file-ios

- name: SonarCloud Scan
uses: ./.github/actions/sonar
with:
github-token: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
sonar-token: ${{ secrets.SONAR_TOKEN }}
sonar-host: https://sonarcloud.io.
pull-request-number: ${{ github.event.pull_request.number }}
branch: ${{ github.head_ref }}
base-branch: ${{ github.base_ref }}
pull-request-sha: ${{ github.event.pull_request.head.sha }}
coverage-file-name: ./coverage/lcov.info
coverage-file-name-android: ./kover/reportRelease.xml
coverage-file-name-ios: sonar-coverage.xml
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,9 @@ android/keystores/debug.keystore
lib/

# npm
.npmrc
.npmrc

# files
**/coverage/*
**/coverage.json
.nyc_output/
Loading