From fd9953b0c5922ff800194b0f5b0c0371d1ce844c Mon Sep 17 00:00:00 2001 From: Beksultan <96925396+Vazno@users.noreply.github.com> Date: Mon, 19 Dec 2022 04:38:40 +0600 Subject: [PATCH] Create csv_linter.yml --- .github/workflows/csv_linter.yml | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/csv_linter.yml diff --git a/.github/workflows/csv_linter.yml b/.github/workflows/csv_linter.yml new file mode 100644 index 0000000..f07553d --- /dev/null +++ b/.github/workflows/csv_linter.yml @@ -0,0 +1,39 @@ +name: CSV Linter and Trailing Whitespaces + +on: + push: + pull_request: + +jobs: + lint_and_check_trailing_whitespaces: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install csvkit + + - name: Lint CSV files + run: find . -name "*.csv" -exec csvclean -n -u 2 {} + + env: + CI: true + - name: Check for errors + if: always() + run: | + if ! grep -q "No errors." <(find . -name "*.csv" -exec csvclean -n -u 2 {} + | grep -v "^$"); then + echo "Errors were found in one or more CSV files." + exit 1 + fi + - name: Check Trailing Whitespaces + run: | + # Check if the special file contains any trailing whitespaces + if grep -q "[[:space:]]$" ./prompts.csv; then + echo "ERROR: Found trailing whitespaces in prompts.csv" + exit 1 + else + echo "No trailing whitespaces found in prompts.csv" + fi \ No newline at end of file