Skip to content

Commit

Permalink
Implement ExplicitImports hook in main repo
Browse files Browse the repository at this point in the history
Manually add an ExplicitImports pre-commit hook.

Related to #349
  • Loading branch information
abelsiqueira committed Oct 2, 2024
1 parent 2b95a78 commit cdcc7a8
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
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

0 comments on commit cdcc7a8

Please sign in to comment.