0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-12-26 09:13:46 -05:00
denoland-rusty-v8/.github/workflows/ci.yml

265 lines
10 KiB
YAML
Raw Normal View History

2019-10-31 21:01:29 -04:00
name: ci
on:
push:
branches: [main]
2022-06-15 08:04:35 -04:00
tags: ["**"]
pull_request:
branches: [main]
types: [labeled, opened, synchronize, reopened]
2019-10-31 21:01:29 -04:00
permissions: write-all
2019-10-31 21:01:29 -04:00
jobs:
build:
name: ${{ matrix.config.variant }} ${{ matrix.config.target }}
runs-on: ${{ matrix.config.os }}
timeout-minutes: 180
2019-10-31 21:01:29 -04:00
strategy:
# Always run main branch builds to completion. This allows the cache to
# stay mostly up-to-date in situations where a single job fails due to
# e.g. a flaky test.
# Don't fast-fail on tag build because publishing binaries shouldn't be
# prevented if 'cargo publish' fails (which can be a false negative).
fail-fast:
${{ (github.event_name == 'pull_request' || (github.ref !=
'refs/heads/main' && !startsWith(github.ref, 'refs/tags/'))) &&
!contains(github.event.pull_request.labels.*.name, 'no-fail-fast') }}
2019-10-31 21:01:29 -04:00
matrix:
config:
- os: macos-13
target: x86_64-apple-darwin
2020-04-04 22:10:55 -04:00
variant: debug
cargo: cargo
- os: macos-13
target: x86_64-apple-darwin
2020-04-04 22:10:55 -04:00
variant: release
cargo: cargo
2024-03-15 16:45:16 -04:00
- os: macos-14
target: aarch64-apple-darwin
variant: asan
cargo: cargo
2024-03-15 16:45:16 -04:00
- os: macos-14
target: aarch64-apple-darwin
variant: debug
cargo: cargo
2024-03-15 16:45:16 -04:00
- os: macos-14
target: aarch64-apple-darwin
variant: release
cargo: cargo
2022-05-18 04:53:34 -04:00
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
2020-04-04 22:10:55 -04:00
target: x86_64-unknown-linux-gnu
variant: debug
cargo: cargo
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
2020-04-04 22:10:55 -04:00
target: x86_64-unknown-linux-gnu
variant: release
cargo: cargo
2022-05-14 05:56:53 -04:00
- os: ${{ github.repository == 'denoland/rusty_v8' && 'windows-2019-xxl' || 'windows-2019' }}
target: x86_64-pc-windows-msvc
variant: release # Note: we do not support windows debug builds.
cargo: cargo
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
2021-02-19 05:56:11 -05:00
target: aarch64-unknown-linux-gnu
variant: debug
cargo: cargo
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
2021-02-19 05:56:11 -05:00
target: aarch64-unknown-linux-gnu
variant: release
cargo: cargo
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
target: aarch64-linux-android
variant: debug
cargo: cross
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
target: aarch64-linux-android
variant: release
cargo: cross
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
target: x86_64-linux-android
variant: debug
cargo: cross
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
target: x86_64-linux-android
variant: release
cargo: cross
env:
V8_FROM_SOURCE: true
CARGO_VARIANT_FLAG: ${{ matrix.config.variant == 'release' && '--release' || '' }}
LIB_NAME: ${{ contains(matrix.config.target, 'windows') && 'rusty_v8' || 'librusty_v8' }}
LIB_EXT: ${{ contains(matrix.config.target, 'windows') && 'lib' || 'a' }}
2021-05-03 15:19:03 -04:00
RUSTFLAGS: -D warnings
2019-10-31 21:01:29 -04:00
steps:
- name: Configure git
run: git config --global core.symlinks true
- name: Clone repository
2024-03-01 12:28:17 -05:00
uses: actions/checkout@v4
2019-10-31 21:01:29 -04:00
with:
fetch-depth: 10
2020-04-04 22:10:55 -04:00
submodules: recursive
2019-10-31 21:01:29 -04:00
- name: Install rust
2024-03-01 12:28:17 -05:00
uses: dsherret/rust-toolchain-file@v1
2019-10-31 21:01:29 -04:00
- name: Install python
uses: actions/setup-python@v4
with:
python-version: 3.11.x
architecture: x64
2019-11-01 17:28:09 -04:00
- name: Install cross compilation toolchain
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
run: |
rustup target add aarch64-unknown-linux-gnu
sudo apt update
sudo apt install -yq --no-install-suggests --no-install-recommends \
binfmt-support g++-10-aarch64-linux-gnu g++-10-multilib \
gcc-10-aarch64-linux-gnu libc6-arm64-cross qemu qemu-user \
qemu-user-binfmt
sudo ln -s /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 \
/lib/ld-linux-aarch64.so.1
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc-10" >> ${GITHUB_ENV}
echo "QEMU_LD_PREFIX=/usr/aarch64-linux-gnu" >> ${GITHUB_ENV}
- name: Write git_submodule_status.txt
run: git submodule status --recursive > git_submodule_status.txt
- name: Install cross and build custom image
if: contains(matrix.config.target, 'linux-android')
run: |
mkdir -p /home/runner/.local/bin
curl -qL https://github.com/cross-rs/cross/releases/download/v0.2.5/cross-x86_64-unknown-linux-musl.tar.gz | tar xz -C /home/runner/.local/bin
sudo docker build --build-arg CROSS_BASE_IMAGE=ghcr.io/cross-rs/${{ matrix.config.target }}:0.2.5 -t cross-rusty_v8:${{ matrix.config.target }} .
- name: Cache
uses: actions/cache@v3
with:
# Note: rusty_v8 targets always get get rebuilt, and their outputs
# ('librusty_v8.rlib', the whole 'gn_out' directory, etc.) can be
# quite big, so we cache only those subdirectories of
# target/{debug|release} that contain the build output for crates that
# come from the registry. By additionally saving the sccache cache
# directory it's still possible to build v8 fast.
path: |-
target/sccache
target/*/.*
target/*/build
target/*/deps
key:
cargo-${{ matrix.config.target }}-${{ matrix.config.variant }}-${{ hashFiles('Cargo.lock', 'build.rs', 'git_submodule_status.txt') }}
restore-keys:
cargo-${{ matrix.config.target }}-${{ matrix.config.variant }}-
- name: Install and start sccache
shell: pwsh
2019-10-31 21:01:29 -04:00
env:
SCCACHE_DIR: ${{ github.workspace }}/target/sccache
SCCACHE_CACHE_SIZE: 128M
2019-10-31 21:01:29 -04:00
SCCACHE_IDLE_TIMEOUT: 0
run: |
$version = "0.2.12"
$platform =
@{ "macOS" = "x86_64-apple-darwin"
"Linux" = "x86_64-unknown-linux-musl"
"Windows" = "x86_64-pc-windows-msvc"
}.${{ runner.os }}
$basename = "sccache-$version-$platform"
$url = "https://github.com/mozilla/sccache/releases/download/" +
"$version/$basename.tar.gz"
cd ~
curl -LO $url
tar -xzvf "$basename.tar.gz"
. $basename/sccache --start-server
echo "$(pwd)/$basename" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install Rust (nightly)
uses: dtolnay/rust-toolchain@nightly
if: matrix.config.variant == 'asan'
- name: Test (ASAN)
env:
SCCACHE_IDLE_TIMEOUT: 0
if: matrix.config.variant == 'asan'
# https://github.com/rust-lang/rust/issues/87215
run: |
rustup component add rust-src --toolchain nightly-${{ matrix.config.target }}
# Is there a better way to install this tool?
curl -O http://commondatastorage.googleapis.com/chromium-browser-clang-staging/Mac/dsymutil-llvmorg-17-init-19076-g5533fc10-1.tgz
tar -C tools/clang/dsymutil/ -xvzf dsymutil-llvmorg-17-init-19076-g5533fc10-1.tgz
V8_FROM_SOURCE=true RUSTFLAGS="-C opt-level=1 -Zsanitizer=address" cargo +nightly -Z build-std test --lib --bins --tests -vv --target ${{ matrix.config.target }}
- name: Test
env:
SCCACHE_IDLE_TIMEOUT: 0
if: matrix.config.variant == 'debug' || matrix.config.variant == 'release'
run:
${{ matrix.config.cargo }} test -vv --all-targets --locked ${{ env.CARGO_VARIANT_FLAG }}
--target ${{ matrix.config.target }}
- name: Clippy
run:
${{ matrix.config.cargo }} clippy --all-targets --locked ${{ env.CARGO_VARIANT_FLAG }}
--target ${{ matrix.config.target }} -- -D clippy::all
2019-11-01 00:54:54 -04:00
- name: Rustfmt
run: cargo fmt -- --check
- name: Prepare binary publish
if: matrix.config.variant == 'debug' || matrix.config.variant == 'release'
run: gzip -9c
target/${{ matrix.config.target }}/${{ matrix.config.variant }}/gn_out/obj/${{ env.LIB_NAME }}.${{ env.LIB_EXT }} >
target/${{ env.LIB_NAME }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz &&
ls -l target/${{ env.LIB_NAME }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz
- name: Binary publish
2022-12-12 20:07:14 -05:00
uses: softprops/action-gh-release@v0.1.15
if: >-
github.repository == 'denoland/rusty_v8' &&
startsWith(github.ref, 'refs/tags/') &&
(matrix.config.variant == 'debug' || matrix.config.variant == 'release')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: target/${{ env.LIB_NAME }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz
# TODO: add clang-format and maybe cpplint.
2021-07-02 14:06:51 -04:00
- name: Cargo Package
if: >-
github.repository == 'denoland/rusty_v8' &&
startsWith(matrix.config.target , 'x86_64') &&
matrix.config.variant == 'debug' &&
runner.os == 'Linux'
run: cargo package -vv --locked
2019-12-04 01:45:50 -05:00
- name: Publish
# Only publish on x64 linux when there's a git tag:
2020-04-04 22:10:55 -04:00
if: >-
startsWith(github.ref, 'refs/tags/') &&
github.repository == 'denoland/rusty_v8' &&
startsWith(matrix.config.target , 'x86_64') &&
matrix.config.variant == 'debug' &&
runner.os == 'Linux'
2019-12-04 01:45:50 -05:00
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish -vv