From d8d0dff8c9f0df1b9214b2cc82851619ef7fa0f0 Mon Sep 17 00:00:00 2001 From: ddwsd Date: Tue, 3 Nov 2020 00:37:09 +0800 Subject: [PATCH 1/4] test: sonarcloud --- .github/workflows/deploy_branch_preview.yml | 90 ++++++++++++--------- 1 file changed, 51 insertions(+), 39 deletions(-) diff --git a/.github/workflows/deploy_branch_preview.yml b/.github/workflows/deploy_branch_preview.yml index 18fa710a2..1d6885a06 100644 --- a/.github/workflows/deploy_branch_preview.yml +++ b/.github/workflows/deploy_branch_preview.yml @@ -3,6 +3,18 @@ name: Deploy Branch Preview on: [pull_request] jobs: + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + # with: + # fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} test: name: Lint & Test runs-on: ubuntu-latest @@ -47,12 +59,12 @@ jobs: - uses: actions/setup-node@v1 with: node-version: 12.x - - uses: expo/expo-github-action@v5 - with: - expo-packager: npm - expo-username: ${{ secrets.EXPO_CLI_TEST_USERNAME }} - expo-password: ${{ secrets.EXPO_CLI_TEST_PASSWORD }} - expo-cache: true + # - uses: expo/expo-github-action@v5 + # with: + # expo-packager: npm + # expo-username: ${{ secrets.EXPO_CLI_TEST_USERNAME }} + # expo-password: ${{ secrets.EXPO_CLI_TEST_PASSWORD }} + # expo-cache: true - name: Cache Node Modules uses: actions/cache@v2 env: @@ -78,36 +90,36 @@ jobs: run: | echo Build number is $GITHUB_RUN_NUMBER echo Latest release is ${{ steps.latestBinaryVersion.outputs.version }} - - name: Expo Publish Channel - env: - SENTRY_ORG: ${{ secrets.SENTRY_ORG }} - SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_DSN: ${{ secrets.SENTRY_DSN }} - APP_BUILD_VERSION: ${{ github.run_number }} - APP_BINARY_VERSION: ${{ steps.latestBinaryVersion.outputs.version }} - DOMAIN_FORMAT: ${{ secrets.TEST_DOMAIN_FORMAT }} - run: expo publish --non-interactive --release-channel pr${{ github.event.number }} - - name: Expo Publish Storybook Channel - env: - SENTRY_ORG: ${{ secrets.SENTRY_ORG }} - SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_DSN: ${{ secrets.SENTRY_DSN }} - APP_BUILD_VERSION: ${{ github.run_number }} - APP_BINARY_VERSION: ${{ steps.latestBinaryVersion.outputs.version }} - DOMAIN_FORMAT: ${{ secrets.TEST_DOMAIN_FORMAT }} - run: expo publish --non-interactive --release-channel storybook-pr${{ github.event.number }} - - name: Add Comment To PR - uses: mshick/add-pr-comment@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - EXPO_PROJECT: "@supplyallytest/rationally" - with: - message: | - ## Application - ![Expo QR](https://api.qrserver.com/v1/create-qr-code/?size=250x250&data=exp://exp.host/${{ env.EXPO_PROJECT }}?release-channel=pr${{ github.event.number }}) - Published to https://exp.host/${{ env.EXPO_PROJECT }}?release-channel=pr${{ github.event.number }} - ## Storybook - ![Expo QR](https://api.qrserver.com/v1/create-qr-code/?size=250x250&data=exp://exp.host/${{ env.EXPO_PROJECT }}?release-channel=storybook-pr${{ github.event.number }}) - Published to https://exp.host/${{ env.EXPO_PROJECT }}?release-channel=storybook-pr${{ github.event.number }} + # - name: Expo Publish Channel + # env: + # SENTRY_ORG: ${{ secrets.SENTRY_ORG }} + # SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} + # SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + # SENTRY_DSN: ${{ secrets.SENTRY_DSN }} + # APP_BUILD_VERSION: ${{ github.run_number }} + # APP_BINARY_VERSION: ${{ steps.latestBinaryVersion.outputs.version }} + # DOMAIN_FORMAT: ${{ secrets.TEST_DOMAIN_FORMAT }} + # run: expo publish --non-interactive --release-channel pr${{ github.event.number }} + # - name: Expo Publish Storybook Channel + # env: + # SENTRY_ORG: ${{ secrets.SENTRY_ORG }} + # SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} + # SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + # SENTRY_DSN: ${{ secrets.SENTRY_DSN }} + # APP_BUILD_VERSION: ${{ github.run_number }} + # APP_BINARY_VERSION: ${{ steps.latestBinaryVersion.outputs.version }} + # DOMAIN_FORMAT: ${{ secrets.TEST_DOMAIN_FORMAT }} + # run: expo publish --non-interactive --release-channel storybook-pr${{ github.event.number }} + # - name: Add Comment To PR + # uses: mshick/add-pr-comment@v1 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # EXPO_PROJECT: "@supplyallytest/rationally" + # with: + # message: | + # ## Application + # ![Expo QR](https://api.qrserver.com/v1/create-qr-code/?size=250x250&data=exp://exp.host/${{ env.EXPO_PROJECT }}?release-channel=pr${{ github.event.number }}) + # Published to https://exp.host/${{ env.EXPO_PROJECT }}?release-channel=pr${{ github.event.number }} + # ## Storybook + # ![Expo QR](https://api.qrserver.com/v1/create-qr-code/?size=250x250&data=exp://exp.host/${{ env.EXPO_PROJECT }}?release-channel=storybook-pr${{ github.event.number }}) + # Published to https://exp.host/${{ env.EXPO_PROJECT }}?release-channel=storybook-pr${{ github.event.number }} From 871de390b11e59588f970f84013f635d93f51bbf Mon Sep 17 00:00:00 2001 From: ddwsd Date: Tue, 3 Nov 2020 00:41:38 +0800 Subject: [PATCH 2/4] fix: sonar-project.properties --- sonar-project.properties | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index 63ff0a5c9..7ad6f8233 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,7 +1,20 @@ -sonar.projectKey=Open-Attestation_identity-wallet -sonar.organization=open-attestation -sonar.projectName=identity-wallet -sonar.projectVersion=1.0 -sonar.test.inclusions=src/**/*.test.ts,src/**/*.test.tsx -sonar.inclusions=src/** -sonar.typescript.lcov.reportPaths=coverage/lcov.info +# sonar.projectKey=Open-Attestation_identity-wallet +# sonar.organization=open-attestation +# sonar.projectName=identity-wallet +# sonar.projectVersion=1.0 +# sonar.test.inclusions=src/**/*.test.ts,src/**/*.test.tsx +# sonar.inclusions=src/** +# sonar.typescript.lcov.reportPaths=coverage/lcov.info + +sonar.projectKey=ddwsd_mobile-application +sonar.organization=ddwsd-sonarcloud + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=mobile-application +#sonar.projectVersion=1.0 + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 From 0f524af950bb75b8318cac6e0515a7680d0300d5 Mon Sep 17 00:00:00 2001 From: ddwsd Date: Thu, 5 Nov 2020 11:39:33 +0800 Subject: [PATCH 3/4] test: add fetch-depth --- .github/workflows/deploy_branch_preview.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy_branch_preview.yml b/.github/workflows/deploy_branch_preview.yml index 1d6885a06..f430c888f 100644 --- a/.github/workflows/deploy_branch_preview.yml +++ b/.github/workflows/deploy_branch_preview.yml @@ -8,8 +8,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - # with: - # fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: From 5ea81e10a9e19b6ec2f88dd89264f274492a6ebe Mon Sep 17 00:00:00 2001 From: ddwsd Date: Thu, 5 Nov 2020 11:53:22 +0800 Subject: [PATCH 4/4] test: add bad code to see of sonarcloud captures --- src/context/alert.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/context/alert.tsx b/src/context/alert.tsx index 7316528d0..ba1b54f1f 100644 --- a/src/context/alert.tsx +++ b/src/context/alert.tsx @@ -122,6 +122,9 @@ const messageToTranslationKeyMappings: Record = { }; const getTranslationKeyFromErrorMessage = (message: string): string => { + const c = 2; + if (c > 0) { + } return messageToTranslationKeyMappings[message] ?? message; };