This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stage('Violations') { | |
steps { | |
// Retrieve golint tool | |
sh 'go get -u golang.org/x/lint/golint' | |
// Run golint | |
sh 'cd $GOPATH/src/github/jbleduigou/budgetcategorizer && golint ./...' | |
// Run go vet | |
sh 'cd $GOPATH/src/github/jbleduigou/budgetcategorizer && go vet ./... || true' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stage('Test') { | |
steps { | |
// Retrieve tool for converting output to junit format | |
sh 'go get -u github.com/jstemmer/go-junit-report' | |
// Run unit tests and redirect output to go-junit-report | |
sh 'cd $GOPATH/src/github/jbleduigou/budgetcategorizer && go test -v ./... 2>&1 | go-junit-report > report.xml' | |
} | |
post { | |
always { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/groovy | |
pipeline { | |
agent { | |
docker { image 'golang:1.13' } | |
} | |
environment { | |
XDG_CACHE_HOME='/tmp/.cache' | |
GOOS='linux' | |
GOARCH='amd64' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/groovy | |
pipeline { | |
agent any | |
tools { | |
// Install the Maven version configured as "M3" and add it to the path. | |
maven "M3" | |
} | |
stages { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/groovy | |
pipeline { | |
agent any | |
tools { | |
// Install the Maven version configured as "M3" and add it to the path. | |
maven "M3" | |
} | |
stages { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
yum update -y | |
yum install java-1.8.0-devel -y | |
yum install git -y | |
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo | |
rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key | |
yum install jenkins -y | |
service jenkins start | |
chkconfig --add jenkins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Throwable exception = assertThrows(IllegalArgumentException.class, () -> $SELECTION$); | |
assertThat( | |
exception.getMessage(), | |
is("Okay, Houston, we've had a problem here")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Throwable exception = assertThrows(BusinessLogicException.class, | |
() -> userService.getUserDetails(1337)); | |
assertThat(exception.getMessage(), is("Could not get user details!")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Set<List<Item>> generateAllSubLists(List<Item> items) { | |
Set<List<Item>> subLists = new HashSet<>(); | |
int allBitMasks = (int) Math.pow(2, Math.min(items.size(), 12)); | |
for (long i = 1; i < allBitMasks; i++) { | |
List<Item> sublist = new ArrayList<>(); | |
for (int j = 0; j < items.size(); j++) { | |
if ((i & (1 << j)) > 0) { | |
sublist.add(items.get(j)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generate all possible sub-lists (PowerSet algorithm) | |
Set<List<Item>> subLists = generateAllSubLists(items); | |
// Find best solution for each sub-set | |
SortedSet<Solution> solutions = new TreeSet<>(); | |
for (List<Item> sublist : subLists) { | |
Solution solution = findBestSolution(maxWeight, sublist); | |
solutions.add(solution); | |
} | |
// No need to sort solutions, TreeSet implements SortedSet | |
Solution best = solutions.first(); |
NewerOlder