Skip to content

Always opt for linux musl binary, automate release process #11

Always opt for linux musl binary, automate release process

Always opt for linux musl binary, automate release process #11

Workflow file for this run

name: Test Rust package and built binaries
on:
push:
branches: [main]
pull_request:
branches: ["*"]
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
jobs:
test_rust_crate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Basic build validation
run: |
cargo build
- name: Check program
run: |
cargo check
- name: Check formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
- name: Output test coverage
run: |
cargo install cargo-tarpaulin
cargo tarpaulin --fail-under 75
build_binaries:
uses: ./.github/workflows/build.yml
test_built_binaries:
needs: build_binaries
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
include:
- os: macos-latest
artifact: macos-binaries
binary: fta
ext: tar.gz
extract: tar -xf
- os: windows-latest
artifact: windows-binaries
binary: fta.exe
ext: 7z
extract: 7z e
- os: ubuntu-latest
artifact: linux-binaries
binary: fta
ext: tar.gz
extract: tar -xf
steps:
- uses: actions/checkout@v3
- name: Install 7zip (Windows)
if: runner.os == 'Windows'
run: choco install 7zip
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: ${{ matrix.artifact }}
path: artifact/
- name: Extract artifact
run: |
for file in artifact/*; do
${{ matrix.extract }} "$file"
done
- name: Create sample folder and copy foo.ts
run: |
mkdir sample
cp ./.github/foo.ts sample/
- name: Test binary
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
OUTPUT=$(./${{ matrix.binary }} sample | Out-String)
else
OUTPUT=$(./${{ matrix.binary }} sample)
fi
if [[ "$OUTPUT" == "foo" ]]; then
echo "Test Passed"
else
echo "Test Failed: Expected 'foo' but got '$OUTPUT'"
exit 1
fi