mirror of https://github.com/sgoudham/git-view.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
152 lines
4.3 KiB
YAML
152 lines
4.3 KiB
YAML
# Copyright (c) 2023 Hamothy
|
|
# Copyright (c) 2015 Andrew Gallant
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
# in the Software without restriction, including without limitation the rights
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
name: build
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
paths:
|
|
- "src/**"
|
|
- "Cargo.toml"
|
|
- "Cargo.lock"
|
|
pull_request:
|
|
paths:
|
|
- "src/**"
|
|
- "Cargo.toml"
|
|
- "Cargo.lock"
|
|
|
|
env:
|
|
BINARY: git-view
|
|
|
|
jobs:
|
|
compile:
|
|
env:
|
|
# For some builds, we use cross to test on 32-bit and big-endian systems.
|
|
CARGO: cargo
|
|
# When CARGO is set to CROSS, this is set to `--target matrix.target`.
|
|
TARGET_FLAGS:
|
|
# When CARGO is set to CROSS, TARGET_DIR includes matrix.target.
|
|
TARGET_DIR: ./target
|
|
# Emit backtraces on panics.
|
|
RUST_BACKTRACE: 1
|
|
runs-on: ${{ matrix.os }}
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
build:
|
|
- stable
|
|
- nightly-gnu
|
|
- nightly-musl
|
|
- nightly-32
|
|
- nightly-arm
|
|
- macos
|
|
- win-msvc
|
|
- win-gnu
|
|
include:
|
|
- build: stable
|
|
os: ubuntu-22.04
|
|
rust: stable
|
|
- build: nightly-gnu
|
|
os: ubuntu-22.04
|
|
rust: nightly
|
|
target: x86_64-unknown-linux-gnu
|
|
- build: nightly-musl
|
|
os: ubuntu-22.04
|
|
rust: nightly
|
|
target: x86_64-unknown-linux-musl
|
|
- build: nightly-32
|
|
os: ubuntu-22.04
|
|
rust: nightly
|
|
target: i686-unknown-linux-gnu
|
|
- build: nightly-arm
|
|
os: ubuntu-22.04
|
|
rust: nightly
|
|
target: arm-unknown-linux-gnueabihf
|
|
- build: macos
|
|
os: macos-12
|
|
rust: nightly
|
|
target: x86_64-apple-darwin
|
|
- build: win-msvc
|
|
os: windows-2022
|
|
rust: nightly
|
|
- build: win-gnu
|
|
os: windows-2022
|
|
rust: nightly-x86_64-gnu
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install packages (Ubuntu)
|
|
if: matrix.os == 'ubuntu-22.04'
|
|
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends musl-tools
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: ${{ matrix.rust }}
|
|
|
|
- name: Cache Rust
|
|
uses: Swatinem/rust-cache@v2
|
|
|
|
- name: Use Cross
|
|
if: matrix.target != ''
|
|
run: |
|
|
cargo install cross
|
|
echo "CARGO=cross" >> $GITHUB_ENV
|
|
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
|
|
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
|
|
|
|
- name: Show command used for Cargo
|
|
run: |
|
|
echo "cargo command is: ${{ env.CARGO }}"
|
|
echo "target flag is: ${{ env.TARGET_FLAGS }}"
|
|
|
|
- name: Compile
|
|
run: ${{ env.CARGO }} build --verbose ${{ env.TARGET_FLAGS }}
|
|
|
|
- name: Test
|
|
run: ${{ env.CARGO }} test --verbose ${{ env.TARGET_FLAGS }}
|
|
|
|
- name: View Target Dir
|
|
run: ls -la ${{ env.TARGET_DIR }}/debug
|
|
|
|
- name: Retrieve Name of Binary
|
|
id: upload-artifact
|
|
run: |
|
|
if [ "${{ matrix.os }}" == "windows-2022" ]; then
|
|
echo "name=${{ env.TARGET_DIR }}/debug/${{ env.BINARY }}.exe" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "name=${{ env.TARGET_DIR}}/debug/${{ env.BINARY }}" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Upload Binary
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ env.BINARY }}-${{ matrix.build }}
|
|
path: ${{ steps.upload-artifact.outputs.name }}
|
|
|
|
rustfmt:
|
|
name: rustfmt
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: stable
|
|
components: rustfmt
|
|
- name: Check formatting
|
|
run: cargo fmt --all --check
|