Skip to content
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

Dissable plugins when needed #113

Merged
merged 12 commits into from
Feb 14, 2017
Merged
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ out/
pivy-importer/ivy-repo/
examples/example-project/activate
examples/example-project/pinned.txt
.DS_Store
4 changes: 3 additions & 1 deletion pygradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ task integTest(type: Test) {
classpath = sourceSets.integTest.runtimeClasspath
reports.html.destination = file("$buildDir${File.separatorChar}reports${File.separatorChar}integration-test")

environment['TEST_REPO'] = rootProject.buildDir.toString().replace('\\', '/') + '/ivy-repo'
environment['TEST_REPO'] = rootProject.buildDir.toURI().toURL().toString() + '/ivy-repo'
}

check.dependsOn integTest
Expand All @@ -68,6 +68,7 @@ gradlePlugin {
pluginSourceSet project.sourceSets.main
testSourceSets project.sourceSets.integTest

//noinspection GroovyAssignabilityCheck
plugins {
pythonPlugin {
id = 'com.linkedin.python'
Expand Down Expand Up @@ -107,6 +108,7 @@ pluginBundle {
description = 'Building Python with Gradle'
tags = ['python']

//noinspection GroovyAssignabilityCheck
plugins {
pythonPlugin {
id = 'com.linkedin.python'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/
package com.linkedin.gradle.python.plugin

import com.linkedin.gradle.python.plugin.testutils.DefaultProjectLayoutRule
import com.linkedin.gradle.python.plugin.testutils.ExecUtils
import com.linkedin.gradle.python.plugin.testutils.PyGradleTestBuilder
import com.linkedin.gradle.python.util.OperatingSystem
import com.linkedin.gradle.python.util.PexFileUtil
import org.gradle.testkit.runner.GradleRunner
Expand Down Expand Up @@ -51,7 +54,7 @@ class PexIntegrationTest extends Specification {
when:
def result = GradleRunner.create()
.withProjectDir(testProjectDir.root)
.withArguments('build', '--stacktrace')
.withArguments('build', '--stacktrace', '--info')
.withPluginClasspath()
.withDebug(true)
.build()
Expand Down Expand Up @@ -95,7 +98,7 @@ class PexIntegrationTest extends Specification {
|plugins {
| id 'com.linkedin.python-pex'
|}
|
|version = "1.0.0"
|python {
| pex {
| fatPex = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
*/
package com.linkedin.gradle.python.plugin

import com.linkedin.gradle.python.plugin.testutils.DefaultProjectLayoutRule
import com.linkedin.gradle.python.plugin.testutils.PyGradleTestBuilder
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import org.junit.Rule
import spock.lang.Specification

import java.nio.file.Paths


class PipIntegrationTest extends Specification {

@Rule
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* Copyright 2016 LinkedIn Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.linkedin.gradle.python.plugin

import com.linkedin.gradle.python.plugin.testutils.DefaultBlankProjectLayoutRule
import com.linkedin.gradle.python.plugin.testutils.PyGradleTestBuilder
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import org.junit.Rule
import spock.lang.Specification

/**
* This test class is designed to test scenarios where we are only using pygradle for documentation and
* other scenarios where it may be included in the project, but not active.
*/
class PyGradleWithSlimProjectsTest extends Specification {

@Rule
final DefaultBlankProjectLayoutRule testProjectDir = new DefaultBlankProjectLayoutRule()

def setup() {

}

def "verify works with blank project with pipconfig"() {
given:
testProjectDir.buildFile << """
| plugins {
| id 'com.linkedin.python'
| }
| python{
| pipConfig = ['global':['index-url': 'https://<login>:<password>@your.repo.com/custom/url', 'timeout': '60']]
| }
|
| ${PyGradleTestBuilder.createRepoClosure()}
""".stripMargin().stripIndent()

when:
def result = GradleRunner.create()
.withProjectDir(testProjectDir.root)
.withArguments('build', 'coverage', '-s')
.withPluginClasspath()
.withDebug(true)
.build()
println result.output

then: "make sure it passes initially first"
result.task(":${testProjectDir.PROJECT_NAME_DIR}:build").outcome == TaskOutcome.SUCCESS

// "Build will skip things that it should"
result.output.contains("Flake8 task skipped, no folders")
result.output.contains("BUILD SUCCESS")
result.output.contains("[SKIPPING]")

// "coverage should be skipped because lack of tests should disable it"
result.output.contains(":coverage SKIPPED")

// "install should be aborted because there is no setup.py"
result.output.contains("[ABORTED]")
result.output.contains("setup.py missing, skipping venv install for product")

when:
result = GradleRunner.create()
.withProjectDir(testProjectDir.root)
.withArguments('buildDocsHtml')
.withPluginClasspath()
.withDebug(true)
.build()
println result.output

then: "make sure it passes initially first"
result.task(":${testProjectDir.PROJECT_NAME_DIR}:buildDocsHtml").outcome == TaskOutcome.SUCCESS
result.output.contains("Sphinx docs dir doesn't exist. Aborting")
}

def "verify docs only nothing else"() {
given:
testProjectDir.buildFile << """
| plugins {
| id 'com.linkedin.python'
| }
| python{
| pipConfig = ['global':['index-url': 'https://<login>:<password>@your.repo.com/custom/url', 'timeout': '60']]
| }
| ${PyGradleTestBuilder.createRepoClosure()}
""".stripMargin().stripIndent()

testProjectDir.copyBuildDocsInfo()

when:
def result = GradleRunner.create()
.withProjectDir(testProjectDir.root)
.withArguments('buildDocsHtml')
.withPluginClasspath()
.withDebug(true)
.build()
println result.output

then: "make sure it passes initially first"
result.task(":${testProjectDir.PROJECT_NAME_DIR}:buildDocsHtml").outcome == TaskOutcome.SUCCESS
result.output.contains("Running Sphinx v1.4.1")
result.output.contains("building [html]: targets for 1 source files that are out of date")
result.output.contains("copying static files")
result.output.contains("dumping object inventory")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.linkedin.gradle.python.plugin

import com.linkedin.gradle.python.plugin.testutils.DefaultProjectLayoutRule
import com.linkedin.gradle.python.plugin.testutils.PyGradleTestBuilder
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import org.junit.Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/
package com.linkedin.gradle.python.plugin

import com.linkedin.gradle.python.plugin.testutils.DefaultProjectLayoutRule
import com.linkedin.gradle.python.plugin.testutils.ExecUtils
import com.linkedin.gradle.python.plugin.testutils.PyGradleTestBuilder
import com.linkedin.gradle.python.util.PexFileUtil
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Copyright 2016 LinkedIn Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.linkedin.gradle.python.plugin.testutils

import java.nio.file.Paths

class DefaultBlankProjectLayoutRule extends DefaultProjectLayoutRule {
@Override
void setupProject() {
// set up the default project name
def settingsGradle = newFile('settings.gradle')
settingsGradle << PyGradleTestBuilder.createSettingGradle()
settingsGradle << "\ninclude ':foo'\n"
}

void copyBuildDocsInfo() {
String docsFldr = "docs"

newFolder(PROJECT_NAME_DIR, docsFldr)
def spinxConfig = newFile(Paths.get(PROJECT_NAME_DIR, docsFldr, "conf.py").toString())
spinxConfig << sphinxConfigData()

def indexRs = newFile(Paths.get(PROJECT_NAME_DIR, docsFldr, "index.rst").toString())

indexRs << """
This Is Cool
============
""".stripIndent()
}

@SuppressWarnings("GrMethodMayBeStatic")
String sphinxConfigData() {
"""
| import os
|
| extensions = [
| 'sphinx.ext.autodoc',
| 'sphinx.ext.doctest',
| 'sphinx.ext.intersphinx',
| 'sphinx.ext.todo',
| 'sphinx.ext.coverage',
| 'sphinx.ext.mathjax',
| 'sphinx.ext.ifconfig',
| 'sphinx.ext.viewcode',
| ]
|
| templates_path = ['_templates']
| source_suffix = '.rst'
| master_doc = 'index'
| project =os.getenv('PYGRADLE_PROJECT_NAME')
| copyright = u'2017, PygradleTests'
| version = os.getenv('PYGRADLE_PROJECT_VERSION')
| release = version
| language = None
| exclude_patterns = ['_build']
| pygments_style = 'sphinx'
| keep_warnings = True
| todo_include_todos = True
| html_theme = 'bizstyle'
| html_theme_options = {}
| html_static_path = ['_static']
| htmlhelp_basename = '@htmlhelp_basename@'
| latex_elements = {
| }
| latex_documents = [
| (master_doc, '@[email protected]', u'@projectName@ Documentation',
| u'@author@', 'manual'),
| ]
| epub_title = project
| epub_copyright = copyright
| epub_exclude_files = ['search.html']""".stripMargin().stripIndent()
}
}
Loading