-
Notifications
You must be signed in to change notification settings - Fork 903
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1st pass at re-enabling automated linting/tests, + autopep8 some file…
…s to reduce linter errors
- Loading branch information
Showing
47 changed files
with
384 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#! /bin/bash | ||
|
||
# Copyright 2020 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 | ||
# | ||
# 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. | ||
|
||
# Utility for generating credentials used by tests. | ||
|
||
# Union of scopes used by samples | ||
SCOPES=( | ||
"https://www.googleapis.com/auth/drive" | ||
"https://www.googleapis.com/auth/drive.activity" | ||
"https://mail.google.com/" | ||
"https://www.googleapis.com/auth/classroom.courses" | ||
"https://www.googleapis.com/auth/classroom.announcements" | ||
"https://www.googleapis.com/auth/classroom.rosters" | ||
"https://www.googleapis.com/auth/classroom.topics" | ||
"https://www.googleapis.com/auth/classroom.guardianlinks.students" | ||
"https://www.googleapis.com/auth/classroom.coursework.students" | ||
) | ||
|
||
if [ -z "$CLIENT_ID_FILE" ]; then | ||
echo "CLIENT_ID_FILE environment not set. Please set and run again." | ||
exit 1 | ||
fi | ||
|
||
if [ ! -f "$CLIENT_ID_FILE" ]; then | ||
echo "$CLIENT_ID_FILE not found." | ||
exit 1 | ||
fi | ||
|
||
printf -v EXPANDED_SCOPES '%s,' "${SCOPES[@]}" | ||
gcloud auth application-default login \ | ||
--client-id-file=client_secret.json \ | ||
--scopes="${EXPANDED_SCOPES}" | ||
|
||
cat "${HOME}/.config/gcloud/application_default_credentials.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#! /bin/bash | ||
# Copyright 2020 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 | ||
# | ||
# 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 | ||
|
||
export LC_ALL=C.UTF-8 | ||
export LANG=C.UTF-8 | ||
|
||
find . -iname "*.py" | xargs pylint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#! /bin/bash | ||
# Copyright 2020 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 | ||
# | ||
# 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. | ||
|
||
export LC_ALL=C.UTF-8 | ||
export LANG=C.UTF-8 | ||
export PIPENV_PYTHON="${PYENV_ROOT}/shims/python" | ||
export GOOGLE_APPLICATION_CREDENTIALS="${HOME}/secrets/default_credentials.json" | ||
|
||
if [ -f "requirements.txt" ]; then | ||
pipenv install -r "requirements.txt" | ||
fi | ||
|
||
TEST_DIRS=`find . -name '*_test.py' -exec dirname '{}' \;| sort -u` | ||
|
||
exit_code=0 | ||
|
||
for DIR in ${TEST_DIRS[@]}; do | ||
pushd "${DIR}" | ||
echo $DIR | ||
if [ -f "requirements.txt" ]; then | ||
# If requirements.txt present, create a new isolated environment | ||
touch Pipfile | ||
pipenv install -r "requirements.txt" | ||
fi | ||
pipenv run python -m unittest discover | ||
status=$? | ||
if [ $status -ne 0 ]; then | ||
exit_code=$status | ||
fi | ||
popd | ||
done | ||
|
||
if [ $exit_code -ne 0 ]; then | ||
echo "Tests failed." | ||
fi | ||
|
||
exit $exit_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.6 | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pylint | ||
- name: Lint with pylint | ||
run: ./.github/scripts/lint.sh | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# TODO - expand matrix once stable | ||
python-version: [3.6] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pipenv | ||
- name: Write test credentials | ||
run: | | ||
mkdir $HOME/secrets | ||
echo "$DEFAULT_CREDENTIALS" > $HOME/secrets/default_credentials.json | ||
echo "$CLIENT_ID_FILE" > $HOME/secrets/client_id.json | ||
env: | ||
DEFAULT_CREDENTIALS: ${{secrets.SNIPPETS_DEFAULT_CREDENTIALS}} | ||
CLIENT_ID_FILE: ${{secrets.SNIPPETS_CLIENT_ID_FILE}} | ||
- name: Run tests | ||
run: ./.github/scripts/test.sh |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
} | ||
'''.strip() | ||
|
||
|
||
def main(): | ||
"""Calls the Apps Script API. | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.