Skip to content

Commit

Permalink
added a script to check for warnings
Browse files Browse the repository at this point in the history
Signed-off-by: sarfaraz siddiqui <sarfarazsiddiqui199@gmail.com>
  • Loading branch information
sarfarazsiddiquii committed Apr 21, 2024
1 parent 3f55494 commit e614d0c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/standard_library_tests_and_examples.yml
Expand Up @@ -99,12 +99,14 @@ jobs:
- name: Validate documentation strings
run: |
mojo doc -warn-missing-doc-strings -o /dev/null stdlib/src/
mojo doc -warn-missing-doc-strings -o /dev/null stdlib/src/ > warnings.txt 2>&1
./check-file-is-empty.py warnings.txt
if [ $? -ne 0 ]; then
echo "::error::Documentation string validation failed. Please fix the issues and try again."
exit 1
fi
- name: Run standard library tests and examples
run: |
./stdlib/scripts/run-tests.sh
Expand Down
45 changes: 45 additions & 0 deletions stdlib/scripts/check-file-is-empty.py
@@ -0,0 +1,45 @@
#!/usr/bin/env python3
# ===----------------------------------------------------------------------=== #
# Copyright (c) 2024, Modular Inc. All rights reserved.
#
# Licensed under the Apache License v2.0 with LLVM Exceptions:
# https://llvm.org/LICENSE.txt
#
# 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.
# ===----------------------------------------------------------------------=== #

import argparse
import os
import sys


def main():
parser = argparse.ArgumentParser(
description=(
"Exits successfully if the file at the given path is empty or does"
" not exist. Otherwise, prints the file's contents, then exits"
" unsuccessfully."
)
)
parser.add_argument("path")
args = parser.parse_args()

if not os.path.exists(args.path):
return

with open(args.path, "r") as f:
content = f.read().strip()
if content:
print(
f"error: '{args.path}' is not empty:\n{content}",
file=sys.stderr,
)
exit(1)


if __name__ == "__main__":
main()

0 comments on commit e614d0c

Please sign in to comment.