268 lines
11 KiB
YAML
268 lines
11 KiB
YAML
name: CI
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'master'
|
|
tags:
|
|
- '*'
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
schedule:
|
|
- cron: '0 7 * * *' # 8AM CET/11PM PT
|
|
|
|
jobs:
|
|
set-nightly:
|
|
# don't schedule nightlies on forks
|
|
if: github.event_name == 'schedule' && github.repository == 'leanprover/lean4'
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
nightly: ${{ steps.set.outputs.nightly }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
- name: Set Nightly
|
|
id: set
|
|
run: |
|
|
if [[ -n '${{ secrets.PUSH_NIGHTLY_TOKEN }}' ]]; then
|
|
git remote add nightly https://foo:'${{ secrets.PUSH_NIGHTLY_TOKEN }}'@github.com/${{ github.repository_owner }}/lean4-nightly.git
|
|
git fetch nightly --tags
|
|
LEAN_VERSION_STRING="nightly-$(date -u +%F)"
|
|
# do nothing if commit already has a different tag
|
|
if [[ $(git name-rev --name-only --tags --no-undefined HEAD 2> /dev/null || echo $LEAN_VERSION_STRING) == $LEAN_VERSION_STRING ]]; then
|
|
echo "::set-output name=nightly::$LEAN_VERSION_STRING"
|
|
fi
|
|
fi
|
|
|
|
build:
|
|
needs: set-nightly
|
|
if: always()
|
|
runs-on: ${{ matrix.os }}
|
|
defaults:
|
|
run:
|
|
shell: ${{ matrix.shell || 'nix-shell --run "bash -euxo pipefail {0}"' }}
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
# portable release build: use channel with older glibc (2.27)
|
|
- name: Linux release
|
|
os: ubuntu-latest
|
|
release: true
|
|
shell: nix-shell --arg pkgsDist "import (fetchTarball \"channel:nixos-19.03\") {{}}" --run "bash -euxo pipefail {0}"
|
|
llvm-url: https://github.com/leanprover/lean-llvm/releases/download/14.0.0/lean-llvm-x86_64-linux-gnu.tar.zst
|
|
prepare-llvm: ../script/prepare-llvm-linux.sh lean-llvm*
|
|
binary-check: ldd -v
|
|
- name: Linux
|
|
os: ubuntu-latest
|
|
check-stage3: true
|
|
test-speedcenter: true
|
|
- name: Linux Debug
|
|
os: ubuntu-latest
|
|
CMAKE_OPTIONS: -DCMAKE_BUILD_TYPE=Debug
|
|
- name: Linux fsanitize
|
|
os: ubuntu-latest
|
|
# turn off custom allocator & symbolic functions to make LSAN do its magic
|
|
CMAKE_OPTIONS: -DLEAN_EXTRA_CXX_FLAGS=-fsanitize=address,undefined -DLEANC_EXTRA_FLAGS='-fsanitize=address,undefined -fsanitize-link-c++-runtime' -DSMALL_ALLOCATOR=OFF -DBSYMBOLIC=OFF
|
|
# exclude problematic tests
|
|
CTEST_OPTIONS: -E laketest
|
|
- name: macOS
|
|
os: macos-latest
|
|
release: true
|
|
shell: bash -euxo pipefail {0}
|
|
CMAKE_OPTIONS: -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15
|
|
llvm-url: https://github.com/leanprover/lean-llvm/releases/download/14.0.0/lean-llvm-x86_64-apple-darwin.tar.zst
|
|
prepare-llvm: ../script/prepare-llvm-macos.sh lean-llvm*
|
|
binary-check: otool -L
|
|
- name: Windows
|
|
os: windows-2022
|
|
release: true
|
|
shell: msys2 {0}
|
|
CMAKE_OPTIONS: -G "Unix Makefiles"
|
|
# for reasons unknown, interactivetests are flaky on Windows
|
|
CTEST_OPTIONS: --repeat until-pass:2
|
|
llvm-url: https://github.com/leanprover/lean-llvm/releases/download/14.0.0/lean-llvm-x86_64-w64-windows-gnu.tar.zst
|
|
prepare-llvm: ../script/prepare-llvm-mingw.sh lean-llvm*
|
|
binary-check: ldd
|
|
- name: Linux aarch64
|
|
os: ubuntu-latest
|
|
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=$GMP
|
|
release: true
|
|
cross: true
|
|
shell: nix-shell --arg pkgsDist "import (fetchTarball \"channel:nixos-19.03\") {{ localSystem.config = \"aarch64-unknown-linux-gnu\"; }}" --run "bash -euxo pipefail {0}"
|
|
llvm-url: https://github.com/leanprover/lean-llvm/releases/download/14.0.0/lean-llvm-x86_64-linux-gnu.tar.zst https://github.com/leanprover/lean-llvm/releases/download/14.0.0/lean-llvm-aarch64-linux-gnu.tar.zst
|
|
prepare-llvm: EXTRA_FLAGS=--target=aarch64-unknown-linux-gnu ../script/prepare-llvm-linux.sh lean-llvm-aarch64-* lean-llvm-x86_64-*
|
|
# complete all jobs
|
|
fail-fast: false
|
|
name: ${{ matrix.name }}
|
|
env:
|
|
# must be inside workspace
|
|
CCACHE_DIR: ${{ github.workspace }}/.ccache
|
|
CCACHE_COMPRESS: true
|
|
# current cache limit
|
|
CCACHE_MAXSIZE: 200M
|
|
# squelch error message about missing nixpkgs channel
|
|
NIX_BUILD_SHELL: bash
|
|
LSAN_OPTIONS: max_leaks=10
|
|
# somehow MinGW clang64 (or cmake?) defaults to `g++` even though it doesn't exist
|
|
CXX: c++
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
with:
|
|
submodules: true
|
|
- name: Install Nix
|
|
uses: cachix/install-nix-action@v15
|
|
if: matrix.os == 'ubuntu-latest'
|
|
- name: Install MSYS2
|
|
uses: msys2/setup-msys2@v2
|
|
with:
|
|
msystem: clang64
|
|
install: make python mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-ccache git zip unzip diffutils binutils tree mingw-w64-clang-x86_64-zstd tar
|
|
if: matrix.os == 'windows-2022'
|
|
- name: Install Brew Packages
|
|
run: |
|
|
brew install ccache tree zstd coreutils
|
|
if: matrix.os == 'macos-latest'
|
|
- name: Cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: .ccache
|
|
key: ${{ matrix.name }}-build-${{ github.sha }}
|
|
# fall back to (latest) previous cache
|
|
restore-keys: |
|
|
${{ matrix.name }}-build
|
|
- name: Setup
|
|
run: |
|
|
# open nix-shell once for initial setup
|
|
true
|
|
if: matrix.os == 'ubuntu-latest'
|
|
- name: Build
|
|
run: |
|
|
mkdir build
|
|
cd build
|
|
OPTIONS=()
|
|
[[ -z '${{ matrix.llvm-url }}' ]] || wget -q ${{ matrix.llvm-url }}
|
|
[[ -z '${{ matrix.prepare-llvm }}' ]] || eval "OPTIONS+=($(${{ matrix.prepare-llvm }}))"
|
|
if [[ -n '${{ matrix.release }}' && -n '${{ needs.set-nightly.outputs.nightly }}' ]]; then
|
|
OPTIONS+=(-DLEAN_SPECIAL_VERSION_DESC=${{ needs.set-nightly.outputs.nightly }})
|
|
fi
|
|
# contortion to support empty OPTIONS with old macOS bash
|
|
cmake .. ${{ matrix.CMAKE_OPTIONS }} ${OPTIONS[@]+"${OPTIONS[@]}"} -DLEAN_INSTALL_PREFIX=$PWD/..
|
|
make -j4
|
|
make install
|
|
- name: Check Binaries
|
|
run: ${{ matrix.binary-check }} lean-*/bin/* || true
|
|
- name: List Install Tree
|
|
run: |
|
|
# omit contents of Init/, ...
|
|
tree --du -h lean-* | grep -E ' (Init|Std|Lean|Lake|LICENSE|[a-z])'
|
|
- name: Pack
|
|
run: |
|
|
dir=$(echo lean-*)
|
|
mkdir pack
|
|
# high-compression tar.zst + zip for release, fast tar.zst otherwise
|
|
if [[ '${{ startsWith(github.ref, 'refs/tags/v') && matrix.release }}' == true || -n '${{ needs.set-nightly.outputs.nightly }}' ]]; then
|
|
tar cf - $dir | zstd -T0 --no-progress -19 -o pack/$dir.tar.zst
|
|
zip -rq pack/$dir.zip $dir
|
|
else
|
|
tar cf - $dir | zstd -T0 --no-progress -o pack/$dir.tar.zst
|
|
fi
|
|
- uses: actions/upload-artifact@v2
|
|
if: matrix.release
|
|
with:
|
|
name: build-${{ matrix.name }}
|
|
path: pack/*
|
|
- name: Lean stats
|
|
run: |
|
|
build/stage1/bin/lean --stats src/Lean.lean
|
|
if: ${{ !matrix.cross }}
|
|
- name: Test
|
|
run: |
|
|
cd build/stage1
|
|
ctest -j4 --output-on-failure ${{ matrix.CTEST_OPTIONS }} < /dev/null
|
|
if: ${{ !matrix.cross }}
|
|
- name: Check Test Binary
|
|
run: ${{ matrix.binary-check }} tests/compiler/534.lean.out
|
|
if: ${{ !matrix.cross }}
|
|
- name: Build Stage 2
|
|
run: |
|
|
cd build
|
|
make -j4 stage2
|
|
if: matrix.build-stage2 || matrix.check-stage3
|
|
- name: Check Stage 3
|
|
run: |
|
|
cd build
|
|
make -j4 check-stage3
|
|
if: matrix.check-stage3
|
|
- name: Test Speedcenter Benchmarks
|
|
run: |
|
|
echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid
|
|
export BUILD=$PWD/build PATH=$PWD/build/stage1/bin:$PATH
|
|
nix-shell -A with-temci --run "cd tests/bench; temci exec --config speedcenter.yaml --included_blocks fast --runs 1"
|
|
if: matrix.test-speedcenter
|
|
- name: Check rebootstrap
|
|
run: |
|
|
cd build
|
|
make update-stage0 && make -j4
|
|
if: matrix.name == 'Linux'
|
|
- name: CCache stats
|
|
run: ccache -s
|
|
|
|
release:
|
|
# When GitHub says "If a job fails, all jobs that need it are skipped unless
|
|
# the jobs use a conditional expression that causes the job to continue.", don't believe
|
|
# their lies. It's actually the entire closure (i.e. including `set-nightly`) that
|
|
# must succeed for subsequent to be run without `always()`.
|
|
if: always() && needs.build.result == 'success' && startsWith(github.ref, 'refs/tags/v')
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
steps:
|
|
- uses: actions/download-artifact@v2
|
|
with:
|
|
path: artifacts
|
|
- name: Release
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
files: artifacts/*/*
|
|
fail_on_unmatched_files: true
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
release-nightly:
|
|
needs: [set-nightly, build]
|
|
if: needs.set-nightly.outputs.nightly
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
with:
|
|
# needed for tagging
|
|
fetch-depth: 0
|
|
token: ${{ secrets.PUSH_NIGHTLY_TOKEN }}
|
|
- uses: actions/download-artifact@v2
|
|
with:
|
|
path: artifacts
|
|
- name: Prepare Nightly Release
|
|
run: |
|
|
git remote add nightly https://foo:'${{ secrets.PUSH_NIGHTLY_TOKEN }}'@github.com/${{ github.repository_owner }}/lean4-nightly.git
|
|
git fetch nightly --tags
|
|
git tag ${{ needs.set-nightly.outputs.nightly }}
|
|
git push nightly ${{ needs.set-nightly.outputs.nightly }}
|
|
last_tag=$(git describe HEAD^ --abbrev=0 --tags)
|
|
echo -e "*Changes since ${last_tag}:*\n\n" > diff.md
|
|
git show $last_tag:RELEASES.md > old.md
|
|
#./script/diff_changelogs.py old.md doc/changes.md >> diff.md
|
|
diff --changed-group-format='%>' --unchanged-group-format='' old.md RELEASES.md >> diff.md || true
|
|
echo -e "\n*Full commit log*\n" >> diff.md
|
|
git log --oneline $last_tag..HEAD | sed 's/^/* /' >> diff.md
|
|
- name: Release Nightly
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
body_path: diff.md
|
|
prerelease: true
|
|
files: artifacts/*/*
|
|
fail_on_unmatched_files: true
|
|
tag_name: ${{ needs.set-nightly.outputs.nightly }}
|
|
repository: ${{ github.repository_owner }}/lean4-nightly
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.PUSH_NIGHTLY_TOKEN }}
|