Skip to content

Commit

Permalink
chore: merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
fgdorais committed Sep 27, 2024
1 parent ce7bd25 commit 3d72b89
Show file tree
Hide file tree
Showing 118 changed files with 2,246 additions and 3,425 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ jobs:

- id: lean-action
name: build, test, and lint batteries
uses: leanprover/lean-action@v1-beta
uses: leanprover/lean-action@v1
with:
build-args: '-Kwerror'
lint-module: 'Batteries'

- name: Check that all files are imported
run: lake env lean scripts/check_imports.lean
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/nightly_detect_failure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
type: 'stream'
topic: 'Batteries status updates'
content: |
❌ The latest CI for Batteries' [`nightly-testing`](https://github.com/leanprover-community/batteries/tree/nightly-testing) branch has [failed](https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}).
The latest CI for Batteries' [`nightly-testing`](https://github.com/leanprover-community/batteries/tree/nightly-testing) branch has [failed](https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}).
# Whenever `nightly-testing` passes CI,
# push it to `nightly-testing-YYYY-MM-DD` so we have a known good version of Batteries on that nightly release.
Expand Down Expand Up @@ -77,13 +77,13 @@ jobs:
}
response = client.get_messages(request)
messages = response['messages']
if not messages or messages[0]['content'] != "✅ The latest CI for Batteries' [`nightly-testing`](https://github.com/leanprover-community/batteries/tree/nightly-testing) branch has succeeded!":
if not messages or messages[0]['content'] != "✅ The latest CI for Batteries' [`nightly-testing`](https://github.com/leanprover-community/batteries/tree/nightly-testing) branch has succeeded!":
# Post the success message
request = {
'type': 'stream',
'to': 'nightly-testing',
'topic': 'Batteries status updates',
'content': "✅ The latest CI for Batteries' [`nightly-testing`](https://github.com/leanprover-community/batteries/tree/nightly-testing) branch has succeeded!"
'content': "✅ The latest CI for Batteries' [`nightly-testing`](https://github.com/leanprover-community/batteries/tree/nightly-testing) branch has succeeded!"
}
result = client.send_message(request)
print(result)
Expand Down
97 changes: 97 additions & 0 deletions .github/workflows/test_mathlib.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Test Mathlib against a Batteries PR

name: Test Mathlib

on:
workflow_run:
workflows: [ci]
types: [completed]

jobs:
on-success:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' && github.repository == 'leanprover-community/batteries'
steps:
- name: Retrieve information about the original workflow
uses: potiuk/get-workflow-origin@v1_1
id: workflow-info
with:
token: ${{ secrets.GITHUB_TOKEN }}
sourceRunId: ${{ github.event.workflow_run.id }}

- name: Checkout mathlib4 repository
if: steps.workflow-info.outputs.pullRequestNumber != ''
uses: actions/checkout@v4
with:
repository: leanprover-community/mathlib4
token: ${{ secrets.MATHLIB4_BOT }}
ref: master
fetch-depth: 0

- name: install elan
run: |
set -o pipefail
curl -sSfL https://github.com/leanprover/elan/releases/download/v3.0.0/elan-x86_64-unknown-linux-gnu.tar.gz | tar xz
./elan-init -y --default-toolchain none
echo "$HOME/.elan/bin" >> "${GITHUB_PATH}"
- name: Retrieve PR information
if: steps.workflow-info.outputs.pullRequestNumber != ''
id: pr-info
uses: actions/github-script@v6
env:
PR_NUMBER: ${{ steps.workflow-info.outputs.pullRequestNumber }}
with:
script: |
const prNumber = process.env.PR_NUMBER;
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber
});
core.exportVariable('HEAD_REPO', pr.head.repo.full_name);
core.exportVariable('HEAD_BRANCH', pr.head.ref);
- name: Check if tag exists
if: steps.workflow-info.outputs.pullRequestNumber != ''
id: check_mathlib_tag
env:
PR_NUMBER: ${{ steps.workflow-info.outputs.pullRequestNumber }}
HEAD_REPO: ${{ env.HEAD_REPO }}
HEAD_BRANCH: ${{ env.HEAD_BRANCH }}
run: |
git config user.name "leanprover-community-mathlib4-bot"
git config user.email "[email protected]"
echo "PR info: $HEAD_REPO $HEAD_BRANCH"
BASE=master
echo "Using base tag: $BASE"
EXISTS="$(git ls-remote --heads origin batteries-pr-testing-$PR_NUMBER | wc -l)"
echo "Branch exists: $EXISTS"
if [ "$EXISTS" = "0" ]; then
echo "Branch does not exist, creating it."
git switch -c batteries-pr-testing-$PR_NUMBER "$BASE"
# Use the fork and branch name to modify the lakefile.lean
sed -i "s,require \"leanprover-community\" / \"batteries\" @ git \".\+\",require \"leanprover-community\" / \"batteries\" from git \"https://github.com/$HEAD_REPO\" @ \"$HEAD_BRANCH\",g" lakefile.lean
lake update batteries
git add lakefile.lean lake-manifest.json
git commit -m "Update Batteries branch for testing https://github.com/leanprover-community/batteries/pull/$PR_NUMBER"
else
echo "Branch already exists, merging $BASE and bumping Batteries."
git switch batteries-pr-testing-$PR_NUMBER
git merge "$BASE" --strategy-option ours --no-commit --allow-unrelated-histories
lake update batteries
git add lake-manifest.json
git commit --allow-empty -m "Trigger CI for https://github.com/leanprover-community/batteries/pull/$PR_NUMBER"
fi
- name: Push changes
if: steps.workflow-info.outputs.pullRequestNumber != ''
env:
PR_NUMBER: ${{ steps.workflow-info.outputs.pullRequestNumber }}
run: |
git push origin batteries-pr-testing-$PR_NUMBER
5 changes: 5 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ image:
vscode:
extensions:
- leanprover.lean4

tasks:
- init: |
elan self update
lake build
14 changes: 4 additions & 10 deletions Batteries.lean
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Batteries.Classes.BEq
import Batteries.Classes.Cast
import Batteries.Classes.Order
import Batteries.Classes.RatCast
Expand All @@ -17,28 +16,26 @@ import Batteries.Data.Array
import Batteries.Data.AssocList
import Batteries.Data.BinaryHeap
import Batteries.Data.BinomialHeap
import Batteries.Data.BitVec
import Batteries.Data.Bool
import Batteries.Data.ByteArray
import Batteries.Data.ByteSubarray
import Batteries.Data.Char
import Batteries.Data.DList
import Batteries.Data.Fin
import Batteries.Data.FloatArray
import Batteries.Data.HashMap
import Batteries.Data.Int
import Batteries.Data.LazyList
import Batteries.Data.List
import Batteries.Data.MLList
import Batteries.Data.Nat
import Batteries.Data.Option
import Batteries.Data.PairingHeap
import Batteries.Data.RBMap
import Batteries.Data.Range
import Batteries.Data.Rat
import Batteries.Data.String
import Batteries.Data.Sum
import Batteries.Data.Thunk
import Batteries.Data.UInt
import Batteries.Data.UnionFind
import Batteries.Data.Vector
import Batteries.Lean.AttributeExtra
import Batteries.Lean.Delaborator
import Batteries.Lean.Except
Expand All @@ -59,18 +56,15 @@ import Batteries.Lean.Meta.SavedState
import Batteries.Lean.Meta.Simp
import Batteries.Lean.Meta.UnusedNames
import Batteries.Lean.MonadBacktrack
import Batteries.Lean.Name
import Batteries.Lean.NameMap
import Batteries.Lean.NameMapAttribute
import Batteries.Lean.PersistentHashMap
import Batteries.Lean.PersistentHashSet
import Batteries.Lean.Position
import Batteries.Lean.SMap
import Batteries.Lean.Syntax
import Batteries.Lean.System.IO
import Batteries.Lean.TagAttribute
import Batteries.Lean.Util.EnvSearch
import Batteries.Lean.Util.Path
import Batteries.Linter
import Batteries.Linter.UnnecessarySeqFocus
import Batteries.Linter.UnreachableTactic
Expand All @@ -84,6 +78,7 @@ import Batteries.Tactic.Congr
import Batteries.Tactic.Exact
import Batteries.Tactic.Init
import Batteries.Tactic.Instances
import Batteries.Tactic.Lemma
import Batteries.Tactic.Lint
import Batteries.Tactic.Lint.Basic
import Batteries.Tactic.Lint.Frontend
Expand All @@ -102,7 +97,6 @@ import Batteries.Tactic.Unreachable
import Batteries.Tactic.Where
import Batteries.Test.Internal.DummyLabelAttr
import Batteries.Util.Cache
import Batteries.Util.CheckTactic
import Batteries.Util.ExtendedBinder
import Batteries.Util.LibraryNote
import Batteries.Util.Pickle
Expand Down
18 changes: 0 additions & 18 deletions Batteries/Classes/BEq.lean

This file was deleted.

7 changes: 2 additions & 5 deletions Batteries/Classes/Order.lean
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ theorem cmp_congr_left (xy : cmp x y = .eq) : cmp x z = cmp y z :=
theorem cmp_congr_left' (xy : cmp x y = .eq) : cmp x = cmp y :=
funext fun _ => cmp_congr_left xy

theorem cmp_congr_right [TransCmp cmp] (yz : cmp y z = .eq) : cmp x y = cmp x z := by
theorem cmp_congr_right (yz : cmp y z = .eq) : cmp x y = cmp x z := by
rw [← Ordering.swap_inj, symm, symm, cmp_congr_left yz]

end TransCmp
Expand Down Expand Up @@ -278,11 +278,8 @@ instance [Ord β] [OrientedOrd β] (f : α → β) : OrientedCmp (compareOn f) w
instance [Ord β] [TransOrd β] (f : α → β) : TransCmp (compareOn f) where
le_trans := TransCmp.le_trans (α := β)

-- FIXME: remove after lean4#3882 is merged
theorem _root_.lexOrd_def [Ord α] [Ord β] :
(lexOrd : Ord (α × β)).compare = compareLex (compareOn (·.1)) (compareOn (·.2)) := by
funext a b
simp [lexOrd, compareLex, compareOn]
(lexOrd : Ord (α × β)).compare = compareLex (compareOn (·.1)) (compareOn (·.2)) := rfl

section «non-canonical instances»
-- Note: the following instances seem to cause lean to fail, see:
Expand Down
4 changes: 2 additions & 2 deletions Batteries/CodeAction/Attr.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Copyright (c) 2023 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Lean.Server.CodeActions
import Lean.Server.CodeActions.Basic

/-!
# Initial setup for code action attributes
Expand All @@ -14,7 +14,7 @@ import Lean.Server.CodeActions
* Attribute `@[tactic_code_action]` collects code actions which will be called
on each occurrence of a tactic.
-/
namespace Std.CodeAction
namespace Batteries.CodeAction

open Lean Elab Server Lsp RequestM Snapshots

Expand Down
Loading

0 comments on commit 3d72b89

Please sign in to comment.