Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ env:

jobs:

check_gcp_variables:
timeout-minutes: 5
name: "Check are GCP variables set"
runs-on: ubuntu-latest
outputs:
run-tests: ${{ steps.check_gcp_variables.outputs.are-gcp-variables-set }}
steps:
- uses: actions/checkout@v2
- name: "Check are GCP variables set"
run: "./scripts/ci/ci_check_are_gcp_variables_set.sh"
id: check_gcp_variables
env:
GCP_SA_EMAIL: ${{ secrets.GCP_SA_EMAIL }}
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}

build_source:
runs-on: ubuntu-latest
name: Build python source distribution
Expand Down Expand Up @@ -78,9 +93,11 @@ jobs:

prepare_gcs:
name: Prepare GCS
needs: build_source
needs:
- build_source
- check_gcp_variables
runs-on: ubuntu-latest
if: github.repository_owner == 'apache' && github.event_name != 'pull_request'
if: needs.check_gcp_variables.outputs.are-gcp-variables-set == 'true' && github.event_name != 'pull_request'
steps:
- name: Authenticate on GCP
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
Expand All @@ -92,9 +109,11 @@ jobs:

upload_source_to_gcs:
name: Upload python source distribution to GCS bucket
needs: prepare_gcs
needs:
- prepare_gcs
- check_gcp_variables
runs-on: ubuntu-latest
if: github.repository_owner == 'apache'
if: needs.check_gcp_variables.outputs.are-gcp-variables-set == 'true'
steps:
- name: Download compressed sources from artifacts
uses: actions/download-artifact@v2
Expand Down Expand Up @@ -156,10 +175,12 @@ jobs:
path: apache-beam-source/wheelhouse/

upload_wheels_to_gcs:
name: Upload python wheels to GCS bucket
needs: build_wheels
name: Upload wheels to GCS bucket
needs:
- build_wheels
- check_gcp_variables
runs-on: ubuntu-latest
if: github.repository_owner == 'apache' && github.event_name != 'pull_request'
if: needs.check_gcp_variables.outputs.are-gcp-variables-set == 'true' && github.event_name != 'pull_request'
strategy:
matrix:
os : [ubuntu-latest, macos-latest, windows-latest]
Expand Down Expand Up @@ -199,9 +220,11 @@ jobs:

list_files_on_gcs:
name: List files on Google Cloud Storage Bucket
needs: upload_wheels_to_gcs
needs:
- upload_wheels_to_gcs
- check_gcp_variables
runs-on: ubuntu-latest
if: github.repository_owner == 'apache' && github.event_name != 'pull_request'
if: needs.check_gcp_variables.outputs.are-gcp-variables-set == 'true' && github.event_name != 'pull_request'
steps:
- name: Authenticate on GCP
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
Expand Down
43 changes: 43 additions & 0 deletions scripts/ci/ci_check_are_gcp_variables_set.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

set -e

echo "This script checks of presence of variables required to perform operations on Google Cloud Platform. They should be stored as secrets."
echo "More detailed information about Google Cloud Platform Credentials can be found in CI.md"

function check_vars() {
ret=true
for var in "$@"; do
if [ -n "${!var}" ]; then
echo "$var is set"
else
echo >&2 "$var is not set"
ret=false
fi
done
$ret
}

if ! check_vars "GCP_SA_EMAIL" "GCP_SA_KEY"; then
echo "::set-output name=are-gcp-variables-set::false"
echo >&2 "!!! WARNING !!!"
echo >&2 "Not all GCP variables are set. Jobs which require them will be skipped."
else
echo "::set-output name=are-gcp-variables-set::true"
fi