intermodal/.github/workflows/build.yaml
Casey Rodarmor 7ca9ed62d5
Mark Info::infohash as potentially lossy
`Info::infohash` will discard fields not present in the `Info` struct,
and can thus produce an erronous infohash.

To try to prevent this function from being called in those
circumstances, rename it to `Info::infohash_lossy`, and add a comment
explaining why it is dangerous.

Embarassingly, `Info::infohash` was called in
`TorrentSummary::from_input`, and thus transitively by the torrent show
subcommand, where it is definitely not safe, since torrent show is
intended to be used with arbitrary torrents. This is now fixed.

There was also a build failure caused by a cache issue, so change the
cache keys to invalidate the caches.

type: fixed
2020-09-06 20:23:45 -07:00

151 lines
3.5 KiB
YAML

name: Build
on:
push:
branches:
- master
tags:
- '*'
pull_request:
branches:
- master
jobs:
all:
name: All
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: macos-latest
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{matrix.os}}
env:
RUSTFLAGS: "-D warnings"
steps:
- uses: actions/checkout@v2
if: github.event_name == 'pull_request'
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- uses: actions/checkout@v2
if: github.event_name != 'pull_request'
with:
fetch-depth: 0
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-v0
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-v0
- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-v0
- name: Install Stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{matrix.target}}
profile: minimal
components: clippy, rustfmt
override: true
- name: Info
run: |
rustup --version
cargo --version
cargo clippy --version
- name: Build
run: cargo build --all --verbose
- name: Test
run: cargo test --all --verbose
- name: Clippy
run: cargo clippy --all
- name: Lint
if: matrix.os == 'macos-latest'
run: |
brew install ripgrep
./bin/lint
- name: Install Nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: ${{matrix.target}}
profile: minimal
components: rustfmt
- name: Check Formatting
run: cargo +nightly fmt --all -- --check
- name: Check Generated
if: matrix.os == 'macos-latest'
run: |
brew install help2man
cargo run --package gen -- --bin target/debug/imdl all
git diff --no-ext-diff --exit-code
- name: Install `mdbook`
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: latest
- name: Build Book
run: |
cargo run --package gen -- --bin target/debug/imdl book
mdbook build book --dest-dir ../www/book
- name: Record Git Revision
if: github.ref == 'refs/heads/master' && matrix.os == 'ubuntu-latest'
run: git rev-parse --verify HEAD > www/head.txt
- name: Deploy Pages
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/master' && matrix.os == 'ubuntu-latest'
with:
github_token: ${{secrets.GITHUB_TOKEN}}
publish_branch: gh-pages
publish_dir: ./www
- name: Package
id: package
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: ./bin/package ${{github.ref}} ${{matrix.os}} ${{matrix.target}}
- name: Publish Release Archive
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: false
files: ${{steps.package.outputs.archive}}
prerelease: ${{ ! startsWith(github.ref, 'refs/tags/v') }}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}