Skip to content

Conversation

@WayneWhitehead
Copy link
Owner

Description

copilot:all

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Request a Review from Copilot

  • Request a review from GitHub Copilot by adding @github-copilot as a reviewer.

WayneWhitehead and others added 30 commits March 4, 2025 14:55
name: PR Linting

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  check-hardcoded-values:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
        with:
          fetch-depth: 0  # Fetch all history for the branches involved in the PR

      - name: Set up JDK 17
        uses: actions/setup-java@v2
        with:
          distribution: 'adopt'
          java-version: 17
          java-package: jdk
          architecture: x64
          check-latest: false

      - name: Get list of changed files
        id: changed-files
        uses: tj-actions/changed-files@v34
        with:
          files: |
            app/src/main/java/**/*.kt

      - name: Find hardcoded values in changed files
        id: find-hardcoded-values
        run: |
          set -e
          STRING_WARNINGS=""
          SIZE_WARNINGS=""
          for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
            FILE_NAME=$(basename $file)
            STRING_LINES=$(grep -nE '"[^"]*"' $file | grep -v 'const val' | grep -v '""' | grep -v '@SerializedName') || true
            SIZE_LINES=$(grep -nE '[0-9]+\.dp' $file) || true
            if [ ! -z "$STRING_LINES" ]; then
              STRING_WARNINGS="$STRING_WARNINGS\n## $FILE_NAME\n**Full Path:** $file\n### Hardcoded Strings\n$STRING_LINES"
            fi
            if [ ! -z "$SIZE_LINES" ]; then
              SIZE_WARNINGS="$SIZE_WARNINGS\n## $FILE_NAME\n**Full Path:** $file\n### Hardcoded Sizes\n$SIZE_LINES"
            fi
          done
          if [ -z "$STRING_WARNINGS" ] && [ -z "$SIZE_WARNINGS" ]; then
            echo "No hardcoded values found."
          else
            echo "STRING_WARNINGS<<EOF" >> $GITHUB_ENV
            echo -e "$STRING_WARNINGS" >> $GITHUB_ENV
            echo "EOF" >> $GITHUB_ENV
            echo "SIZE_WARNINGS<<EOF" >> $GITHUB_ENV
            echo -e "$SIZE_WARNINGS" >> $GITHUB_ENV
            echo "EOF" >> $GITHUB_ENV
            echo "::warning::Hardcoded values found."
          fi
        shell: /usr/bin/bash -e {0}
        env:
          JAVA_HOME: /opt/hostedtoolcache/Java_Adopt_jdk/17.0.14-7/x64

      - name: Post string warnings as comments
        if: env.STRING_WARNINGS != ''
        uses: actions/github-script@v5
        with:
          script: |
            const stringWarnings = process.env.STRING_WARNINGS.split('\n');
            const { context, github } = require('@actions/github');
            const commitId = context.payload.pull_request.head.sha;
            stringWarnings.forEach(line => {
              if (line.trim() !== '' && line.startsWith('## ')) {
                const filePath = line.split('**Full Path:** ')[1];
                const lineNumber = parseInt(line.split(':')[0].split(' ')[1]);
                github.rest.pulls.createReviewComment({
                  owner: context.repo.owner,
                  repo: context.repo.repo,
                  pull_number: context.payload.pull_request.number,
                  body: 'Hardcoded string found here.',
                  commit_id: commitId,
                  path: filePath,
                  position: lineNumber
                });
              }
            });

      - name: Post size warnings as comments
        if: env.SIZE_WARNINGS != ''
        uses: actions/github-script@v5
        with:
          script: |
            const sizeWarnings = process.env.SIZE_WARNINGS.split('\n');
            const { context, github } = require('@actions/github');
            const commitId = context.payload.pull_request.head.sha;
            sizeWarnings.forEach(line => {
              if (line.trim() !== '' && line.startsWith('## ')) {
                const filePath = line.split('**Full Path:** ')[1];
                const lineNumber = parseInt(line.split(':')[0].split(' ')[1]);
                github.rest.pulls.createReviewComment({
                  owner: context.repo.owner,
                  repo: context.repo.repo,
                  pull_number: context.payload.pull_request.number,
                  body: 'Hardcoded size found here.',
                  commit_id: commitId,
                  path: filePath,
                  position: lineNumber
                });
              }
            });
@github-actions
Copy link

ViewModel Test Coverage:

Class Instructions Branches Complexity Lines Methods
WeatherViewModel 96% n/a 100% 88% 100%

Other Test Coverage:

Class Instructions Branches Complexity Lines Methods
AirPollutionResponse 61% n/a 33% 100% 33%
OneCallResponse 61% n/a 11% 100% 11%
MainActivity 0% 0% 0% 0% 0%
DateUtils 100% 100% 100% 100% 100%
LocationUtil 28% 0% 13% 29% 14%
WeatherUtil 88% 77% 63% 100% 100%

@github-actions github-actions bot changed the title 🐞 🐞 Fixes/general 🐞 🐞 🐞 Fixes/general Mar 20, 2025
@github-actions
Copy link

ViewModel Test Coverage:

Class Instructions Branches Complexity Lines Methods
WeatherViewModel 96% n/a 100% 88% 100%

Other Test Coverage:

Class Instructions Branches Complexity Lines Methods
AirPollutionResponse 61% n/a 33% 100% 33%
OneCallResponse 61% n/a 11% 100% 11%
MainActivity 0% 0% 0% 0% 0%
DateUtils 100% 100% 100% 100% 100%
LocationUtil 28% 0% 13% 29% 14%
WeatherUtil 88% 77% 63% 100% 100%

@WayneWhitehead WayneWhitehead requested a review from Copilot March 20, 2025 10:43

This comment was marked as resolved.

@github-actions
Copy link

ViewModel Test Coverage:

Class Instructions Branches Complexity Lines Methods
WeatherViewModel 96% n/a 100% 88% 100%

Other Test Coverage:

Class Instructions Branches Complexity Lines Methods
AirPollutionResponse 61% n/a 33% 100% 33%
OneCallResponse 61% n/a 11% 100% 11%
MainActivity 0% 0% 0% 0% 0%
DateUtils 100% 100% 100% 100% 100%
LocationUtil 28% 0% 13% 29% 14%
WeatherUtil 88% 77% 63% 100% 100%

@WayneWhitehead WayneWhitehead requested a review from Copilot March 20, 2025 10:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds two new GitHub Actions workflows to automate PR tests and checks for key quality indicators such as missing test files, code coverage reports, and hardcoded values.

  • Introduces a "PR Tests" workflow to generate test coverage reports and post comments on missing ViewModel test files.
  • Adds a "PR Checks" workflow to identify hardcoded values in Kotlin files and automatically update PR titles and labels.

Reviewed Changes

Copilot reviewed 13 out of 31 changed files in this pull request and generated no comments.

File Description
.github/workflows/pr-tests.yml New workflow for running tests, generating coverage reports, and posting comments on test coverage.
.github/workflows/pr-checks.yml New workflow for checking hardcoded values and updating PR details including title and labels.
Files not reviewed (18)
  • app/build.gradle.kts: Language not supported
  • app/src/main/AndroidManifest.xml: Language not supported
  • app/src/main/java/com/hidesign/hiweather/data/model/AirPollutionResponse.kt: Language not supported
  • app/src/main/java/com/hidesign/hiweather/data/model/OneCallResponse.kt: Language not supported
  • app/src/main/java/com/hidesign/hiweather/presentation/MainActivity.kt: Language not supported
  • app/src/main/java/com/hidesign/hiweather/presentation/WeatherViewModel.kt: Language not supported
  • app/src/main/java/com/hidesign/hiweather/presentation/components/CelestialComponents.kt: Language not supported
  • app/src/main/java/com/hidesign/hiweather/presentation/components/ForecastComponents.kt: Language not supported
  • app/src/main/java/com/hidesign/hiweather/presentation/dialog/AirPollutionSheet.kt: Language not supported
  • app/src/main/java/com/hidesign/hiweather/presentation/dialog/CelestialSheet.kt: Language not supported
  • app/src/main/java/com/hidesign/hiweather/presentation/dialog/ForecastSheet.kt: Language not supported
  • app/src/main/java/com/hidesign/hiweather/presentation/dialog/WindSheet.kt: Language not supported
  • app/src/main/java/com/hidesign/hiweather/util/DateUtils.kt: Language not supported
  • app/src/main/java/com/hidesign/hiweather/util/LocationUtil.kt: Language not supported
  • app/src/main/java/com/hidesign/hiweather/util/WeatherUtil.kt: Language not supported
  • app/src/test/java/com/hidesign/hiweather/HiWeatherAppTest.kt: Language not supported
  • app/src/test/java/com/hidesign/hiweather/dagger/AppModuleTest.kt: Language not supported
  • app/src/test/java/com/hidesign/hiweather/model/AirPollutionResponseTest.kt: Language not supported
Comments suppressed due to low confidence (2)

.github/workflows/pr-tests.yml:261

  • The header used in this condition does not match the header defined earlier in the file. Consider aligning the header text to ensure the condition accurately checks for the expected content.
if (viewModelCoverageDetails.trim() !== '### ViewModel Test Coverage:\n\n| Class | Line Coverage | Method Coverage | Branch Coverage | Complexity |\n|-------|---------------|-----------------|-----------------|------------|\n') {

.github/workflows/pr-tests.yml:265

  • The header used for the Other test coverage condition is mismatched with the header defined earlier. Update the header text to ensure consistency in the condition check.
if (otherCoverageDetails.trim() !== '### Other Test Coverage:\n\n| Class | Line Coverage | Method Coverage | Branch Coverage | Complexity |\n|-------|---------------|-----------------|-----------------|------------|\n') {

@github-actions
Copy link

ViewModel Test Coverage:

Class Instructions Branches Complexity Lines Methods
WeatherViewModel 96% n/a 100% 88% 100%

Other Test Coverage:

Class Instructions Branches Complexity Lines Methods
AirPollutionResponse 61% n/a 33% 100% 33%
OneCallResponse 61% n/a 11% 100% 11%
MainActivity 0% 0% 0% 0% 0%
DateUtils 100% 100% 100% 100% 100%
LocationUtil 28% 0% 13% 29% 14%
WeatherUtil 88% 77% 63% 100% 100%

@github-actions
Copy link

ViewModel Test Coverage:

Class Instructions Branches Complexity Lines Methods
WeatherViewModel 96% n/a 100% 88% 100%

Other Test Coverage:

Class Instructions Branches Complexity Lines Methods
AirPollutionResponse 61% n/a 33% 100% 33%
OneCallResponse 61% n/a 11% 100% 11%
MainActivity 0% 0% 0% 0% 0%
DateUtils 100% 100% 100% 100% 100%
LocationUtil 28% 0% 13% 29% 14%
WeatherUtil 88% 77% 63% 100% 100%

@github-actions
Copy link

ViewModel Test Coverage:

Class Instructions Branches Complexity Lines Methods
WeatherViewModel 96% n/a 100% 88% 100%

Other Test Coverage:

Class Instructions Branches Complexity Lines Methods
AirPollutionResponse 61% n/a 33% 100% 33%
OneCallResponse 61% n/a 11% 100% 11%
MainActivity 0% 0% 0% 0% 0%
DateUtils 100% 100% 100% 100% 100%
LocationUtil 28% 0% 13% 29% 14%
WeatherUtil 88% 77% 63% 100% 100%

1 similar comment
@github-actions
Copy link

ViewModel Test Coverage:

Class Instructions Branches Complexity Lines Methods
WeatherViewModel 96% n/a 100% 88% 100%

Other Test Coverage:

Class Instructions Branches Complexity Lines Methods
AirPollutionResponse 61% n/a 33% 100% 33%
OneCallResponse 61% n/a 11% 100% 11%
MainActivity 0% 0% 0% 0% 0%
DateUtils 100% 100% 100% 100% 100%
LocationUtil 28% 0% 13% 29% 14%
WeatherUtil 88% 77% 63% 100% 100%

@github-actions
Copy link

This is a summary generated by Copilot for PR #7.

@github-actions
Copy link

ViewModel Test Coverage:

Class Instructions Branches Complexity Lines Methods
WeatherViewModel 96% n/a 100% 88% 100%

Other Test Coverage:

Class Instructions Branches Complexity Lines Methods
AirPollutionResponse 61% n/a 33% 100% 33%
OneCallResponse 61% n/a 11% 100% 11%
MainActivity 0% 0% 0% 0% 0%
DateUtils 100% 100% 100% 100% 100%
LocationUtil 28% 0% 13% 29% 14%
WeatherUtil 88% 77% 63% 100% 100%

@github-actions
Copy link

ViewModel Test Coverage:

Class Instructions Branches Complexity Lines Methods
WeatherViewModel 96% n/a 100% 88% 100%

Other Test Coverage:

Class Instructions Branches Complexity Lines Methods
AirPollutionResponse 61% n/a 33% 100% 33%
OneCallResponse 61% n/a 11% 100% 11%
MainActivity 0% 0% 0% 0% 0%
DateUtils 100% 100% 100% 100% 100%
LocationUtil 28% 0% 13% 29% 14%
WeatherUtil 88% 77% 63% 100% 100%

@github-actions
Copy link

ViewModel Test Coverage:

Class Instructions Branches Complexity Lines Methods
WeatherViewModel 96% n/a 100% 88% 100%

Other Test Coverage:

Class Instructions Branches Complexity Lines Methods
AirPollutionResponse 61% n/a 33% 100% 33%
OneCallResponse 61% n/a 11% 100% 11%
MainActivity 0% 0% 0% 0% 0%
DateUtils 100% 100% 100% 100% 100%
LocationUtil 28% 0% 13% 29% 14%
WeatherUtil 88% 77% 63% 100% 100%

@WayneWhitehead WayneWhitehead changed the title 🐞 🐞 🐞 Fixes/general 🐞Fixes/general Mar 24, 2025
@github-actions
Copy link

ViewModel Test Coverage:

Class Instructions Branches Complexity Lines Methods
WeatherViewModel 96% n/a 100% 88% 100%

UseCase Test Coverage:

Class Instructions Branches Complexity Lines Methods

Other Test Coverage:

Class Instructions Branches Complexity Lines Methods
AirPollutionResponse 61% n/a 33% 100% 33%
OneCallResponse 61% n/a 11% 100% 11%
MainActivity 0% 0% 0% 0% 0%
DateUtils 100% 100% 100% 100% 100%
LocationUtil 28% 0% 13% 29% 14%
WeatherUtil 88% 77% 63% 100% 100%

1 similar comment
@github-actions
Copy link

ViewModel Test Coverage:

Class Instructions Branches Complexity Lines Methods
WeatherViewModel 96% n/a 100% 88% 100%

UseCase Test Coverage:

Class Instructions Branches Complexity Lines Methods

Other Test Coverage:

Class Instructions Branches Complexity Lines Methods
AirPollutionResponse 61% n/a 33% 100% 33%
OneCallResponse 61% n/a 11% 100% 11%
MainActivity 0% 0% 0% 0% 0%
DateUtils 100% 100% 100% 100% 100%
LocationUtil 28% 0% 13% 29% 14%
WeatherUtil 88% 77% 63% 100% 100%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants