From 27f9f5c35975cc766fd4bd7bfb4737e7f98aa54f Mon Sep 17 00:00:00 2001 From: Lee Briggs Date: Mon, 27 Apr 2020 18:22:50 -0700 Subject: [PATCH] Don't try decrypt values on community PRs When a community member sends a pull request to the repo, travis can't decrypt some environment variables which include decrypting the GCP credentials. In addition to this, there are a few tests that run that require the `PULUMI_ACCESS_TOKEN` which can't be used. This PR does 2 things: - Adds a check to the GCP credentials decryption which checks the source of the PR (whether it's from within the local repo, or a fork) - Sets an environment variable: `COMMUNITY_PRS` which is used downstream during some tests. If the var exists, some tests are skipped This should enhance the experience for community pull requests significantly Fixes #4508 --- .travis.yml | 12 ++++++++++-- pkg/cmd/pulumi/new_test.go | 3 +++ pkg/npm/npm_test.go | 4 ++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 956eac5d8..e46d98d02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,16 @@ sudo: true git: depth: false before_install: -- openssl aes-256-cbc -K $encrypted_342342ee5e49_key -iv $encrypted_342342ee5e49_iv - -in gcp-credentials.json.enc -out gcp-credentials.json -d +- | + if [ "$TRAVIS_PULL_REQUEST_SLUG" != "pulumi/pulumi" ]; + then + echo "Not decrypting gcp credentials"; + export COMMUNITY_PR="true" + else + echo "Decrypting gcp credentials" + openssl aes-256-cbc -K $encrypted_342342ee5e49_key -iv $encrypted_342342ee5e49_iv -in gcp-credentials.json.enc -out gcp-credentials.json -d + export COMMUNITY_PR="false" + fi - git clone https://github.com/pulumi/scripts ${GOPATH}/src/github.com/pulumi/scripts - source ${GOPATH}/src/github.com/pulumi/scripts/ci/prepare-environment.sh - source ${PULUMI_SCRIPTS}/ci/keep-failed-tests.sh diff --git a/pkg/cmd/pulumi/new_test.go b/pkg/cmd/pulumi/new_test.go index d2de8fc5f..56d87333d 100644 --- a/pkg/cmd/pulumi/new_test.go +++ b/pkg/cmd/pulumi/new_test.go @@ -807,6 +807,9 @@ func removeStack(t *testing.T, name string) { } func skipIfShort(t *testing.T) { + if os.Getenv("COMMUNITY_PR") == "true" { + t.Skip("Skipped for community PRs") + } if testing.Short() { t.Skip("Skipped in short test run") } diff --git a/pkg/npm/npm_test.go b/pkg/npm/npm_test.go index 1f673bcc2..c5abfbaf6 100644 --- a/pkg/npm/npm_test.go +++ b/pkg/npm/npm_test.go @@ -33,6 +33,10 @@ func TestYarnInstall(t *testing.T) { } func testInstall(t *testing.T, expectedBin string) { + // Skip for community PRs + if os.Getenv("COMMUNITY_PR") == "true" { + t.Skip("Skipped for community PRs") + } // Skip during short test runs since this test involves downloading dependencies. if testing.Short() { t.Skip("Skipped in short test run")