CI #655
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
schedule: | |
- cron: '0 0 * * 0' | |
push: | |
branches: | |
- master | |
- staging | |
- trying | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+**' | |
pull_request: | |
env: | |
CARGO_EQUIP_TEST_NIGHTLY_TOOLCHAIN: nightly-2023-08-04 | |
jobs: | |
rustfmt: | |
name: Rustfmt | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up `stable` | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt | |
- name: cargo-fmt | |
run: cargo fmt --all -- --check | |
grcov: | |
name: grcov | |
runs-on: ubuntu-20.04 | |
if: ${{ github.repository_owner == 'qryxip' && github.ref == 'refs/heads/master' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up `stable` | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: llvm-tools-preview, rustfmt | |
- name: Set up `${{ env.CARGO_EQUIP_TEST_NIGHTLY_TOOLCHAIN }}` | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.CARGO_EQUIP_TEST_NIGHTLY_TOOLCHAIN }} | |
- name: Install cargo-binstall | |
uses: taiki-e/install-action@cargo-binstall | |
- name: Install cargo-udeps | |
run: | | |
cargo +stable binstall \ | |
cargo-udeps@^0.1 \ | |
--no-confirm \ | |
--log-level debug | |
- name: Install grcov | |
run: | | |
cargo +stable binstall \ | |
grcov@^0.8 \ | |
--pkg-url '{ repo }/releases/download/v{ version }/{ name }-{ target }.tar.bz2' \ | |
--pkg-fmt tbz2 \ | |
--bin-dir '{ bin }{ binary-ext }' \ | |
--no-confirm \ | |
--log-level debug | |
- name: cargo-test | |
run: cargo +stable test --no-fail-fast -v -- --test-threads 1 | |
env: | |
RUSTFLAGS: '-Cinstrument-coverage' | |
RUST_BACKTRACE: full | |
LLVM_PROFILE_FILE: '%p-%m.profraw' | |
- name: grcov | |
run: grcov . -b ./target/debug -s . -t lcov --branch --ignore-not-existing --ignore '/*' -o lcov.info | |
- name: Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: lcov.info | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
target-triple: | |
- x86_64-pc-windows-msvc | |
- x86_64-apple-darwin | |
- x86_64-unknown-linux-gnu | |
include: | |
- { channel: stable, target-triple: x86_64-pc-windows-msvc , exe-suffix: .exe, os: windows-2019 } | |
- { channel: stable, target-triple: x86_64-apple-darwin , exe-suffix: '' , os: macos-11 } | |
- { channel: stable, target-triple: x86_64-unknown-linux-gnu, exe-suffix: '' , os: ubuntu-20.04 } | |
name: ${{ matrix.channel }}-${{ matrix.target-triple }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Disable `core.autocrlf` | |
run: git config --global core.autocrlf false | |
if: ${{ matrix.os == 'windows-2019' }} | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: 'Set up `${{ matrix.channel }}` (target: `${{ matrix.target-triple }}`)' | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.channel }} | |
targets: ${{ matrix.target-triple }} | |
components: clippy | |
- name: Set up `${{ env.CARGO_EQUIP_TEST_NIGHTLY_TOOLCHAIN }}` | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.CARGO_EQUIP_TEST_NIGHTLY_TOOLCHAIN }} | |
targets: ${{ matrix.target-triple }} | |
profile: minimal | |
- name: Rust Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Install cargo-binstall | |
uses: taiki-e/install-action@cargo-binstall | |
- name: Install cargo-udeps | |
run: | | |
cargo +${{ matrix.channel }} binstall \ | |
cargo-udeps@^0.1 \ | |
--no-confirm \ | |
--log-level debug | |
shell: bash | |
- name: cargo-clippy | |
run: cargo +${{ matrix.channel }} clippy --all-targets --target ${{ matrix.target-triple }} -- -D warnings | |
- name: cargo-test | |
run: cargo +${{ matrix.channel }} test --no-fail-fast --target ${{ matrix.target-triple }} -- --test-threads 1 | |
env: | |
RUST_BACKTRACE: full | |
- name: cargo-install (locked) | |
run: cargo +${{ matrix.channel }} install --path . --debug --target ${{ matrix.target-triple }} --locked | |
- name: cargo-install | |
run: cargo +${{ matrix.channel }} install --path . --debug --target ${{ matrix.target-triple }} | |
- name: cargo-udeps | |
run: cargo +${{ env.CARGO_EQUIP_TEST_NIGHTLY_TOOLCHAIN }} udeps --all-targets | |
upload-archives: | |
strategy: | |
fail-fast: false | |
matrix: | |
target-triple: | |
- x86_64-pc-windows-msvc | |
- x86_64-apple-darwin | |
- x86_64-unknown-linux-gnu | |
include: | |
- { target-triple: x86_64-pc-windows-msvc , os: windows-2019 } | |
- { target-triple: x86_64-apple-darwin , os: macos-11 } | |
- { target-triple: x86_64-unknown-linux-gnu, os: ubuntu-20.04 } | |
name: Upload (${{ matrix.target-triple }}) | |
runs-on: ${{ matrix.os }} | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
steps: | |
- name: Disable `core.autocrlf` | |
run: git config --global core.autocrlf false | |
if: ${{ matrix.os == 'windows-2019' }} | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: 'Set up `stable` (target: `${{ matrix.target-triple }}`)' | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target-triple }} | |
- name: cargo-install | |
run: cargo install --path . --target ${{ matrix.target-triple }} -v --locked | |
- name: Create an asset | |
id: asset | |
run: | | |
BIN_TARGET=cargo-equip | |
if ${{ contains(matrix.target-triple, 'pc-windows') }}; then | |
DOT_EXE=.exe | |
fi | |
ASSET_STEM="$BIN_TARGET-${GITHUB_REF#refs/tags/}-${{ matrix.target-triple }}" | |
git archive -o "./$ASSET_STEM.tar" --prefix "$ASSET_STEM/" HEAD | |
tar -xf "./$ASSET_STEM.tar" | |
mv "$HOME/.cargo/bin/$BIN_TARGET$DOT_EXE" "./$ASSET_STEM/" | |
if ${{ contains(matrix.target-triple, 'pc-windows') }}; then | |
ASSET="$ASSET_STEM.zip" | |
7z a "$ASSET" "./$ASSET_STEM" | |
zipinfo "./$ASSET" | |
else | |
ASSET="$ASSET_STEM.tar.gz" | |
tar -czvf "./$ASSET" "./$ASSET_STEM" | |
fi | |
echo "::set-output name=asset::$ASSET" | |
shell: bash | |
- name: Upload the artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: assets | |
path: ${{ steps.asset.outputs.asset }} | |
upload-release-notes: | |
name: Upload the release notes | |
runs-on: ubuntu-20.04 | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Prepare release notes | |
run: | | |
with open('./CHANGELOG.md') as file: | |
changelog = file.read() | |
output = '' | |
inside_subsection = False | |
for line in changelog.splitlines(): | |
is_h2 = line.startswith('## ') | |
if not inside_subsection and is_h2: | |
inside_subsection = True | |
elif inside_subsection and not is_h2: | |
output += line + '\n' | |
elif inside_subsection: | |
break | |
with open('./release-notes.md', 'w') as file: | |
file.write(output) | |
shell: python | |
- name: Upload the release notes | |
uses: actions/upload-artifact@v3 | |
with: | |
name: release-notes | |
path: release-notes.md | |
release: | |
name: GitHub Release | |
runs-on: ubuntu-20.04 | |
needs: [rustfmt, build, upload-archives, upload-release-notes] | |
steps: | |
- name: Download the assets | |
uses: actions/download-artifact@v3 | |
with: | |
name: assets | |
path: ./assets | |
- name: Download the release notes | |
uses: actions/download-artifact@v3 | |
with: | |
name: release-notes | |
path: . | |
- name: GH Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: ./assets/* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: GH Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
body_path: ./release-notes.md | |
files: ./assets/* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |