Skip to content

Commit

Permalink
Merge pull request GoogleCloudPlatform#340 from AdrienWalkowiak/master
Browse files Browse the repository at this point in the history
Adding support for gts in make test
  • Loading branch information
morgante authored Oct 21, 2019
2 parents 8dcb465 + 59c2729 commit c001a86
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cloudbuild/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,26 @@

FROM debian

# install core tools
RUN apt-get update && apt-get install -y build-essential python python-pip python3 python3-pip

# install yapf
RUN pip install yapf
RUN pip3 install yapf

# install golang (+gofmt)
RUN apt-get install -y golang

# Install nodejs (for gts)

RUN apt-get install -y wget nodejs

# installing npm 6.12.0
RUN wget https://github.com/npm/cli/archive/v6.12.0.tar.gz
RUN tar xf v6.12.0.tar.gz
WORKDIR cli-6.12.0
RUN make install

RUN npm install gts

ENTRYPOINT ["make"]
33 changes: 33 additions & 0 deletions helpers/check_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,38 @@ validate_go() {
fi
}

# validate_go - takes a folder path as input and validate folder
# using gts
# errors out if gts init or npm audit returns a non-0 status
validate_typescript(){
FOLDER=$1
if [[ -f "$FOLDER/tsconfig.json" ]]
then
echo "Validating $FOLDER - Checking typescript files"
cd $FOLDER
npx gts -y init > /dev/null

if [[ "$?" -eq 0 ]]
then
echo "Running npm audit..."
npm audit
cd -
if [[ "$?" -ne 0 ]]
then
echo "$FOLDER npm audit needs fixing - FAIL"
exit 1
else
echo "$FOLDER npm audit is clean - PASS"
fi
else
cd -
echo "gts init returned an error - FAIL"
exit 1
fi
fi

}

# temporary list of folders to exclude
EXCLUDE_FOLDERS=$(cat helpers/exclusion_list.txt)

Expand All @@ -113,6 +145,7 @@ do
then
validate_python $FOLDER
validate_go $FOLDER
validate_typescript $FOLDER
else
echo "$FOLDER in exclusion list - SKIP "
fi
Expand Down
14 changes: 14 additions & 0 deletions helpers/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,19 @@ do
echo "Formatting go files (if any)"
gofmt -w $FOLDER

if [[ -f "$FOLDER/tsconfig.json" ]]
then
echo "Formatting typescript (if possible)"
cd $FOLDER
npx gts init > /dev/null
npm audit fix
cd -

if [[ "$?" -ne 0 ]]
then
echo "npm audit fix returned an error - exiting"
exit 1
fi
fi
fi
done

0 comments on commit c001a86

Please sign in to comment.