Skip to content

Commit

Permalink
Install and use pre-commit
Browse files Browse the repository at this point in the history
* format JSON and YAML (and remove from Spotless)
* Verify GitHub Workflows and Renovate configs
* Re-enable Java formatting in Spotless
* Forbid tabs and crlf
* GitHub Quality check Action
  • Loading branch information
eirnym committed Feb 6, 2024
1 parent 8c5bbe8 commit f31ee29
Show file tree
Hide file tree
Showing 34 changed files with 643 additions and 523 deletions.
32 changes: 23 additions & 9 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [ "config:base" ],
"commitMessageExtra": "from {{{currentValue}}} to {{{newValue}}}{{#if isMajor}} (major v{{{newMajor}}}){{else}}{{/if}}",
"extends": [
"config:base"
],
"packageRules": [
{
"description": "Disable updating AGP compatibility dependencies. Allow changes in minor and patches.",
"enabled": false,
"matchFiles": [
"gradle/agp.dependencies.toml",
"demo/android-agp7/**"
],
"matchPackageNames": [
"com.android.tools.build:gradle"
],
"matchUpdateTypes": [
"major"
]
}
],
"pre-commit": {
"enabled": true
},
"separateMajorMinor": true,
"separateMultipleMajor": true,
"separateMinorPatch": true,
"packageRules": [ {
"description": "Disable updating AGP compatibility dependencies. Allow changes in minor and patches.",
"matchPackageNames": [ "com.android.tools.build:gradle" ],
"matchFiles": [ "gradle/agp.dependencies.toml", "demo/android-agp7/**" ],
"matchUpdateTypes": [ "major" ],
"enabled": false
} ]
"separateMultipleMajor": true
}
1 change: 1 addition & 0 deletions .github/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pre-commit==3.6.0
51 changes: 26 additions & 25 deletions .github/workflows/demo-android-agp7-ci-unreleased.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
---
name: Android AGP 7 Demo CI (unreleased plugin version)

on:
push:
branches:
- main
- main
tags-ignore:
- '*'
- '*'
paths:
- build.gradle.kts
- 'internal/**'
- 'plugin-gradle/**'
- 'demo/android-agp7/**'
- .github/workflows/demo-android-agp7-ci-unreleased.yml
- build.gradle.kts
- internal/**
- plugin-gradle/**
- demo/android-agp7/**
- .github/workflows/demo-android-agp7-ci-unreleased.yml
pull_request:
types: [ assigned, opened, synchronize, reopened ]
types: [assigned, opened, synchronize, reopened]
paths:
- 'plugin-gradle/**'
- 'demo/android-agp7/**'
- .github/workflows/demo-android-agp7-ci-unreleased.yml
- plugin-gradle/**
- demo/android-agp7/**
- .github/workflows/demo-android-agp7-ci-unreleased.yml

concurrency:
# Documentation suggests ${{ github.head_ref }}, but that's only available on pull_request/pull_request_target triggers, so using ${{ github.ref }}.
Expand All @@ -38,18 +39,18 @@ jobs:
strategy:
fail-fast: false
matrix:
java: [ 17 ]
distribution: [ "zulu" ]
java: [17]
distribution: [zulu]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.distribution }} ${{ matrix.java }}
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.java }}
cache: gradle
- name: Install Android SDK
uses: malinskiy/action-android/install-sdk@release/0.1.4
- name: Build project Android AGP 7 Demo (unreleased plugin version)
run: ./gradlew assembleDebug -S --scan --warning-mode all -I ../../gradle/init.gradle.kts -Porg.jsonschema2dataclass.internal.spotless.disable=true -Porg.jsonschema2dataclass.internal.local=true
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.distribution }} ${{ matrix.java }}
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.java }}
cache: gradle
- name: Install Android SDK
uses: malinskiy/action-android/install-sdk@release/0.1.4
- name: Build project Android AGP 7 Demo (unreleased plugin version)
run: ./gradlew assembleDebug -S --scan --warning-mode all -I ../../gradle/init.gradle.kts -Porg.jsonschema2dataclass.internal.spotless.disable=true -Porg.jsonschema2dataclass.internal.local=true
43 changes: 22 additions & 21 deletions .github/workflows/demo-android-agp7-ci.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
---
name: Android AGP 7 Demo CI

on:
push:
branches:
- main
- main
tags-ignore:
- '*'
- '*'
paths:
- 'demo/android-agp7/**'
- .github/workflows/demo-android-agp7-ci.yml
- demo/android-agp7/**
- .github/workflows/demo-android-agp7-ci.yml
pull_request:
types: [ assigned, opened, synchronize, reopened ]
types: [assigned, opened, synchronize, reopened]
paths:
- 'demo/android-agp7/**'
- .github/workflows/demo-android-agp7-ci.yml
- demo/android-agp7/**
- .github/workflows/demo-android-agp7-ci.yml

concurrency:
# Documentation suggests ${{ github.head_ref }}, but that's only available on pull_request/pull_request_target triggers, so using ${{ github.ref }}.
Expand All @@ -35,18 +36,18 @@ jobs:
fail-fast: false
max-parallel: 2
matrix:
java: [ 11, 17, 18 ]
distribution: [ "zulu", "temurin" ]
java: [11, 17, 18]
distribution: [zulu, temurin]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.distribution }} ${{ matrix.java }}
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.java }}
cache: gradle
- name: Install Android SDK
uses: malinskiy/action-android/install-sdk@release/0.1.4
- name: Build project Android AGP 7 Demo
run: ./gradlew assembleDebug -S --scan --warning-mode all
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.distribution }} ${{ matrix.java }}
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.java }}
cache: gradle
- name: Install Android SDK
uses: malinskiy/action-android/install-sdk@release/0.1.4
- name: Build project Android AGP 7 Demo
run: ./gradlew assembleDebug -S --scan --warning-mode all
43 changes: 22 additions & 21 deletions .github/workflows/demo-java-ci-unreleased.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
---
name: Java Demo CI (unreleased plugin version)

on:
push:
branches:
- main
- main
tags-ignore:
- '*'
- '*'
paths:
- build.gradle.kts
- 'internal/**'
- 'plugin-gradle/**'
- 'demo/java/**'
- .github/workflows/demo-java-ci-unreleased.yml
- build.gradle.kts
- internal/**
- plugin-gradle/**
- demo/java/**
- .github/workflows/demo-java-ci-unreleased.yml
pull_request:
types: [assigned, opened, synchronize, reopened]
paths:
- 'plugin-gradle/**'
- 'demo/java/**'
- .github/workflows/demo-java-ci-unreleased.yml
- plugin-gradle/**
- demo/java/**
- .github/workflows/demo-java-ci-unreleased.yml

concurrency:
# Documentation suggests ${{ github.head_ref }}, but that's only available on pull_request/pull_request_target triggers, so using ${{ github.ref }}.
Expand All @@ -40,15 +41,15 @@ jobs:
max-parallel: 1
matrix:
java_version: [8, 17]
distribution: ["zulu"]
distribution: [zulu]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install JDK ${{ matrix.distribution }} ${{ matrix.java_version }}
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.java_version }}
cache: gradle
- name: Build project Java Demo (unreleased plugin version)
run: ./gradlew build -S --scan --warning-mode all -I ../../gradle/init.gradle.kts -Porg.jsonschema2dataclass.internal.spotless.disable=true -Porg.jsonschema2dataclass.local=true
- name: Checkout
uses: actions/checkout@v4
- name: Install JDK ${{ matrix.distribution }} ${{ matrix.java_version }}
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.java_version }}
cache: gradle
- name: Build project Java Demo (unreleased plugin version)
run: ./gradlew build -S --scan --warning-mode all -I ../../gradle/init.gradle.kts -Porg.jsonschema2dataclass.internal.spotless.disable=true -Porg.jsonschema2dataclass.local=true
35 changes: 18 additions & 17 deletions .github/workflows/demo-java-ci.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
---
name: Java Demo CI

on:
push:
branches:
- main
- main
tags-ignore:
- '*'
- '*'
paths:
- 'demo/java/**'
- .github/workflows/demo-java-ci.yml
- demo/java/**
- .github/workflows/demo-java-ci.yml
pull_request:
types: [assigned, opened, synchronize, reopened]
paths:
- 'demo/java/**'
- .github/workflows/demo-java-ci.yml
- demo/java/**
- .github/workflows/demo-java-ci.yml

concurrency:
# Documentation suggests ${{ github.head_ref }}, but that's only available on pull_request/pull_request_target triggers, so using ${{ github.ref }}.
Expand All @@ -36,15 +37,15 @@ jobs:
fail-fast: false
matrix:
java_version: [8, 11, 17, 19]
distribution: ["zulu", "temurin"]
distribution: [zulu, temurin]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install JDK ${{ matrix.distribution }} ${{ matrix.java_version }}
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.java_version }}
cache: gradle
- name: Build project Java Demo
run: ./gradlew build -S --scan --warning-mode all
- name: Checkout
uses: actions/checkout@v4
- name: Install JDK ${{ matrix.distribution }} ${{ matrix.java_version }}
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.java_version }}
cache: gradle
- name: Build project Java Demo
run: ./gradlew build -S --scan --warning-mode all
56 changes: 29 additions & 27 deletions .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,62 @@
name: "Validate Gradle Wrapper"
---
name: Validate Gradle Wrapper

on:
push:
branches:
- main
- main
paths:
- 'gradle/wrapper/**'
- 'demo/android-agp7/gradle/wrapper/**'
- 'demo/java/gradle/wrapper/**'
- .github/workflows/gradle-wrapper-validation.yml
- gradle/wrapper/**
- demo/android-agp7/gradle/wrapper/**
- demo/java/gradle/wrapper/**
- .github/workflows/gradle-wrapper-validation.yml
pull_request:
branches:
- main
- main
paths:
- 'gradle/wrapper/**'
- 'demo/android-agp7/gradle/**'
- 'demo/java/gradle/**'
- .github/workflows/gradle-wrapper-validation.yml
- gradle/wrapper/**
- demo/android-agp7/gradle/**
- demo/java/gradle/**
- .github/workflows/gradle-wrapper-validation.yml

concurrency:
# Documentation suggests ${{ github.head_ref }}, but that's only available on pull_request/pull_request_target triggers, so using ${{ github.ref }}.
# On master, we want all builds to complete even if merging happens faster to make it easier to discover at which point something broke.
group: ${{ github.ref == 'refs/heads/main' && format('gradle-wrapper-validation-main-{0}', github.sha) || format('gradle-wrapper-validation-{0}', github.ref) }}
group: ${{ github.ref == 'refs/heads/main' && format('gradle-wrapper-validation-main-{0}', github.sha) || format('gradle-wrapper-validation-{0}', github.ref)
}}
cancel-in-progress: true

env:
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dkotlin.incremental=false -Dkotlin.compiler.execution.strategy=in-process

jobs:
validationPlugin:
name: "Wrapper validation: Plugin"
name: 'Wrapper validation: Plugin'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gradle/wrapper-validation-action@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gradle/wrapper-validation-action@v2
validationJavaKotlinSample:
name: "Wrapper validation: Java Demo"
name: 'Wrapper validation: Java Demo'
runs-on: ubuntu-latest
defaults:
run:
working-directory: demo/java
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gradle/wrapper-validation-action@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gradle/wrapper-validation-action@v2
validationAndroidAgp7Sample:
name: "Wrapper validation: Android AGP 7 Demo"
name: 'Wrapper validation: Android AGP 7 Demo'
runs-on: ubuntu-latest
defaults:
run:
working-directory: demo/android-agp7
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gradle/wrapper-validation-action@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gradle/wrapper-validation-action@v2
Loading

0 comments on commit f31ee29

Please sign in to comment.