Skip to content

Commit

Permalink
chore: check Lean import and copyright header in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
david-christiansen committed Jul 16, 2024
1 parent d4534a1 commit 21e7b54
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 10 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/formalities.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
on:
push:
pull_request:

name: Formalities

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Don't 'import Lean', use precise imports
if: always()
run: |
! (find . -name "*.lean" -type f -print0 | xargs -0 grep -E -n '^import Lean$')
- name: Verify .lean files start with a copyright header.
run: |
FILES=$(find ./src ./demo ./demo-toml -not -path '*/.lake/*' -type f -name "*.lean" -exec perl -ne 'BEGIN { $/ = undef; } print "$ARGV\n" if !m{\A/-\nCopyright}; exit;' {} \;)
if [ -n "$FILES" ]; then
echo "Found .lean files which do not have a copyright header:"
echo "$FILES"
exit 1
else
echo "All copyright headers present."
fi
6 changes: 5 additions & 1 deletion Extract.lean
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import Lean
/-
Copyright (c) 2023-2024 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: David Thrane Christiansen
-/
import SubVerso.Examples.Env

open Lean
Expand Down
7 changes: 5 additions & 2 deletions demo-toml/Demo.lean
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
-- This module serves as the root of the `Demo` library.
-- Import modules here that should be built as part of the library.
/-
Copyright (c) 2023-2024 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: David Thrane Christiansen
-/
import «Demo».Basic

import SubVerso.Examples
Expand Down
7 changes: 6 additions & 1 deletion demo-toml/Demo/Basic.lean
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
def hello := "world"
/-
Copyright (c) 2023-2024 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: David Thrane Christiansen
-/
def hello := "world"
5 changes: 5 additions & 0 deletions demo-toml/Main.lean
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/-
Copyright (c) 2023-2024 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: David Thrane Christiansen
-/
import «Demo»

def main : IO Unit :=
Expand Down
7 changes: 5 additions & 2 deletions demo/Demo.lean
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
-- This module serves as the root of the `Demo` library.
-- Import modules here that should be built as part of the library.
/-
Copyright (c) 2023-2024 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: David Thrane Christiansen
-/
import «Demo».Basic

import SubVerso.Examples
Expand Down
7 changes: 6 additions & 1 deletion demo/Demo/Basic.lean
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
def hello := "world"
/-
Copyright (c) 2023-2024 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: David Thrane Christiansen
-/
def hello := "world"
5 changes: 5 additions & 0 deletions demo/Main.lean
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/-
Copyright (c) 2023-2024 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: David Thrane Christiansen
-/
import «Demo»

def main : IO Unit :=
Expand Down
5 changes: 5 additions & 0 deletions demo/lakefile.lean
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/-
Copyright (c) 2023-2024 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: David Thrane Christiansen
-/
import Lake
open Lake DSL

Expand Down
5 changes: 5 additions & 0 deletions src/compat/SubVerso/Compat.lean
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/-
Copyright (c) 2023-2024 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: David Thrane Christiansen
-/
import Lean.Elab

open Lean Elab Term
Expand Down
10 changes: 8 additions & 2 deletions src/examples/SubVerso/Examples.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
/-
Copyright (c) 2023-2024 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: David Thrane Christiansen
-/
import Lean.Environment
import SubVerso.Highlighting
import SubVerso.Compat
import SubVerso.Examples.Env
import Lean.Environment


namespace SubVerso.Examples

Expand Down Expand Up @@ -284,7 +290,7 @@ elab_rules : command
let addScope x := mkIdentFrom x (addMacroScope mod x.getId sc)
let declName ← match sigName with
| `(Lean.Parser.Command.declId|$x:ident) => pure x
| `(Lean.Parser.Command.declId|$x:ident.{$u:ident,*}) => pure x
| `(Lean.Parser.Command.declId|$x:ident.{$_u:ident,*}) => pure x
| _ => throwErrorAt sigName "Unexpected format of name: {sigName}"
let target ← liftTermElabM <| Compat.realizeNameNoOverloads declName
let noClash ← match sigName with
Expand Down
5 changes: 5 additions & 0 deletions src/examples/SubVerso/Examples/Env.lean
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/-
Copyright (c) 2023-2024 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: David Thrane Christiansen
-/
import SubVerso.Highlighting

open Lean
Expand Down
5 changes: 5 additions & 0 deletions src/highlighting/SubVerso/Highlighting.lean
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
/-
Copyright (c) 2023-2024 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: David Thrane Christiansen
-/
import SubVerso.Highlighting.Highlighted
import SubVerso.Highlighting.Code
7 changes: 7 additions & 0 deletions src/highlighting/SubVerso/Highlighting/Code.lean
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
/-
Copyright (c) 2023-2024 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: David Thrane Christiansen
-/
import Lean.Widget.InteractiveCode
import Lean.Widget.TaggedText


import SubVerso.Compat
import SubVerso.Highlighting.Highlighted

Expand Down
9 changes: 8 additions & 1 deletion src/highlighting/SubVerso/Highlighting/Highlighted.lean
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import Lean
/-
Copyright (c) 2023-2024 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: David Thrane Christiansen
-/
import Lean.Data.Json
import Lean.Expr
import Lean.SubExpr -- for the To/FromJSON FVarId instances

open Lean

Expand Down

0 comments on commit 21e7b54

Please sign in to comment.