108 lines
3.9 KiB
YAML
108 lines
3.9 KiB
YAML
name: Nix CI
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
tags:
|
|
- '*'
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
Build:
|
|
runs-on: ${{ matrix.os }}
|
|
defaults:
|
|
run:
|
|
shell: nix -v --experimental-features "nix-command flakes" run .#ciShell -- bash -euxo pipefail {0}
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- name: Nix Linux
|
|
os: ubuntu-latest
|
|
#- name: Nix macOS
|
|
# os: macos-latest
|
|
# complete all jobs
|
|
fail-fast: false
|
|
name: ${{ matrix.name }}
|
|
env:
|
|
NIX_BUILD_ARGS: -v --print-build-logs --fallback
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
- name: Install Nix
|
|
uses: cachix/install-nix-action@v15
|
|
with:
|
|
# https://github.com/NixOS/nix/issues/6572
|
|
install_url: https://releases.nixos.org/nix/nix-2.7.0/install
|
|
extra_nix_config: |
|
|
extra-sandbox-paths = /nix/var/cache/ccache
|
|
substituters = file://${{ github.workspace }}/nix-store-cache-copy?priority=10&trusted=true https://cache.nixos.org
|
|
- name: Set Up Nix Cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: nix-store-cache
|
|
key: ${{ matrix.name }}-nix-store-cache-${{ github.sha }}
|
|
# fall back to (latest) previous cache
|
|
restore-keys: |
|
|
${{ matrix.name }}-nix-store-cache
|
|
- name: Further Set Up Nix Cache
|
|
shell: bash -euxo pipefail {0}
|
|
run: |
|
|
# Nix seems to mutate the cache, so make a copy
|
|
cp -r nix-store-cache nix-store-cache-copy || true
|
|
- name: Prepare CCache Cache
|
|
shell: bash -euxo pipefail {0}
|
|
run: |
|
|
sudo mkdir -m0770 -p /nix/var/cache/ccache
|
|
sudo chown -R $USER /nix/var/cache/ccache
|
|
- name: Setup CCache Cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: /nix/var/cache/ccache
|
|
key: ${{ matrix.name }}-nix-ccache-${{ github.sha }}
|
|
# fall back to (latest) previous cache
|
|
restore-keys: |
|
|
${{ matrix.name }}-nix-ccache
|
|
- name: Further Set Up CCache Cache
|
|
shell: bash -euxo pipefail {0}
|
|
run: |
|
|
sudo chown -R root:nixbld /nix/var/cache
|
|
sudo chmod -R 770 /nix/var/cache
|
|
- name: Install Cachix
|
|
uses: cachix/cachix-action@v10
|
|
with:
|
|
name: lean4
|
|
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
|
skipPush: true # we push specific outputs only
|
|
- name: Build
|
|
run: |
|
|
# .o files are not a runtime dependency on macOS because of lack of thin archives
|
|
nix build $NIX_BUILD_ARGS .#stage0 .#stage1.lean-all .#Lean.oTree .#iTree .#modDepsFiles -o push-build
|
|
- name: Test
|
|
run: |
|
|
nix build $NIX_BUILD_ARGS .#test -o push-test
|
|
- name: Build manual
|
|
run: |
|
|
nix build $NIX_BUILD_ARGS --update-input lean --no-write-lock-file ./doc#{lean-mdbook,leanInk,alectryon,test} -o push-doc
|
|
nix build $NIX_BUILD_ARGS --update-input lean --no-write-lock-file ./doc
|
|
if: matrix.name == 'Nix Linux'
|
|
- name: Push to Cachix
|
|
run: |
|
|
[ -z "${{ secrets.CACHIX_AUTH_TOKEN }}" ] || cachix push -j4 lean4 ./push-* || true
|
|
- name: Rebuild Nix Store Cache
|
|
run: |
|
|
rm -rf nix-store-cache || true
|
|
nix copy ./push-* --to file://$PWD/nix-store-cache?compression=none
|
|
- name: Publish manual
|
|
uses: peaceiris/actions-gh-pages@v3
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
publish_dir: ./result
|
|
destination_dir: ./doc
|
|
if: matrix.name == 'Nix Linux' && github.ref == 'refs/heads/master' && github.event_name == 'push'
|
|
- name: Fixup CCache Cache
|
|
run: |
|
|
sudo chown -R $USER /nix/var/cache
|
|
- name: CCache stats
|
|
run: CCACHE_DIR=/nix/var/cache/ccache nix run .#nixpkgs.ccache -- -s
|