You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
146 lines
5.0 KiB
146 lines
5.0 KiB
name: CI
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- master
|
|
- dev
|
|
- ci
|
|
|
|
workflow_run:
|
|
workflows:
|
|
- sync-channels
|
|
types:
|
|
- completed
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
check-flake:
|
|
name: Check flake
|
|
if: ${{ github.event.workflow_run.conclusion != 'failure' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0 # Nix Flakes doesn't work on shallow clones
|
|
- name: Install Nix (flakes, nixpkgs-unstable)
|
|
uses: cachix/install-nix-action@v12
|
|
with:
|
|
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20201221_9fab14a/install
|
|
extra_nix_config: |
|
|
experimental-features = nix-command flakes
|
|
nix_path: nixpkgs=channel:nixpkgs-unstable
|
|
- name: Check flake
|
|
run: nix flake check -v --show-trace --no-update-lock-file
|
|
|
|
check-sync-script:
|
|
name: Check sync script
|
|
if: ${{ github.event.workflow_run.conclusion != 'failure' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
- name: Install python
|
|
uses: actions/setup-python@v2
|
|
with:
|
|
python-version: '3.8'
|
|
- name: Install python packages
|
|
run: pip3 install -r ./scripts/requirements.txt
|
|
- name: Clean the latest version of each channel
|
|
run: |
|
|
for channel in stable beta nightly; do
|
|
version=$(sed -nE 's/.*latest = "(.*?)".*/\1/p' "./manifests/$channel/default.nix")
|
|
echo "Remove $channel $version"
|
|
rm "./manifests/$channel/default.nix"
|
|
if [[ "$channel" == "stable" ]]; then
|
|
rm "./manifests/$channel/$version.nix"
|
|
else
|
|
rm "./manifests/$channel/${version%%-*}/$version.nix"
|
|
fi
|
|
done
|
|
- name: Re-fetch latest stable
|
|
run: python3 ./scripts/fetch.py stable
|
|
- name: Re-fetch latest beta
|
|
run: python3 ./scripts/fetch.py beta
|
|
- name: Re-fetch latest nightly
|
|
run: python3 ./scripts/fetch.py nightly
|
|
- name: Check file changes
|
|
run: |
|
|
short_status=$(git status --short)
|
|
echo "$short_status"
|
|
shopt -s extglob
|
|
while read -r change; do
|
|
case "$change" in
|
|
# Okay if there is no change.
|
|
"" ) ;;
|
|
"?? "manifests/@(stable|nightly|beta)/* ) ;;
|
|
"M "manifests/@(renames.nix|targets.nix) ) ;;
|
|
"M "manifests/@(stable|nightly|beta)/default.nix ) ;;
|
|
* )
|
|
echo "Unexpected change: $change"
|
|
exit 1
|
|
esac
|
|
done <<<"$short_status"
|
|
|
|
check-build:
|
|
name: Check build Rust
|
|
if: ${{ github.event.workflow_run.conclusion != 'failure' }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest]
|
|
channel: [stable, beta]
|
|
build_pkg: [minimal, default]
|
|
runs-on: ${{ matrix.os }}
|
|
env:
|
|
build_expr: (import <nixpkgs> { overlays = [ (import ./.) ]; }).rust-bin.${{ matrix.channel }}.latest.${{ matrix.build_pkg }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
- name: Get locked nixpkgs revision
|
|
id: nixpkgs_rev
|
|
run: |
|
|
rev=$(jq '.nodes.nixpkgs.locked.rev' --raw-output flake.lock)
|
|
echo "Revision: $rev"
|
|
echo "::set-output name=rev::$rev"
|
|
- name: Install Nix
|
|
uses: cachix/install-nix-action@v12
|
|
with:
|
|
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/${{ steps.nixpkgs_rev.outputs.rev }}.tar.gz
|
|
- name: Instantiate derivation
|
|
id: instantiate
|
|
run: |
|
|
drv_path=$(nix-instantiate -E "$build_expr")
|
|
echo "::set-output name=drv_path::$drv_path"
|
|
- name: Cache derivation status
|
|
id: cache-drv-status
|
|
uses: actions/cache@v2
|
|
with:
|
|
key: drv-check-build-0-${{ steps.instantiate.outputs.drv_path }}
|
|
path: successful
|
|
- name: Build Rust
|
|
if: steps.cache-drv-status.outputs.cache-hit != 'true'
|
|
run: |
|
|
nix-build -E "$build_expr"
|
|
./result/bin/rustc --version
|
|
- name: Prepare nix-shell
|
|
if: steps.cache-drv-status.outputs.cache-hit != 'true'
|
|
run: nix-shell -p "$build_expr" --pure --command "exit"
|
|
- name: Check `rustc` works
|
|
if: steps.cache-drv-status.outputs.cache-hit != 'true'
|
|
run: |
|
|
echo 'fn main() { println!("hello, world"); }' >./test.rs
|
|
# Use nix-shell to bring propagatedBuildInputs into scope.
|
|
nix-shell -p "$build_expr" --pure --command "rustc test.rs -o test"
|
|
[[ "$(./test)" == "hello, world" ]]
|
|
- name: Check `clippy` works
|
|
if: matrix.build_pkg == 'default' && steps.cache-drv-status.outputs.cache-hit != 'true'
|
|
run: |
|
|
echo 'fn main() { loop { break; } }' >./test.rs
|
|
nix-shell -p "$build_expr" --pure --command 'clippy-driver test.rs -W clippy::never-loop' 2>&1 | tee msg
|
|
[[ ${PIPESTATUS[0]} -eq 0 && "$(cat msg)" == *"warning: this loop never actually loops"* ]]
|
|
- name: Mark a successful build for cache
|
|
if: steps.cache-drv-status.outputs.cache-hit != 'true'
|
|
run: echo "1" >./successful
|
|
|