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 ExplicitImports pre-commit hook #472

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
25 changes: 25 additions & 0 deletions .github/scripts/explicit-imports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

module=$1

# Check that $module is not empty
if [ -z "$module" ]; then
echo "Module was not passed. 'args: [Module]' should be included in the pre-commit config"
fi

julia -e "
using Pkg
pkg\"activate\"

using ExplicitImports: ExplicitImports
pkg\"activate .\"

using $module
ExplicitImports.check_all_explicit_imports_are_public($module)
# ExplicitImports.check_all_qualified_accesses_are_public($module) # disabled due to #471
ExplicitImports.check_all_explicit_imports_via_owners($module)
ExplicitImports.check_all_qualified_accesses_via_owners($module)
ExplicitImports.check_no_implicit_imports($module)
ExplicitImports.check_no_self_qualified_accesses($module)
ExplicitImports.check_no_stale_explicit_imports($module)
"
6 changes: 4 additions & 2 deletions .github/workflows/Lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ jobs:
version: "1"
- name: Use Julia cache
uses: julia-actions/cache@v2
- name: Install JuliaFormatter.jl
run: julia -e 'using Pkg; pkg"add JuliaFormatter"'
- name: Build package (required for ExplicitImports)
uses: julia-actions/julia-buildpkg@v1
- name: Install Julia packages
run: julia -e 'using Pkg; pkg"add ExplicitImports, JuliaFormatter"'
- name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807
run: touch requirements.txt
- name: Setup Python
Expand Down
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ repos:
rev: v1.35.1
hooks:
- id: yamllint
- repo: local
hooks:
- id: explicit-imports
name: ExplicitImports checks
entry: .github/scripts/explicit-imports.sh
args: [BestieTemplate]
files: ^src.*\.jl$
language: script
pass_filenames: false
- repo: https://github.com/domluna/JuliaFormatter.jl
rev: v1.0.60
hooks:
Expand Down
2 changes: 1 addition & 1 deletion src/debug/Debug.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Noteworthy: [`BestieTemplate.Debug.Data`](@ref)
"""
module Debug

using ..BestieTemplate: BestieTemplate, generate, apply
using ..BestieTemplate: BestieTemplate

include("Data.jl")
include("helper.jl")
Expand Down