diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..c6c379fd --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,128 @@ +# This file was generated by the excavator check 'excavator/manage-circleci' as specified in .circleci/template.sh. +# To request a modification to the general template, file an issue on Excavator. +# To manually manage the CircleCI configuration for this project, remove the .circleci/template.sh file. + +working_dir: &working_dir + working_directory: /go/src/github.com/palantir/go-java-launcher + +darwin-linux-no-cgo: &darwin-linux-no-cgo + <<: *working_dir + docker: + - image: nmiyake/go:go-darwin-linux-no-cgo-1.10.3-t130 + environment: + CGO_ENABLED: 0 + +go-version: &go-version + run: go version + +godel-cache-restore: &godel-cache-restore + restore_cache: + keys: + - godel-cache-{{ checksum "godelw" }}-v1 + +godel-version: &godel-version + run: ./godelw version + +godel-cache-save: &godel-cache-save + save_cache: + key: godel-cache-{{ checksum "godelw" }}-v1 + paths: + - ~/.godel + +define-tests-dir: &define-tests-dir + run: echo 'export TESTS_DIR=/tmp/test-results' >> $BASH_ENV + +mkdir-tests-dir: &mkdir-tests-dir + run: mkdir -p "${TESTS_DIR}" + +godelw-verify: &godelw-verify + run: ./godelw verify --apply=false --junit-output="$TESTS_DIR/$CIRCLE_PROJECT_REPONAME-tests.xml" + +store-test-results: &store-test-results + type: test-results-store + path: /tmp/test-results + +store-artifacts: &store-artifacts + type: artifacts-store + path: /tmp/test-results + destination: test-results + +version: 2 +jobs: + verify: + <<: *darwin-linux-no-cgo + steps: + - checkout + - *go-version + - *godel-cache-restore + - *godel-version + - *godel-cache-save + - run: ./godelw verify --apply=false --skip-test + test: + <<: *darwin-linux-no-cgo + steps: + - checkout + - *go-version + - *godel-cache-restore + - *godel-version + - *godel-cache-save + - *define-tests-dir + - *mkdir-tests-dir + - run: ./godelw test --junit-output="$TESTS_DIR/$CIRCLE_PROJECT_REPONAME-tests.xml" + - *store-test-results + - *store-artifacts + dist: + <<: *darwin-linux-no-cgo + steps: + - checkout + - *go-version + - *godel-cache-restore + - *godel-version + - *godel-cache-save + - run: ./godelw dist + - save_cache: + key: dist-{{ .Environment.CIRCLE_WORKFLOW_ID }}-{{ .Environment.CIRCLE_SHA1 }}-v1 + paths: + - out + publish: + <<: *darwin-linux-no-cgo + steps: + - checkout + - *go-version + - *godel-cache-restore + - *godel-version + - restore_cache: + keys: + - dist-{{ .Environment.CIRCLE_WORKFLOW_ID }}-{{ .Environment.CIRCLE_SHA1 }}-v1 + # gödel cache only works if cached outputs are newer than source that generates it. CircleCI restore_cache restores + # the cache with the original modification dates, but the source's modification date in CI is the time of checkout. + # Manually touch all of the cache output to mark it as being generated after source was checked out. + - run: find out -exec touch {} \; + - run: ./godelw publish bintray --url https://api.bintray.com --subject palantir --repository releases --username "$BINTRAY_USERNAME" --password "$BINTRAY_PASSWORD" --publish --downloads-list + +### Workflows ### +requires_products: &requires_products + - verify + - test + - dist + +all-tags-filter: &all-tags-filter + filters: { tags: { only: /.*/ } } + +workflows: + version: 2 + build-publish: + jobs: + - verify: + <<: *all-tags-filter + - test: + <<: *all-tags-filter + - dist: + <<: *all-tags-filter + - publish: + requires: *requires_products + filters: + tags: + only: /^v?[0-9]+(\.[0-9]+)+(-rc[0-9]+)?(-alpha[0-9]+)?$/ + branches: + ignore: /.*/ diff --git a/circle.yml b/circle.yml deleted file mode 100644 index f5b228ff..00000000 --- a/circle.yml +++ /dev/null @@ -1,54 +0,0 @@ -machine: - environment: - GODIST: "go1.10.2.linux-amd64.tar.gz" - GOPATH: "$HOME/.go_workspace" - IMPORT_PATH: "github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME" - GO_PROJECT_SRC_PATH: "$GOPATH/src/$IMPORT_PATH" - java: - version: oraclejdk8 - post: - - mkdir -p download - - test -e "download/$GODIST" || wget -O "download/$GODIST" "https://storage.googleapis.com/golang/$GODIST" - # create custom Go distribution with packages built for darwin-amd64 if it is not present - - | - if [ ! -e "download/$GODIST-custom.tgz" ]; then - sudo rm -rf /usr/local/go && \ - sudo tar -C /usr/local -xzf "download/$GODIST" && \ - sudo env GOOS=linux GOARCH=amd64 /usr/local/go/bin/go install std && \ - sudo env GOOS=darwin GOARCH=amd64 /usr/local/go/bin/go install std && \ - tar -C /usr/local -czf "download/$GODIST-custom.tgz" go - fi - - sudo rm -rf /usr/local/go - - sudo tar -C /usr/local -xzf "download/$GODIST-custom.tgz" - -checkout: - post: - # ensure all tags are fetched and up-to-date - - git tag -l | xargs git tag -d && git fetch -t - -dependencies: - override: - - mkdir -p "$GOPATH/src/$IMPORT_PATH" - - rsync -az --delete ./ "$GOPATH/src/$IMPORT_PATH/" - - cd "$GO_PROJECT_SRC_PATH" && ./godelw version - cache_directories: - - ~/.godel - - ~/download - -test: - pre: - - go version - override: - - cd "$GO_PROJECT_SRC_PATH" && go install $(./godelw packages) - - mkdir -p "$CIRCLE_TEST_REPORTS/$CIRCLE_PROJECT_REPONAME" - - cd "$GO_PROJECT_SRC_PATH" && ./godelw verify --apply=false --tags none --junit-output="$CIRCLE_TEST_REPORTS/$CIRCLE_PROJECT_REPONAME/$CIRCLE_PROJECT_REPONAME-tests.xml" - - mkdir -p "$CIRCLE_TEST_REPORTS/$CIRCLE_PROJECT_REPONAME-integration" - - cd "$GO_PROJECT_SRC_PATH" && ./godelw test --tags=integration --junit-output="$CIRCLE_TEST_REPORTS/$CIRCLE_PROJECT_REPONAME/$CIRCLE_PROJECT_REPONAME-integration.xml" - - cd "$GO_PROJECT_SRC_PATH" && ./godelw dist - -deployment: - release: - tag: /[0-9]+(\.[0-9]+)+(-rc[0-9]+)?/ - owner: palantir - commands: - - cd "$GO_PROJECT_SRC_PATH" && ./godelw publish bintray --url https://api.bintray.com --subject palantir --repository releases --user "$BINTRAY_USERNAME" --password "$BINTRAY_PASSWORD" --publish --downloads-list diff --git a/integration_test/go_java_launcher_integration_test.go b/integration_test/go_java_launcher_integration_test.go index 27468c4a..4d61427d 100644 --- a/integration_test/go_java_launcher_integration_test.go +++ b/integration_test/go_java_launcher_integration_test.go @@ -15,8 +15,10 @@ package integration_test import ( + "log" "os" "os/exec" + "path/filepath" "testing" "github.com/palantir/godel/pkg/products/v2/products" @@ -73,3 +75,15 @@ func runMainWithArgs(t *testing.T, staticConfigFile, customConfigFile string) (s outputBytes, err := cmd.CombinedOutput() return string(outputBytes), err } + +func TestMain(m *testing.M) { + jdkDir := "jdk" + javaHome, err := filepath.Abs(jdkDir) + if err != nil { + log.Fatalf("Failed to calculate absolute path of '%s': %v\n", jdkDir, err) + } + if err := os.Setenv("JAVA_HOME", javaHome); err != nil { + log.Fatalln("Failed to set a mock JAVA_HOME", err) + } + os.Exit(m.Run()) +} diff --git a/integration_test/jdk/bin/java b/integration_test/jdk/bin/java new file mode 100755 index 00000000..14bd5a48 --- /dev/null +++ b/integration_test/jdk/bin/java @@ -0,0 +1,6 @@ +#!/bin/sh + +echo +echo "main method" + +sleep 5 \ No newline at end of file diff --git a/integration_test/testdata/Main.class b/integration_test/testdata/Main.class deleted file mode 100644 index c24c5aad..00000000 Binary files a/integration_test/testdata/Main.class and /dev/null differ diff --git a/integration_test/testdata/Main.java b/integration_test/testdata/Main.java deleted file mode 100644 index 4bf8acee..00000000 --- a/integration_test/testdata/Main.java +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2015 Palantir Technologies, Inc. All rights reserved. - * - * 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. - */ - -public class Main { - public static void main(String args[]) throws InterruptedException { - System.out.println("main method"); - Thread.sleep(5000); - } -}