From 15d72bbe43811b0c6aa3703fa4ee6b8c7f29b8b1 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Sat, 4 Feb 2023 21:17:15 -0800 Subject: [PATCH] Add lint workflow --- .github/workflows/Lint.yml | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/Lint.yml diff --git a/.github/workflows/Lint.yml b/.github/workflows/Lint.yml new file mode 100644 index 0000000..cb8bf7a --- /dev/null +++ b/.github/workflows/Lint.yml @@ -0,0 +1,45 @@ +name: Lint + +on: + push: + branches: + - main + tags: + - v* + pull_request: + +jobs: + lintrunner: + name: lintrunner + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest] + python_version: ["3.11"] + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python_version }} + - name: Install Lintrunner + run: | + pip install . + lintrunner init + - name: Run lintrunner on all files + run: | + set +e + if ! lintrunner -v --force-color --all-files --tee-json=lint.json; then + echo "" + echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner -m main\`.\e[0m" + exit 1 + fi + - name: Store annotations + continue-on-error: true + run: | + # Use jq to massage the JSON lint output into GitHub Actions workflow commands. + jq --raw-output \ + '"::\(if .severity == "advice" or .severity == "disabled" then "warning" else .severity end) file=\(.path),line=\(.line),col=\(.char),title=\(.code) \(.name)::" + (.description | gsub("\\n"; "%0A"))' \ + lint.json