Skip to content

Commit

Permalink
Merge branch 'master' into mo271/fract_div_intCast_eq_div_intCast_mod
Browse files Browse the repository at this point in the history
  • Loading branch information
mo271 authored Nov 29, 2024
2 parents b6d614c + 4965277 commit ba7912f
Show file tree
Hide file tree
Showing 4,813 changed files with 234,219 additions and 104,908 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
47 changes: 47 additions & 0 deletions .docker/gitpod-blueprint/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This is the Dockerfile for `leanprovercommunity/gitpod4-blueprint`.
# As well as elan, we also install leanblueprint and all of its dependencies.

# This container does not come with a pre-installed version of mathlib.
# When a gitpod container is spawned, elan will be updated and mathlib will be downloaded:
# see the .gitpod.yml file for more information.

FROM ubuntu:jammy

USER root

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install sudo git curl git bash-completion texlive texlive-xetex latexmk graphviz graphviz-dev python3 python3-pip python3-requests -y && apt-get clean

RUN useradd -l -u 33333 -G sudo -md /home/gitpod -s /bin/bash -p gitpod gitpod \
# passwordless sudo for users in the 'sudo' group
&& sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers
USER gitpod
WORKDIR /home/gitpod

SHELL ["/bin/bash", "-c"]

# gitpod bash prompt
RUN { echo && echo "PS1='\[\033[01;32m\]\u\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\]\$(__git_ps1 \" (%s)\") $ '" ; } >> .bashrc

# install elan
RUN curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain none

# install whichever toolchain mathlib is currently using
RUN . ~/.profile && elan toolchain install $(curl https://raw.githubusercontent.com/leanprover-community/mathlib4/master/lean-toolchain)

# install neovim (for any lean.nvim user), via tarball since the appimage doesn't work for some reason, and jammy's version is ancient
RUN curl -s -L https://github.com/neovim/neovim/releases/download/stable/nvim-linux64.tar.gz | tar xzf - && sudo mv nvim-linux64 /opt/nvim

ENV PATH="/home/gitpod/.local/bin:/home/gitpod/.elan/bin:/opt/nvim/bin:${PATH}"

# install leanblueprint
RUN python3 -m pip install leanblueprint invoke

# fix the infoview when the container is used on gitpod:
ENV VSCODE_API_VERSION="1.50.0"

# ssh to github once to bypass the unknown fingerprint warning
RUN ssh -o StrictHostKeyChecking=no github.com || true

# run sudo once to suppress usage info
RUN sudo echo finished
11 changes: 7 additions & 4 deletions .docker/gitpod/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# This is the Dockerfile for `leanprovercommunity/mathlib:gitpod`.
# This is the Dockerfile for `leanprovercommunity/gitpod4`.

# This container does not come with a pre-installed version of mathlib.
# When a gitpod container is spawned, elan will be updated and mathlib will be downloaded:
# see the .gitpod.yml file for more information.

# gitpod doesn't support multiple FROM statements, (or rather, you can't copy from one to another)
# so we just install everything in one go
FROM ubuntu:jammy

USER root

RUN apt-get update && apt-get install sudo git curl git bash-completion python3 python3-requests -y && apt-get clean
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install sudo git curl git bash-completion python3 python3-pip python3-requests -y && apt-get clean

RUN useradd -l -u 33333 -G sudo -md /home/gitpod -s /bin/bash -p gitpod gitpod \
# passwordless sudo for users in the 'sudo' group
Expand Down
36 changes: 36 additions & 0 deletions .docker/lean/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This is the Dockerfile for `leanprovercommunity/lean4`.
# It is based on the generic `debian` image, and installs `elan` and the current stable version of `lean`.

# This container does not come with a pre-installed version of mathlib;
# you should call `lake exe cache get` which will download the most recent version.
# The only difference between this Dockerfile and leanprovercommunity/lean4 is that this image
# bypasses a warning that could occur when trying to connect to github for the first time.

# NOTE: to run this docker image on macos or windows,
# you will need to increase the allowed memory (in the docker GUI) beyond 2GB

FROM debian
USER root
# install prerequisites
RUN apt-get update && apt-get install curl git -y && apt-get clean
# create a non-root user
RUN useradd -m lean

USER lean
WORKDIR /home/lean

SHELL ["/bin/bash", "-c"]
# set the entrypoint to be a login shell, so everything is on the PATH
ENTRYPOINT ["/bin/bash", "-l"]

# make sure binaries are available even in non-login shells
ENV PATH="/home/lean/.elan/bin:/home/lean/.local/bin:$PATH"

# install elan
RUN curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain none && \
. ~/.profile && \
elan toolchain install $(curl https://raw.githubusercontent.com/leanprover-community/mathlib/master/leanpkg.toml | grep lean_version | awk -F'"' '{print $2}') && \
elan default stable

# ssh to github once to bypass the unknown fingerprint warning
RUN ssh -o StrictHostKeyChecking=no github.com || true
94 changes: 78 additions & 16 deletions .github/build.in.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# This is the master file for autogenerating `.github/workflows/{bors, build_fork, build }.yml`.
### NB: This is the master file for autogenerating
### NB: `.github/workflows/{bors, build_fork, build}.yml`.
### NB: If you need to edit any of those files, you should edit this file instead,
### NB: and regenerate those files by manually running
### NB: .github/workflows/mk_build_yml.sh

env:
# Disable Lake's automatic fetching of cloud builds.
# Lake's cache is currently incompatible with Mathlib's `lake exe cache`.
# This is because Mathlib's Cache assumes all build aritfacts present in the build directory
# are valid by-products of the Mathlib build. Build artifacts fetched from Lake's cache do
# not necessarily satisfy this property.
LAKE_NO_CACHE: true

jobs:
# Cancels previous runs of jobs in this file
Expand Down Expand Up @@ -29,7 +41,7 @@ jobs:
uses: credfeto/action-case-checker@v1.3.0

- name: Look for ignored files
uses: credfeto/action-no-ignored-files@v1.1.0
uses: credfeto/action-no-ignored-files@v1.2.0

- name: "Check for Lean files with the executable bit set"
shell: bash
Expand Down Expand Up @@ -88,7 +100,7 @@ jobs:
# The Hoskinson runners may not have jq installed, so do that now.
- name: 'Setup jq'
uses: dcarbone/install-jq-action@v1.0.1
uses: dcarbone/install-jq-action@v2.1.0

- name: install elan
run: |
Expand Down Expand Up @@ -117,6 +129,7 @@ jobs:
- name: prune ProofWidgets .lake
run: |
lake build proofwidgets:release
# The ProofWidgets release contains not just the `.js` (which we need in order to build)
# but also `.oleans`, which may have been built with the wrong toolchain.
# This removes them.
Expand All @@ -132,13 +145,29 @@ jobs:
lake exe cache get Mathlib.Init
lake build --no-build Mathlib.Init && lake exe cache get || echo "No cache for 'Mathlib.Init' available"
- name: update {Mathlib, Tactic, Counterexamples, Archive}.lean
id: mk_all
run: |
if ! lake exe mk_all --check
then
echo "Not all lean files are in the import all files"
echo "mk_all=false" >> "${GITHUB_OUTPUT}"
else
echo "mk_all=true" >> "${GITHUB_OUTPUT}"
fi
- name: build mathlib
id: build
uses: liskin/gh-problem-matcher-wrap@v3
with:
linters: gcc
run: |
bash -o pipefail -c "lake exe mk_all || echo \"There are unaccounted for files, but I am not failing yet\!\"; env LEAN_ABORT_ON_PANIC=1 lake build --wfail -KCI"
bash -o pipefail -c "env LEAN_ABORT_ON_PANIC=1 lake build --wfail -KCI"
- name: print the sizes of the oleans
run: |
du .lake/build/lib/Mathlib || echo "This code should be unreachable"
- name: upload cache
# We only upload the cache if the build started (whether succeeding, failing, or cancelled)
Expand Down Expand Up @@ -194,8 +223,13 @@ jobs:
MATHLIB_CACHE_SAS: ${{ secrets.MATHLIB_CACHE_SAS }}
MATHLIB_CACHE_S3_TOKEN: ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}

- name: update {Mathlib, Tactic, Counterexamples, Archive}.lean
run: lake exe mk_all --check
- name: Check {Mathlib, Tactic, Counterexamples, Archive}.lean
run: |
if [ ${{ steps.mk_all.outputs.mk_all }} == "false" ]
then
echo "Please run 'lake exe mk_all' to regenerate the import all files"
exit 1
fi
- name: check for noisy stdout lines
id: noisy
Expand All @@ -219,23 +253,33 @@ jobs:
python3 scripts/yaml_check.py docs/100.yaml docs/overview.yaml docs/undergrad.yaml
lake exe check-yaml
- name: verify `lake exe graph` works
run: |
lake exe graph
rm import_graph.dot
- name: generate our import graph
run: lake exe graph

- name: upload the import graph
uses: actions/upload-artifact@v4
with:
name: import-graph
path: import_graph.dot
## the default is 90, but we build often, so unless there's a reason
## to care about old copies in the future, just say 7 days for now
retention-days: 7

- name: clean up the import graph file
run: rm import_graph.dot

- name: build everything
# make sure everything is available for test/import_all.lean
run: |
lake build Batteries Qq Aesop ProofWidgets
lake build Batteries Qq Aesop ProofWidgets Plausible
- name: test mathlib
id: test
uses: liskin/gh-problem-matcher-wrap@v3
with:
linters: gcc
run:
lake test
lake --iofail test

- name: check for unused imports
id: shake
Expand All @@ -257,7 +301,7 @@ jobs:
# Output is posted to the zulip topic
# https://leanprover.zulipchat.com/#narrow/stream/345428-mathlib-reviewers/topic/lean4checker

- name: Post comments for lean-pr-testing branch
- name: Post comments for lean-pr-testing-NNNN and batteries-pr-testing-NNNN branches
if: always()
env:
TOKEN: ${{ secrets.LEAN_PR_TESTING }}
Expand All @@ -266,11 +310,29 @@ jobs:
BUILD_OUTCOME: ${{ steps.build.outcome }}
NOISY_OUTCOME: ${{ steps.noisy.outcome }}
ARCHIVE_OUTCOME: ${{ steps.archive.outcome }}
COUNTEREXAMPLE_OUTCOME: ${{ steps.counterexamples.outcome }}
COUNTEREXAMPLES_OUTCOME: ${{ steps.counterexamples.outcome }}
LINT_OUTCOME: ${{ steps.lint.outcome }}
TEST_OUTCOME: ${{ steps.test.outcome }}
run: |
scripts/lean-pr-testing-comments.sh
scripts/lean-pr-testing-comments.sh lean
scripts/lean-pr-testing-comments.sh batteries
- name: build lean4checker, but don't run it
if: ${{ (always() && steps.build.outcome == 'success' || steps.build.outcome == 'failure') && contains(github.event.pull_request.changed_files, 'lean-toolchain') }}
run: |
git clone https://github.com/leanprover/lean4checker
cd lean4checker
# Read lean-toolchain file and checkout appropriate branch
TOOLCHAIN=$(cat ../lean-toolchain)
if [[ "$TOOLCHAIN" =~ ^leanprover/lean4:v ]]; then
VERSION=${TOOLCHAIN#leanprover/lean4:}
git checkout "$VERSION"
else
git checkout master
fi
# Build lean4checker using the same toolchain
cp ../lean-toolchain .
lake build
final:
name: Post-CI jobJOB_NAME
Expand All @@ -281,7 +343,7 @@ jobs:
- uses: actions/checkout@v4

- id: PR
uses: 8BitJonny/gh-get-current-pr@2.2.0
uses: 8BitJonny/gh-get-current-pr@3.0.0
# TODO: this may not work properly if the same commit is pushed to multiple branches:
# https://github.com/8BitJonny/gh-get-current-pr/issues/8
with:
Expand Down
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2 # Specifies the version of the Dependabot configuration file format

updates:
# Configuration for dependency updates
- package-ecosystem: "github-actions" # Specifies the ecosystem to check for updates
directory: "/" # Specifies the directory to check for dependencies; "/" means the root directory
schedule:
# Check for updates to GitHub Actions every month
interval: "monthly"
23 changes: 21 additions & 2 deletions .github/workflows/PR_summary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:

jobs:
build:
name: "post-or-update-summary-comment"
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -55,12 +56,27 @@ jobs:
PR="${{ github.event.pull_request.number }}"
title="### PR summary"
graphAndHighPercentReports=$(python ./scripts/import-graph-report.py base.json head.json changed_files.txt)
## Import count comment
importCount=$(
python ./scripts/import-graph-report.py base.json head.json changed_files.txt
printf '%s\n' "${graphAndHighPercentReports}" | sed '/^Import changes exceeding/Q'
./scripts/import_trans_difference.sh
)
## High percentage imports
high_percentages=$(
printf '%s\n' "${graphAndHighPercentReports}" | sed -n '/^Import changes exceeding/,$p'
)
# if there are files with large increase in transitive imports, then we add the `large-import` label
if [ -n "${high_percentages}" ]
then
high_percentages=$'\n\n'"${high_percentages}"
gh pr edit "${PR}" --add-label large-import
else # otherwise, we remove the label
gh pr edit "${PR}" --remove-label large-import
fi
if [ "$(printf '%s' "${importCount}" | wc -l)" -gt 12 ]
then
importCount="$(printf '<details><summary>\n\n%s\n\n</summary>\n\n%s\n\n</details>\n' "#### Import changes for modified files" "${importCount}")"
Expand All @@ -80,6 +96,9 @@ jobs:
currentHash="$(git rev-parse HEAD)"
hashURL="https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}/commits/${currentHash}"
message="$(printf '%s [%s](%s)\n\n%s\n\n---\n\n%s\n' "${title}" "$(git rev-parse --short HEAD)" "${hashURL}" "${importCount}" "${declDiff}")"
## Technical debt changes
techDebtVar="$(./scripts/technical-debt-metrics.sh pr_summary)"
message="$(printf '%s [%s](%s)%s\n\n%s\n\n---\n\n%s\n\n---\n\n%s\n' "${title}" "$(git rev-parse --short HEAD)" "${hashURL}" "${high_percentages}" "${importCount}" "${declDiff}" "${techDebtVar}")"
./scripts/update_PR_comment.sh "${message}" "${title}" "${PR}"
Loading

0 comments on commit ba7912f

Please sign in to comment.