Skip to content

Commit

Permalink
don't split plugin v dependency cache -- not needed
Browse files Browse the repository at this point in the history
The plugin cache is necessary and sufficient.
The dependency cache could not include plugins, so it was insufficient.
  • Loading branch information
artoonie committed Jan 26, 2024
1 parent 518c819 commit 76821a6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 59 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/generate-dependency-hashes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
# Generates a CSV of checksums for all maven dependencies in the global cache
# Including their actual SHA 256, and where to verify that online
set -e

echo "Filename, SHA-1 Checksum, SHA-256 Checksum, Maven Dependency URL, Direct URL to SHA-1, Direct URL to SHA-256"
cd ~/.gradle/caches/modules-2/files-2.1
for filename in $(find * -type f); do
# filename is of format, with dot-separated org:
# <org>/<dependency-name>/<version>/<sha-1>/<dependency-name>-<version>.<ext>
# friendly URL is of format, with dot-separated org:
# https://mvnrepository.com/artifact/<org>/<dependency-name>/<version>
# direct-to-SHA URL is of format, with slash-separated org:
# https://repo1.maven.org/maven2/<org>/<dependency-name>/<version>/<dependency-name>-<version>.<ext>.sha256
dotSeparatedOrg=$(echo $filename | cut -f1 -d/)
dependencyName=$(echo $filename | cut -f2 -d/)
version=$(echo $filename | cut -f3 -d/)
ext=$(echo $filename | rev | cut -f1 -d. | rev)
slashSeparatedOrg=$(echo $dotSeparatedOrg | tr "." "/")
friendlyurl="https://mvnrepository.com/artifact/$dotSeparatedOrg/$dependencyName/$version"
directUrl="https://repo1.maven.org/maven2/$slashSeparatedOrg/$dependencyName/$version/$dependencyName-$version.$ext"
directUrlToSha1="$directUrl.sha1"
directUrlToSha256="$directUrl.sha256"
sha1=$(shasum -a 1 $filename | cut -f1 -d" ")
sha256=$(shasum -a 256 $filename | cut -f1 -d" ")
echo "$filename,$sha1,$sha256,$friendlyurl,$directUrlToSha1,$directUrlToSha256"
done
29 changes: 9 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,33 +81,24 @@ jobs:
id: cachefn
shell: bash
run: |
echo "DEPENDENCY_FILEPATH=${{ steps.basefn.outputs.FILEPATH }}.dependencycache.zip" >> $GITHUB_OUTPUT
echo "PLUGIN_FILEPATH=${{ steps.basefn.outputs.FILEPATH }}.plugincache.zip" >> $GITHUB_OUTPUT
echo "FILEPATH=${{ steps.basefn.outputs.FILEPATH }}.cache.zip" >> $GITHUB_OUTPUT
- name: "Create dependency zip"
uses: ./.github/actions/zip
with:
command: ./gradlew copyLibs
input: ".dependencycache"
zipFilename: ${{steps.cachefn.outputs.DEPENDENCY_FILEPATH}}

- name: "Create plugins zip"
uses: ./.github/actions/zip
with:
type: "zip"
# Build, then remove all non-essential files
command: ./gradlew assemble && ./gradlew --stop
input: "~/.gradle/caches"
zipFilename: ${{steps.cachefn.outputs.PLUGIN_FILEPATH}}
zipFilename: ${{steps.cachefn.outputs.FILEPATH}}

- name: "Generate SHA512 for dependency cache"
uses: ./.github/actions/sha
with:
filepath: ${{steps.cachefn.outputs.DEPENDENCY_FILEPATH}}
- name: "Generate SHA1 and SHA256 for each maven dependency"
shell: bash
run: ./.github/workflows/generate-dependency-hashes.sh >> ~/.gradle/caches/checksums.csv

- name: "Generate SHA512 for plugins cache"
uses: ./.github/actions/sha
with:
filepath: ${{steps.cachefn.outputs.PLUGIN_FILEPATH}}
filepath: ${{steps.cachefn.outputs.FILEPATH}}

- name: "Prepare keychain"
if: matrix.os == 'macOS-latest'
Expand Down Expand Up @@ -164,10 +155,8 @@ jobs:
${{ github.workspace }}/${{ steps.zipfn.outputs.FILEPATH }}.sha512
${{ github.workspace }}/${{ steps.exefn.outputs.FILEPATH }}
${{ github.workspace }}/${{ steps.exefn.outputs.FILEPATH }}.sha512
${{ github.workspace }}/${{steps.cachefn.outputs.DEPENDENCY_FILEPATH}}
${{ github.workspace }}/${{steps.cachefn.outputs.DEPENDENCY_FILEPATH}}.sha512
${{ github.workspace }}/${{steps.cachefn.outputs.PLUGIN_FILEPATH}}
${{ github.workspace }}/${{steps.cachefn.outputs.PLUGIN_FILEPATH}}.sha512
${{ github.workspace }}/${{steps.cachefn.outputs.FILEPATH}}
${{ github.workspace }}/${{steps.cachefn.outputs.FILEPATH}}.sha512
retention-days: 1

- name: "Upload binaries to release"
Expand Down
47 changes: 8 additions & 39 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,15 @@ repositories {
mavenCentral()
}

// Caching dependencies for a fully-offline build
def DEPENDENCY_CACHE_DIR = "$projectDir/.dependencycache/"

dependencies {
if (gradle.startParameter.isOffline()) {
implementation fileTree(dir: DEPENDENCY_CACHE_DIR)
} else {
implementation 'commons-cli:commons-cli:1.5.0'
implementation 'org.apache.commons:commons-csv:1.10.0'
implementation 'org.apache.poi:poi-ooxml:5.2.3'
implementation 'com.fasterxml.jackson.core:jackson-core:2.15.2'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.15.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.15.2'
implementation "com.github.spotbugs:spotbugs:4.8.3"

}

implementation 'commons-cli:commons-cli:1.5.0'
implementation 'org.apache.commons:commons-csv:1.10.0'
implementation 'org.apache.poi:poi-ooxml:5.2.3'
implementation 'com.fasterxml.jackson.core:jackson-core:2.15.2'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.15.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.15.2'
implementation "com.github.spotbugs:spotbugs:4.8.3"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.3'
}
Expand Down Expand Up @@ -245,25 +236,3 @@ tasks.jlink.doLast {
into JLINK_DIR + "/sample_input"
}
}

// Tooling to copy dependencies for a fully-offline build
configurations {
cacheableImplementation.extendsFrom implementation
}

task deleteLibraryCache(type: Delete) {
delete DEPENDENCY_CACHE_DIR
}

task copyLibs(type: Copy, dependsOn: 'deleteLibraryCache') {
from configurations.cacheableImplementation
into DEPENDENCY_CACHE_DIR
}

// Necessary for offline builds to succeed
tasks.withType(Tar) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.withType(Zip) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

0 comments on commit 76821a6

Please sign in to comment.