Skip to content

Commit

Permalink
Merge pull request #39 from stewartbryson/develop
Browse files Browse the repository at this point in the history
GCS support #31.
  • Loading branch information
stewartbryson authored Sep 16, 2022
2 parents 679d90c + cd32411 commit dd617e7
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 21 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/gradle-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ jobs:
env:
GRADLE_PROPERTIES: ${{secrets.GRADLE_PROPERTIES}}

- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v0'
with:
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}'

- name: Gradle build and test
uses: gradle/gradle-build-action@v2
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ jobs:
env:
GRADLE_PROPERTIES: ${{secrets.GRADLE_PROPERTIES}}

- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v0'
with:
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}'

- name: Gradle release
uses: gradle/gradle-build-action@v2
with:
Expand Down
3 changes: 2 additions & 1 deletion plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ testing {
shouldRunAfter(test)
systemProperties project.properties.findAll { it.key.startsWith "snowflake." }
systemProperty 'internalStage', findProperty('internalStage')
systemProperty 'externalStage', findProperty('externalStage')
systemProperty 's3Stage', findProperty('s3Stage')
systemProperty 'gcsStage', findProperty('gcsStage')
failFast true
testLogging.showStandardStreams true
}
Expand Down
3 changes: 2 additions & 1 deletion plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
internalStage=upload
externalStage=maven_snapshot
s3Stage=maven_snapshot
gcsStage=maven_snapshot_gcs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ class JavaTest extends Specification {
String account = System.getProperty("snowflake.account"),
user = System.getProperty("snowflake.user"),
password = System.getProperty("snowflake.password"),
publishUrl = System.getProperty("snowflake.publishUrl"),
s3PublishUrl = System.getProperty("snowflake.s3PublishUrl"),
gcsPublishUrl = System.getProperty("snowflake.gcsPublishUrl"),
role = System.getProperty("snowflake.role"),
database = System.getProperty("snowflake.database"),
schema = System.getProperty("snowflake.schema"),
internalStage = System.getProperty("internalStage"),
externalStage = System.getProperty("externalStage")
s3Stage = System.getProperty("s3Stage"),
gcsStage = System.getProperty("gcsStage")

def setupSpec() {
settingsFile = new File(projectDir, 'settings.gradle')
Expand Down Expand Up @@ -131,34 +133,34 @@ class JavaTest extends Specification {
!result.tasks.collect { it.outcome }.contains('FAILURE')
}

def "tasks with publishUrl"() {
def "shadowJar"() {
given:
taskName = 'tasks'
taskName = 'shadowJar'

when:
result = executeSingleTask(taskName, ["-Psnowflake.stage=$externalStage".toString(), "-Psnowflake.publishUrl=$publishUrl".toString(), '-Si'])
result = executeSingleTask(taskName, ['-Si'])

then:
!result.tasks.collect { it.outcome }.contains('FAILURE')
}

def "shadowJar"() {
def "snowflakePublish with S3 publishUrl option"() {
given:
taskName = 'shadowJar'
taskName = 'snowflakePublish'

when:
result = executeSingleTask(taskName, ['-Si'])
result = executeSingleTask(taskName, ["--stage", s3Stage, "-Psnowflake.publishUrl=$s3PublishUrl".toString(), '-Si'])

then:
!result.tasks.collect { it.outcome }.contains('FAILURE')
}

def "snowflakePublish with publishUrl option"() {
def "snowflakePublish with GCS publishUrl option"() {
given:
taskName = 'snowflakePublish'

when:
result = executeSingleTask(taskName, ["-Psnowflake.publishUrl=${publishUrl}".toString(), "-Psnowflake.stage=$externalStage".toString(), '-Si'])
result = executeSingleTask(taskName, ["--stage", gcsStage, "-Psnowflake.publishUrl=$gcsPublishUrl".toString(), '-Si'])

then:
!result.tasks.collect { it.outcome }.contains('FAILURE')
Expand All @@ -169,7 +171,7 @@ class JavaTest extends Specification {
taskName = 'snowflakePublish'

when:
result = executeSingleTask(taskName, ["-Psnowflake.stage=$internalStage".toString(), '-Si'])
result = executeSingleTask(taskName, ["--stage", internalStage, '-Si'])

then:
!result.tasks.collect { it.outcome }.contains('FAILURE')
Expand All @@ -180,7 +182,7 @@ class JavaTest extends Specification {
taskName = 'snowflakePublish'

when:
result = executeSingleTask(taskName, ['--jar', 'build/libs/unit-test-0.1.0-all.jar', '-Psnowflake.stage=upload', '-Si'])
result = executeSingleTask(taskName, ['--jar', 'build/libs/unit-test-0.1.0-all.jar', '--stage', 'upload', '-Si'])

then:
!result.tasks.collect { it.outcome }.contains('FAILURE')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SnowflakePlugin implements Plugin<Project> {
private static String PLUGIN = 'snowflake'

/**
* Apply the gradle-snowflake plugin to a Gradle project. Also applies the 'com.github.johnrengelman.shadow' and 'java-library' plugins. Supporting the 'scala' plugin instead is on the roadmap.
* Apply the snowflake plugin to a Gradle project. Also applies the 'com.github.johnrengelman.shadow' plugin. Supporting the 'scala' plugin as well is on the roadmap.
*/
void apply(Project project) {
project.extensions.create(PLUGIN, SnowflakeExtension)
Expand Down Expand Up @@ -51,12 +51,22 @@ class SnowflakePlugin implements Plugin<Project> {
}
}
// create repository
project.publishing.repositories {
maven {
name extension.stage
url extension.publishUrl
authentication {
awsIm(AwsImAuthentication)
// check and see if we are AWS or GCS
if (extension.publishUrl ==~ /(?i)(s3:\/\/)(.+)/) {
project.publishing.repositories {
maven {
name extension.stage
url extension.publishUrl
authentication {
awsIm(AwsImAuthentication)
}
}
}
} else {
project.publishing.repositories {
maven {
name extension.stage
url extension.publishUrl
}
}
}
Expand Down

0 comments on commit dd617e7

Please sign in to comment.