iced/.github/workflows/build.yml

239 lines
9.3 KiB
YAML

name: GitHub CI
on: push
jobs:
build-csharp-windows:
name: C# (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
steps:
- uses: actions/checkout@v1
- name: Run generator, verify no diff
shell: pwsh
run: |
cd src/csharp/Intel/Generator
dotnet run -c Release
if ($LASTEXITCODE) { exit $LASTEXITCODE }
git diff --exit-code
if ($LASTEXITCODE) { exit $LASTEXITCODE }
- name: Build one feature at a time
shell: pwsh
run: |
foreach ($def in
"NO_ENCODER;NO_INSTR_INFO;NO_GAS_FORMATTER;NO_INTEL_FORMATTER;NO_MASM_FORMATTER;NO_NASM_FORMATTER",
"NO_DECODER;NO_INSTR_INFO;NO_GAS_FORMATTER;NO_INTEL_FORMATTER;NO_MASM_FORMATTER;NO_NASM_FORMATTER",
"NO_DECODER;NO_ENCODER;NO_GAS_FORMATTER;NO_INTEL_FORMATTER;NO_MASM_FORMATTER;NO_NASM_FORMATTER",
"NO_DECODER;NO_ENCODER;NO_INSTR_INFO;NO_INTEL_FORMATTER;NO_MASM_FORMATTER;NO_NASM_FORMATTER",
"NO_DECODER;NO_ENCODER;NO_INSTR_INFO;NO_GAS_FORMATTER;NO_MASM_FORMATTER;NO_NASM_FORMATTER",
"NO_DECODER;NO_ENCODER;NO_INSTR_INFO;NO_GAS_FORMATTER;NO_INTEL_FORMATTER;NO_NASM_FORMATTER",
"NO_DECODER;NO_ENCODER;NO_INSTR_INFO;NO_GAS_FORMATTER;NO_INTEL_FORMATTER;NO_MASM_FORMATTER"
) {
git clean -xdf
if ($LASTEXITCODE) { exit $LASTEXITCODE }
$env:MoreDefineConstants=$def
dotnet build -v:m -c Release src/csharp/Intel/Iced/Iced.csproj
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}
foreach ($def in
"NO_INSTR_INFO;NO_GAS_FORMATTER;NO_INTEL_FORMATTER;NO_MASM_FORMATTER;NO_NASM_FORMATTER",
"NO_ENCODER;NO_GAS_FORMATTER;NO_INTEL_FORMATTER;NO_MASM_FORMATTER;NO_NASM_FORMATTER",
"NO_ENCODER;NO_INSTR_INFO;NO_INTEL_FORMATTER;NO_MASM_FORMATTER;NO_NASM_FORMATTER",
"NO_ENCODER;NO_INSTR_INFO;NO_GAS_FORMATTER;NO_MASM_FORMATTER;NO_NASM_FORMATTER",
"NO_ENCODER;NO_INSTR_INFO;NO_GAS_FORMATTER;NO_INTEL_FORMATTER;NO_NASM_FORMATTER",
"NO_ENCODER;NO_INSTR_INFO;NO_GAS_FORMATTER;NO_INTEL_FORMATTER;NO_MASM_FORMATTER"
) {
git clean -xdf
if ($LASTEXITCODE) { exit $LASTEXITCODE }
$env:MoreDefineConstants=$def
dotnet build -v:m -c Release src/csharp/Intel/Iced.UnitTests/Iced.UnitTests.csproj
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}
- name: Build, test
shell: pwsh
run: |
.\build.ps1
- name: upload-artifact doesn't support wildcards
shell: pwsh
run: |
New-Item -ItemType Directory nuget_files > $null
Copy-Item src\csharp\Intel\Iced\bin\Release\*.*nupkg nuget_files
- uses: actions/upload-artifact@v1
with:
name: nupkg
path: nuget_files
- uses: actions/upload-artifact@v1
with:
name: coverage.info
path: src/csharp/Intel/Iced.UnitTests/coverage.info
- name: Upload coverage report
shell: bash
run: |
curl https://codecov.io/bash -o codecov
chmod +x codecov
./codecov -f src/csharp/Intel/Iced.UnitTests/coverage.info
env:
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
- name: Upload to nuget.org if it's a new release
if: startsWith(github.ref, 'refs/tags/')
shell: pwsh
run: |
Invoke-WebRequest -Uri https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -UseBasicParsing -OutFile nuget.exe
Get-ChildItem src\csharp\Intel\Iced\bin\Release\Iced.*.nupkg | ForEach-Object { .\nuget.exe push $_.FullName -ApiKey ${{secrets.NUGET_APIKEY}} -NonInteractive -Source https://api.nuget.org/v3/index.json }
# Make sure it builds on Linux too
build-csharp:
name: C# (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.100'
- name: Build, test
shell: pwsh
run: ./build.ps1
build-rust:
name: Rust (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v1
- name: Install rustup and rustc latest (macOS)
shell: bash
if: startsWith(matrix.os, 'macos-')
run: |
curl https://sh.rustup.rs -sSf | bash -s -- -y
export PATH="$HOME/.cargo/bin:$PATH"
rustup install stable
- name: Install rustc
shell: bash
run: |
export PATH="$HOME/.cargo/bin:$PATH"
# It fails on Windows, disable auto self update
rustup toolchain install 1.20.0 --no-self-update
rustup toolchain install nightly --no-self-update
rustup update --no-self-update
- name: Build no_std
shell: bash
run: |
export PATH="$HOME/.cargo/bin:$PATH"
export RUSTFLAGS="-D warnings"
git clean -xdf
cd src/rust/iced-x86
echo ==== BUILD DEBUG ====
cargo build --color always --lib --no-default-features --features "no_std decoder encoder instr_info all_formatters"
cd ../../..
git clean -xdf
- name: Build one feature at a time
shell: bash
run: |
export PATH="$HOME/.cargo/bin:$PATH"
export RUSTFLAGS="-D warnings"
cargo -V
cd src/rust/iced-x86
echo ==== std decoder ====
cargo check --lib --no-default-features --features "std decoder"
echo ==== std encoder ====
cargo check --lib --no-default-features --features "std encoder"
echo ==== std instr_info ====
cargo check --lib --no-default-features --features "std instr_info"
echo ==== std gas_formatter ====
cargo check --lib --no-default-features --features "std gas_formatter"
echo ==== std intel_formatter ====
cargo check --lib --no-default-features --features "std intel_formatter"
echo ==== std masm_formatter ====
cargo check --lib --no-default-features --features "std masm_formatter"
echo ==== std nasm_formatter ====
cargo check --lib --no-default-features --features "std nasm_formatter"
echo ==== TEST std decoder ====
cargo check --tests --lib --no-default-features --features "std decoder"
echo ==== TEST std decoder encoder ====
cargo check --tests --lib --no-default-features --features "std decoder encoder"
echo ==== TEST std decoder instr_info ====
cargo check --tests --lib --no-default-features --features "std decoder instr_info"
echo ==== TEST std decoder gas_formatter ====
cargo check --tests --lib --no-default-features --features "std decoder gas_formatter"
echo ==== TEST std decoder intel_formatter ====
cargo check --tests --lib --no-default-features --features "std decoder intel_formatter"
echo ==== TEST std decoder masm_formatter ====
cargo check --tests --lib --no-default-features --features "std decoder masm_formatter"
echo ==== TEST std decoder nasm_formatter ====
cargo check --tests --lib --no-default-features --features "std decoder nasm_formatter"
cd ..
git clean -xdf
- name: Build, test (default)
shell: bash
run: |
export PATH="$HOME/.cargo/bin:$PATH"
export RUSTFLAGS="-D warnings"
cargo -V
cd src/rust/iced-x86
echo ==== CLIPPY ====
cargo clippy --color always
echo ==== CLIPPY --tests ====
cargo clippy --color always --tests
echo ==== FORMAT CHECK ====
cargo fmt -- --color always --check
echo ==== DOC ====
# Use nightly since that's what docs.rs uses
cargo +nightly doc
echo ==== BUILD DEBUG ====
cargo build --color always
echo ==== TEST DEBUG ====
cargo test --color always
echo ==== BUILD RELEASE ====
cargo build --color always --release
echo ==== TEST RELEASE ====
cargo test --color always --release
echo ==== PUBLISH DRY-RUN ====
# It fails on Windows without this, claiming that some random number of rust files are dirty.
# This is the 2nd GitHub CI for Windows hack I've added to this file.
git status
git diff
cargo publish --color always --dry-run
- name: Build, test (1.20.0)
shell: bash
run: |
export PATH="$HOME/.cargo/bin:$PATH"
export RUSTFLAGS="-D warnings"
cd src/rust/iced-x86
echo ==== UPDATE Cargo.lock ====
cargo +1.20.0 generate-lockfile
cargo +1.20.0 update --package lazy_static --precise 1.1.0
echo ==== BUILD DEBUG ====
cargo +1.20.0 build --color always
echo ==== TEST DEBUG ====
cargo +1.20.0 test --color always
echo ==== BUILD RELEASE ====
cargo +1.20.0 build --color always --release
echo ==== TEST RELEASE ====
cargo +1.20.0 test --color always --release