Skip to content

Commit

Permalink
[DEPLOY]...
Browse files Browse the repository at this point in the history
  • Loading branch information
nad2000 committed Nov 15, 2019
1 parent 1d2d8f0 commit 0b5aa77
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 20 deletions.
7 changes: 7 additions & 0 deletions .jenkins/install.sh
Expand Up @@ -35,3 +35,10 @@ fi
# if [ ! -x "${WORKSPACE}/bin/zipit" ] ; then
# go build -o "${WORKSPACE}/bin/zipit" .jenkins/zipit.go
# fi

# recompile terraform 'null' provider:
if [ ! -x "${GOPATH}/bin/terraform-provider-null" ] ; then
git clone git@github.com:terraform-providers/terraform-provider-null "$GOPATH/src/github.com/terraform-providers/terraform-provider-null"
cd "$GOPATH/src/github.com/terraform-providers/terraform-provider-null"
go install
fi
6 changes: 4 additions & 2 deletions .travis.yml
Expand Up @@ -16,9 +16,11 @@ script:
- go vet ./handler
- go vet -tags=test ./handler
- golint ./handler
# - staticcheck ./handler
- staticcheck ./handler
- staticcheck -tags=heroku ./handler
- staticcheck -tags=container ./handler
# - staticcheck -tags=test ./handler
- gotest -v -tags test -cover -covermode=count -coverprofile coverage.out ./...
- gotest -v -tags test -cover -covermode=count -coverprofile coverage.out ./...

after_success:
- $GOPATH/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN
4 changes: 3 additions & 1 deletion Jenkinsfile
Expand Up @@ -47,7 +47,7 @@ pipeline {
sh 'go vet ./handler'
sh 'go vet -tags test ./handler'
sh 'golint ./handler'
// sh 'staticcheck ./handler'
sh 'staticcheck ./handler'
sh 'go build -o main ./handler/ && upx main && zip -0 main.zip main'
archiveArtifacts artifacts: 'main.zip', fingerprint: true
}
Expand All @@ -70,6 +70,8 @@ pipeline {
sh '.jenkins/terraform.sh'
dir("deployment") {
sh "terraform init || true"
// override the null provider
sh "cp $GOPATH/bin/terraform-provider-null .terraform/plugins/*/terraform-provider-null_*"
sh "terraform workspace new ${ENV} || terraform workspace select ${ENV}"
sh "terraform plan"
if (env.RECREATE == 'true' || COMMIT_MESSAGE.toUpperCase().contains("[RECREATE]")) {
Expand Down
4 changes: 0 additions & 4 deletions deployment/services.tf
Expand Up @@ -24,7 +24,3 @@ resource "null_resource" "orcidhub_webhook" {
}
}
}

output "UPSTREAM_URL" {
value = "${local.UPSTREAM_URL}"
}
1 change: 0 additions & 1 deletion handler/common.go
Expand Up @@ -37,7 +37,6 @@ var (
taskRecordCountMutex sync.Mutex
taskRetentionMin = defaultTaskRetentionMin
verbose bool
wg sync.WaitGroup
env string
// for testing/mocking
logFatal func(args ...interface{})
Expand Down
11 changes: 1 addition & 10 deletions handler/handler_internal_test.go
Expand Up @@ -34,13 +34,6 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}

func getenv(key, defaultValue string) string {
if value := os.Getenv(key); value != "" {
return value
}
return defaultValue
}

func isValidUUID(u string) bool {
_, err := uuid.Parse(u)
return err == nil
Expand Down Expand Up @@ -378,7 +371,6 @@ func testProcessRegistration(t *testing.T) {
assert.NotNil(t, err)

// malformatted messages:
wg.Wait()
logFatal = func(args ...interface{}) {}
malformatResponse = true

Expand All @@ -387,7 +379,6 @@ func testProcessRegistration(t *testing.T) {
assert.Empty(t, output)
assert.NotNil(t, err)

wg.Wait()
malformatResponse = false
// logFatal = log.Fatal
}
Expand Down Expand Up @@ -575,7 +566,7 @@ func testProcessEmpUpdate(t *testing.T) {
}).handle()
malformatResponse = false
logFatal = log.Fatal

assert.NotNil(t, err)
}

func testProcessMixed(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions handler/main.go
Expand Up @@ -35,8 +35,6 @@ func HandleRequest(ctx context.Context, e Event) (string, error) {

defer func() {
logger.Sync()
wg.Wait()
logger.Sync()
}()

return e.handle()
Expand Down
8 changes: 8 additions & 0 deletions handler/mock_test.go
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net/http"
"os"
"strings"
"testing"
"unicode"
Expand All @@ -24,6 +25,13 @@ func isValidID(uid string) bool {
return true
}

func getenv(key, defaultValue string) string {
if value := os.Getenv(key); value != "" {
return value
}
return defaultValue
}

func createMockHandler(t *testing.T) http.HandlerFunc {

return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit 0b5aa77

Please sign in to comment.