Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add remaining pre-commit-hooks #430

Merged
merged 9 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actionlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ self-hosted-runner:
labels:
- ubuntu-x64
- macOS
- public-amd64-2xlarge
# Configuration variables in array of strings defined in your repository or
# organization. `null` means disabling configuration variables check.
# Empty array means no configuration variable is allowed.
Expand Down
62 changes: 49 additions & 13 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,50 @@ jobs:
echo "out=${action_files}" >> "$GITHUB_OUTPUT"

# Run tests against all linters for known_good_version and latest version
linter_tests:
name: Linter Tests ${{ matrix.os }}
runs-on: [self-hosted, "${{ matrix.os }}"]
linter_tests_linux:
name: Linter Tests Linux
runs-on: public-amd64-2xlarge
needs: detect_changes
if:
needs.detect_changes.outputs.linters == 'true' || needs.detect_changes.outputs.all-linters ==
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we end up keeping this, can we merge it back into the matrix and add a new field to the object for the correct runner name?

'linters/'
timeout-minutes: 90
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Linter Tests
# Run tests using KnownGoodVersion with any modified linters and conditionally all linters
uses: ./.github/actions/linter_tests
with:
linter-version: KnownGoodVersion
sourcery-token: ${{ secrets.TRUNK_SOURCERY_TOKEN }}
append-args:
${{ needs.detect_changes.outputs.all-linters }} ${{
needs.detect_changes.outputs.linters-files }}
trunk-token: ${{ secrets.TRUNK_DEBUGGER_TOKEN }}

- name: Linter Tests Latest
# Run tests on Latest with any modified linters (see filters.yaml). Don't run when cancelled.
if:
(failure() || success()) && needs.detect_changes.outputs.linters == 'true' &&
needs.detect_changes.outputs.linters-files != ''
uses: ./.github/actions/linter_tests
with:
linter-version: Latest
sourcery-token: ${{ secrets.TRUNK_SOURCERY_TOKEN }}
append-args: ${{ needs.detect_changes.outputs.linters-files }}
trunk-token: ${{ secrets.TRUNK_DEBUGGER_TOKEN }}

# Run tests against all linters for known_good_version and latest version
linter_tests_macos:
name: Linter Tests macOS
runs-on: [self-hosted, macOS]
needs: detect_changes
if:
needs.detect_changes.outputs.linters == 'true' || needs.detect_changes.outputs.all-linters ==
'linters/'
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
os: [Linux, macOS]
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down Expand Up @@ -156,7 +188,7 @@ jobs:

tool_tests:
name: Tool Tests
runs-on: [self-hosted, "${{ matrix.os }}"]
runs-on: public-amd64-2xlarge
needs: detect_changes
if:
needs.detect_changes.outputs.tools == 'true' || needs.detect_changes.outputs.all-tools ==
Expand All @@ -182,7 +214,7 @@ jobs:

action_tests:
name: Action Tests
runs-on: [self-hosted, Linux]
runs-on: public-amd64-2xlarge
needs: detect_changes
if:
needs.detect_changes.outputs.actions == 'true' || needs.detect_changes.outputs.all-actions ==
Expand Down Expand Up @@ -281,14 +313,18 @@ jobs:
if: ${{ always() }}
runs-on: ubuntu-latest
name: Aggregate Test Results
needs: [linter_tests, tool_tests, repo_tests]
needs: [linter_tests_macos, linter_tests_linux, tool_tests, repo_tests]
steps:
- run: |
linters="${{ needs.linter_tests.result }}"
repos="${{ needs.repo_tests.result }}"
tools="${{ needs.tool_tests.result }}"
if [[ $linters != "success" && $linters != "skipped" ]]; then
echo "Detected failure in linter tests"
linters_macos = ${{ needs.linter_tests_macos.result }}
linters_linux = ${{ needs.linter_tests_linux.result }}
if [[ $linters_macos != "success" && $linters_macos != "skipped" ]]; then
echo "Detected failure in linter macos tests"
exit 1
elif [[ $linters_linux != "success" && $linters_linux != "skipped" ]]; then
echo "Detected failure in linter linux tests"
exit 1
elif [[ $tools != "success" && $tools != "skipped" ]]; then
echo "Detected failure in tool tests"
Expand Down
4 changes: 4 additions & 0 deletions linters/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ lint:
extensions:
- xib

- name: xml
extensions:
- xml

- name: yaml
extensions:
- yaml
Expand Down
145 changes: 145 additions & 0 deletions linters/pre-commit-hooks/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,148 @@ lint:
success_codes: [0, 1]
files:
- ALL
- name: check-added-large-files
enabled: false
output: pass_fail
read_output_from: stdout
run: check-added-large-files ${target}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add python3 to the front of these if appropriate? Shebangs don't work for these executions on Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False alarm. This was previously WAI, the files are .exe on Windows and inside of Scripts/, so no need for the python3 bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

success_codes: [0, 1]
files:
- ALL
- name: check-ast
enabled: false
output: pass_fail
read_output_from: stdout
run: check-ast ${target}
success_codes: [0, 1]
files:
- python
- name: check-builtin-literals
enabled: false
output: pass_fail
read_output_from: stdout
run: check-builtin-literals ${target}
success_codes: [0, 1]
files:
- python
- name: check-case-conflict
enabled: false
output: pass_fail
read_output_from: stdout
run: check-case-conflict ${target}
success_codes: [0, 1]
files:
- ALL
- name: check-docstring-first
enabled: false
output: pass_fail
read_output_from: stdout
run: check-docstring-first ${target}
success_codes: [0, 1]
files:
- python
- name: check-json
enabled: false
output: pass_fail
read_output_from: stdout
run: check-json ${target}
success_codes: [0, 1]
files:
- json
- name: check-merge-conflict
enabled: false
output: pass_fail
read_output_from: stdout
run: check-merge-conflict ${target}
success_codes: [0, 1]
files:
- ALL
- name: check-shebang-scripts-are-executable
enabled: false
output: pass_fail
read_output_from: stderr
run: check-shebang-scripts-are-executable ${target}
success_codes: [0, 1]
files:
- ALL
- name: check-symlinks
enabled: false
output: pass_fail
read_output_from: stderr
run: check-symlinks ${target}
success_codes: [0, 1]
files:
- ALL
- name: check-toml
enabled: false
output: pass_fail
read_output_from: stderr
run: check-toml ${target}
success_codes: [0, 1]
files:
- toml
- name: check-vcs-permalinks
enabled: false
output: pass_fail
read_output_from: stderr
run: check-vcs-permalinks ${target}
success_codes: [0, 1]
files:
- ALL
- name: check-xml
enabled: false
output: pass_fail
read_output_from: stderr
run: check-xml ${target}
success_codes: [0, 1]
files:
- xml
- name: check-yaml
enabled: false
output: pass_fail
read_output_from: stderr
run: check-yaml ${target}
success_codes: [0, 1]
files:
- yaml
- name: debug-statement-hook
enabled: false
output: pass_fail
read_output_from: stderr
run: debug-statement-hook ${target}
success_codes: [0, 1]
files:
- python
- name: destroyed-symlinks
enabled: false
output: pass_fail
read_output_from: stderr
run: destroyed-symlinks ${target}
success_codes: [0, 1]
files:
- ALL
- name: detect-private-key
enabled: false
output: pass_fail
read_output_from: stderr
run: detect-private-key ${target}
success_codes: [0, 1]
files:
- ALL
- name: mixed-line-ending
enabled: false
output: pass_fail
read_output_from: stdout
run: mixed-line-ending --fix=no ${target}
success_codes: [0, 1]
files:
- ALL
- name: trailing-whitespace
enabled: false
output: rewrite
in_place: true
formatter: true
run: mixed-line-ending --fix=no ${target}
success_codes: [0, 1]
files:
- ALL
Loading