-
Notifications
You must be signed in to change notification settings - Fork 1
🐞Fixes/general #7
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
base: master
Are you sure you want to change the base?
Conversation
Wayne whitehead patch 1
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
});
}
});
Co-authored-by: Copilot <[email protected]>
ViewModel Test Coverage:
Other Test Coverage:
|
ViewModel Test Coverage:
Other Test Coverage:
|
ViewModel Test Coverage:
Other Test Coverage:
|
There was a problem hiding this 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') {
ViewModel Test Coverage:
Other Test Coverage:
|
ViewModel Test Coverage:
Other Test Coverage:
|
ViewModel Test Coverage:
Other Test Coverage:
|
1 similar comment
ViewModel Test Coverage:
Other Test Coverage:
|
|
This is a summary generated by Copilot for PR #7. |
ViewModel Test Coverage:
Other Test Coverage:
|
ViewModel Test Coverage:
Other Test Coverage:
|
ViewModel Test Coverage:
Other Test Coverage:
|
ViewModel Test Coverage:
UseCase Test Coverage:
Other Test Coverage:
|
1 similar comment
ViewModel Test Coverage:
UseCase Test Coverage:
Other Test Coverage:
|
Description
copilot:all
Type of change
Checklist
Request a Review from Copilot
@github-copilotas a reviewer.