Skip to content

Commit

Permalink
build(gha): check for unused resources in prs
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-kozinski committed Oct 28, 2024
1 parent 913569e commit 816f92d
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 19 deletions.
27 changes: 27 additions & 0 deletions .github/actions/setup-environment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Set up environment
description: Common environment setup steps for this repository

inputs:
jdk:
description: Set up JDK
required: false
default: 'false'
gradle:
description: Set up Gradle
required: false
default: 'false'

runs:
using: composite
steps:
- name: Set up JDK
if: ${{ inputs.jdk == 'true' || inputs.gradle == 'true }}
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
with:
java-version-file: '.java-version'
distribution: 'temurin'
# Using 'temurin' speeds up the job, because this distribution is cached by the runner.
# See: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Hosted-Tool-Cache
- name: Set up Gradle
if: ${{ inputs.gradle == 'true' }}
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0
32 changes: 23 additions & 9 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
name: PR checks

on: pull_request
on:
pull_request:
merge_group:

jobs:
android-lint:
name: Android Lint
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up environment
uses: ./.github/actions/setup-environment
with:
gradle: true
- name: Decrypt secrets
env:
GPG_KEY: ${{ secrets.gpg_key }}
run: secrets/decrypt.sh
- name: Run Android Lint
run: scripts/run-android-lint.sh

licenses:
name: Validate licenses
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up JDK
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
- name: Set up environment
uses: ./.github/actions/setup-environment
with:
java-version-file: '.java-version'
distribution: 'temurin'
# Using 'temurin' speeds up the job, because this distribution is cached by the runner.
# See: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Hosted-Tool-Cache
- name: Set up Gradle
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0
gradle: true
- name: Decrypt secrets
env:
GPG_KEY: ${{ secrets.gpg_key }}
Expand Down
2 changes: 1 addition & 1 deletion Pocket/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ android {
}

lint {
abortOnError = false
checkReleaseBuilds = false
checkDependencies = true
}
buildFeatures {
viewBinding = true
Expand Down
6 changes: 0 additions & 6 deletions Pocket/lint.xml

This file was deleted.

6 changes: 4 additions & 2 deletions Pocket/src/main/res/values/donottranslate.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources
xmlns:tools="http://schemas.android.com/tools"
>
<string name="nm_icon" translatable="false">Pocket</string>
<string name="nm_app" translatable="false">Pocket</string>
<string name="alpha_settings" translatable="false">Alpha Settings</string>
Expand Down Expand Up @@ -31,5 +33,5 @@
<string name="gcm_defaultSenderId" translatable="false">638773995762</string>
<string name="google_app_id" translatable="false">1:638773995762:android:11ffc4bd95a81fa4</string>
<string name="google_storage_bucket" translatable="false">api-project-638773995762.appspot.com</string>
<string name="project_id" translatable="false">api-project-638773995762</string>
<string name="project_id" translatable="false" tools:ignore="UnusedResources">api-project-638773995762</string>
</resources>
5 changes: 4 additions & 1 deletion Pocket/src/main/res/values/leakcanary.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="UnusedResources"
>
<bool name="leak_canary_add_launcher_icon">false</bool>
</resources>
7 changes: 7 additions & 0 deletions lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<!-- Turn off all checks by default, so we can opt into just the ones we want. -->
<issue id="all" severity="ignore" />

<issue id="UnusedResources" severity="error" />
</lint>
6 changes: 6 additions & 0 deletions scripts/run-android-lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

# Fail if any commands fails.
set -e

./gradlew :Pocket:lint

0 comments on commit 816f92d

Please sign in to comment.