Skip to content

Commit

Permalink
Added support for Wercker
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen Hildebrandt committed Aug 30, 2016
1 parent 9908144 commit 91b71d9
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.eluder.coveralls.maven.plugin.service.ServiceSetup;
import org.eluder.coveralls.maven.plugin.service.Shippable;
import org.eluder.coveralls.maven.plugin.service.Travis;
import org.eluder.coveralls.maven.plugin.service.Wercker;
import org.eluder.coveralls.maven.plugin.source.SourceCallback;
import org.eluder.coveralls.maven.plugin.source.SourceLoader;
import org.eluder.coveralls.maven.plugin.source.UniqueSourceCallback;
Expand Down Expand Up @@ -307,6 +308,7 @@ protected List<ServiceSetup> getServices() {
services.add(new Jenkins(env));
services.add(new Bamboo(env));
services.add(new Appveyor(env));
services.add(new Wercker(env));
services.add(new General(env));
return services;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package org.eluder.coveralls.maven.plugin.service;

import java.util.Map;

/*
* #[license]
* coveralls-maven-plugin
* %%
* Copyright (C) 2013 - 2016 Tapio Rautonen
* %%
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* %[license]
*/

/**
* Service implementation for Wercker CI.
* <p>
* http://wercker.com/
*/
public class Wercker extends AbstractServiceSetup {

public static final String WERCKER_NAME = "wercker";
public static final String WERCKER_BUILD_URL = "WERCKER_RUN_URL";
public static final String WERCKER_BRANCH = "WERCKER_GIT_BRANCH";

public Wercker(final Map<String, String> env) {
super(env);
}

@Override
public boolean isSelected() {
return getProperty(WERCKER_BRANCH) != null;
}

@Override
public String getName() {
return WERCKER_NAME;
}

@Override
public String getJobId() {
final String buildUrl = getBuildUrl();
return buildUrl.substring(buildUrl.lastIndexOf("/") + 1);
}

@Override
public String getBuildUrl() {
return getProperty(WERCKER_BUILD_URL);
}

@Override
public String getBranch() {
return getProperty(WERCKER_BRANCH);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package org.eluder.coveralls.maven.plugin.service;

/*
* #[license]
* coveralls-maven-plugin
* %%
* Copyright (C) 2013 - 2016 Tapio Rautonen
* %%
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* %[license]
*/

import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class WerckerTest {

private Map<String, String> env() {
Map<String, String> env = new HashMap<String, String>();
env.put("WERCKER_RUN_URL", "https://app.wercker.com/build/123456789");
env.put("WERCKER_GIT_BRANCH", "master");
return env;
}

@Test
public void testIsSelectedForNothing() {
assertFalse(new Wercker(new HashMap<String, String>()).isSelected());
}

@Test
public void testIsSelectedForTravis() {
assertTrue(new Wercker(env()).isSelected());
}

@Test
public void testGetName() {
assertEquals("wercker", new Wercker(env()).getName());
}

@Test
public void testGetJobId() {
assertEquals("123456789", new Wercker(env()).getJobId());
}

@Test
public void testGetBranch() {
assertEquals("master", new Wercker(env()).getBranch());
}
}

0 comments on commit 91b71d9

Please sign in to comment.