Skip to content

Commit

Permalink
Merge branch 'main' into data-science-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
debakkerb committed Nov 16, 2021
2 parents e47dd18 + 7748b88 commit 8d8574c
Show file tree
Hide file tree
Showing 8 changed files with 307 additions and 129 deletions.
120 changes: 0 additions & 120 deletions .github/workflows/build-tf-plan.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/check-license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: 'BUILD - Check Lisence Boilerplate'
name: 'CHECK - License Boilerplate'

on:
schedule:
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/check-tf-plan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# .github/workflows/check-tf-plan.yml

# Copyright 2021 Google LLC
#
# 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
#
# https://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.

name: 'CHECK - Terraform Plan'

on:
pull_request:
types: [opened, reopened]
paths:
- 'modules/**/*.tf'
workflow_dispatch:
inputs:
PRNumber:
description: 'PR #'
required: true

jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TF_IN_AUTOMATION: true
steps:
- name: Checkout
uses: actions/checkout@v2

- name: setup python
uses: actions/setup-python@v2
with:
python-version: 3.8 #install the python needed

- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
terraform_version: 1.0.11

- name: Set environment
run: |
echo "GOOGLE_APPLICATION_CREDENTIALS=${GITHUB_WORKSPACE}/.github/workflows/fake-key.json" >> $GITHUB_ENV
echo $GOOGLE_APPLICATION_CREDENTIALS # This will print the file path in GOOGLE_APPLICATION_CREDENTIALS variable
# cat $GOOGLE_APPLICATION_CREDENTIALS # This will print the file content
- name: install python packages
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
working-directory: tools

- name: execute py script (auto) # run the tf-plan.py
id: tf-plan-auto
if: github.event_name == 'pull_request'
run: |
python tf-plan.py ${{ github.event.number }}
working-directory: tools

- name: execute py script (manual) # run the tf-plan.py
id: tf-plan-manual
if: github.event_name == 'workflow_dispatch'
run: |
if [[ "${{ github.event.inputs.PRNumber }}" =~ ^[0-9]+$ ]]
then
python tf-plan.py ${{ github.event.inputs.PRNumber }}
else
echo "INVALID PR Number ENTERED..."
exit 1
fi
working-directory: tools
4 changes: 2 additions & 2 deletions .github/workflows/notifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name: BUILD - RAD Lab Notifications
on:
issues:
types: [opened, reopened]
types: [opened]
pull_request:
branches:
- main
Expand Down Expand Up @@ -152,4 +152,4 @@ jobs:
]
}
]
}'
}'
2 changes: 1 addition & 1 deletion modules/data_science/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ NOTE: `variables.tf` would list some defaults. If you would like to override or

## Access RAD Lab Data Science Notebooks

Follow the instructions under [gcp-ai-nootbook-tools Readme](./scripts/gcp-ai-notebook-tools/README.md).
Follow the instructions under [gcp-ai-nootbook-tools Readme](../../scripts/gcp-ai-notebook-tools).
17 changes: 13 additions & 4 deletions tools/checklicense_openpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import os
import sys
import glob
import json
import shutil
import requests
Expand Down Expand Up @@ -65,6 +66,11 @@ def licensecheck(GITHUB_REPOSITORY, TOKEN, pr, commentcheck):
# Download all prf files locally into ./tools/temp/ folder in the same directory structure
downloadprfiles(prfiles)

# print(os.getcwd()+'/temp')
# print(glob.glob(os.getcwd()+'/temp/*'))
# print(glob.glob(os.getcwd()+'/temp/*/*'))
# print(glob.glob(os.getcwd()+'/temp/*/*/*'))

# Run lisence check on the downloaded files in temp directory
pr_no_license_files = boilerplate(os.getcwd()+'/temp')

Expand Down Expand Up @@ -105,9 +111,12 @@ def prcommentcheck(GITHUB_REPOSITORY, pr):
def boilerplate(local_temp):
pr_no_license_files = []
allfiles = check_boilerplate.main(local_temp)
for x in range(len(allfiles)):
pr_no_license_files.append(allfiles[x].replace(local_temp+'/', ""))
# print(pr_no_license_files)
try:
for x in range(len(allfiles)):
pr_no_license_files.append(allfiles[x].replace(local_temp+'/', ""))
# print(pr_no_license_files)
except:
print("All files have the Apache 2.0 Lisence")
return pr_no_license_files

def pr_files(GITHUB_REPOSITORY,pr):
Expand Down Expand Up @@ -163,4 +172,4 @@ def commentpr(GITHUB_REPOSITORY, pr, comment, TOKEN):
if len(sys.argv) == 2:
main(sys.argv[1])
else:
main('All')
main('All')
3 changes: 2 additions & 1 deletion tools/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
click
python-dateutil
pytz
requests
requests
python-terraform>=0.10.1
Loading

0 comments on commit 8d8574c

Please sign in to comment.