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
This commit is contained in:
Lee Briggs 2020-04-27 18:22:50 -07:00
parent 7b17463031
commit 27f9f5c359
No known key found for this signature in database
GPG key ID: A4D09B96FDFEB505
3 changed files with 17 additions and 2 deletions

View file

@ -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

View file

@ -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")
}

View file

@ -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")