name: test_coverage on: pull_request: # open will be triggered when a pull request is created. # synchronize will be triggered when a pull request has new commits. # closed will be triggered when a pull request is closed. types: [opened, synchronize, closed] env: METRICS_SERVICE_SECRET: ${{ secrets.GHASecretsGPGPassphrase1 }} concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} cancel-in-progress: true jobs: pod_lib_lint: if: github.repository == 'google/GoogleUtilities' && (github.event.action == 'synchronize' || github.event.action == 'opened' || github.event.pull_request.merged) runs-on: macos-latest strategy: matrix: target: [ios] steps: - uses: ruby/setup-ruby@v1 with: ruby-version: "2.7" - uses: actions/checkout@v3 - name: Setup Scripts Directory run: ./setup-scripts.sh - name: Setup Bundler run: ./scripts/setup_bundler.sh - name: PodLibLint DataTransport run: | scripts/health_metrics/pod_test_code_coverage_report.sh --sdk=GoogleUtilities --platform=${{ matrix.target }} --test_spec=unit,unit-swift --output_path="/Users/runner/GoogleUtilities-ios-unit.xcresult" - uses: actions/upload-artifact@v2 with: name: codecoverage path: /Users/runner/*.xcresult manage_test_results: if: github.repository == 'google/GoogleUtilities' && (github.event.action == 'synchronize' || github.event.action == 'opened' || github.event.pull_request.merged) needs: pod_lib_lint runs-on: macOS-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - uses: actions/download-artifact@v2 id: download with: path: /Users/runner/test - name: Setup Scripts Directory run: ./setup-scripts.sh - name: Access to Metrics Service if: ${{ env.METRICS_SERVICE_SECRET }} run: | # Install gcloud sdk curl https://sdk.cloud.google.com > install.sh bash install.sh --disable-prompts echo "${HOME}/google-cloud-sdk/bin/" >> $GITHUB_PATH export PATH="${HOME}/google-cloud-sdk/bin/:${PATH}" # Activate the service account for Metrics Service. scripts/decrypt_gha_secret.sh scripts/gha-encrypted/metrics_service_access.json.gpg \ metrics-access.json "${{ env.METRICS_SERVICE_SECRET }}" gcloud auth activate-service-account --key-file metrics-access.json - name: Build code coverage tool run: swift build --package-path firebase-ios-sdk/scripts/health_metrics/generate_code_coverage_report/ - name: Generate report if: github.event.pull_request.merged != true && env.METRICS_SERVICE_SECRET env: pr_branch: ${{ github.event.pull_request.head.ref }} run: | common_commit=$(git merge-base remotes/origin/${pr_branch} remotes/origin/main) GITHUB_SHA=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.head.sha) if [ -d "${{steps.download.outputs.download-path}}" ]; then firebase-ios-sdk/scripts/health_metrics/generate_code_coverage_report/.build/debug/CoverageReportGenerator --presubmit "google/GoogleUtilities" --head-commit "${GITHUB_SHA}" --token $(gcloud auth print-identity-token) --xcresult-dir "${{steps.download.outputs.download-path}}/codecoverage" --log-link "https://github.com/google/GoogleUtilities/actions/runs/${GITHUB_RUN_ID}" --pull-request-num ${{github.event.pull_request.number}} --base-commit "$common_commit" fi - name: Update New Coverage Data if: github.event.pull_request.merged == true && env.METRICS_SERVICE_SECRET run: | if [ -d "${{steps.download.outputs.download-path}}" ]; then firebase-ios-sdk/scripts/health_metrics/generate_code_coverage_report/.build/debug/CoverageReportGenerator --merge "google/GoogleUtilities" --head-commit "${GITHUB_SHA}" --token $(gcloud auth print-identity-token) --xcresult-dir "${{steps.download.outputs.download-path}}/codecoverage" --log-link "https://github.com/google/GoogleUtilities/actions/runs/${GITHUB_RUN_ID}" --source-branch "${{ github.base_ref }}" fi