feat(ci): cross-compile release assets, cache deps (#128)

* feat(ci): cross-compile release assets, cache deps

chore(ci): add caching to regular tests

* fix(ci): include cross only in ci env, add note about release assets
This commit is contained in:
Aaryamann Challani 2023-03-14 17:44:06 +05:30 committed by GitHub
parent c319f32a1e
commit bb7dfb80ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 75 additions and 44 deletions

View File

@ -46,10 +46,9 @@ jobs:
profile: minimal profile: minimal
toolchain: stable toolchain: stable
override: true override: true
- name: Update git submodules - uses: Swatinem/rust-cache@v2
run: git submodule update --init --recursive - name: Install dependencies
- name: Install cargo-make run: make installdeps
run: cargo install cargo-make
- name: cargo-make test - name: cargo-make test
run: | run: |
cargo make test --release cargo make test --release
@ -72,10 +71,9 @@ jobs:
profile: minimal profile: minimal
toolchain: stable toolchain: stable
override: true override: true
- name: Update git submodules - uses: Swatinem/rust-cache@v2
run: git submodule update --init --recursive - name: Install Dependencies
- name: Install cargo-make run: make installdeps
run: cargo install cargo-make
- name: cargo-make test - name: cargo-make test
run: | run: |
cargo make test --release cargo make test --release
@ -97,10 +95,11 @@ jobs:
profile: minimal profile: minimal
toolchain: stable toolchain: stable
override: true override: true
- run: git submodule update --init --recursive - uses: Swatinem/rust-cache@v2
- name: Install Dependencies
run: make installdeps
- name: Install wasm-pack - name: Install wasm-pack
uses: jetli/wasm-pack-action@v0.3.0 uses: jetli/wasm-pack-action@v0.3.0
- run: cargo install cargo-make
- run: cargo make build - run: cargo make build
working-directory: rln-wasm working-directory: rln-wasm
- run: cargo-make test - run: cargo-make test
@ -123,10 +122,9 @@ jobs:
profile: minimal profile: minimal
toolchain: stable toolchain: stable
override: true override: true
- name: Update git submodules - uses: Swatinem/rust-cache@v2
run: git submodule update --init --recursive - name: Install Dependencies
- name: Install cargo-make run: make installdeps
run: cargo install cargo-make
- name: cargo-make test - name: cargo-make test
run: | run: |
cargo make test --release cargo make test --release
@ -149,10 +147,9 @@ jobs:
profile: minimal profile: minimal
toolchain: stable toolchain: stable
override: true override: true
- name: Update git submodules - uses: Swatinem/rust-cache@v2
run: git submodule update --init --recursive - name: Install Dependencies
- name: Install cargo-make run: make installdeps
run: cargo install cargo-make
- name: cargo-make test - name: cargo-make test
run: | run: |
cargo make test --release cargo make test --release
@ -177,8 +174,9 @@ jobs:
toolchain: stable toolchain: stable
override: true override: true
components: rustfmt, clippy components: rustfmt, clippy
- name: Update git submodules - uses: Swatinem/rust-cache@v2
run: git submodule update --init --recursive - name: Install Dependencies
run: make installdeps
- name: cargo fmt - name: cargo fmt
if: success() || failure() if: success() || failure()
run: cargo fmt --all -- --check run: cargo fmt --all -- --check

View File

@ -10,9 +10,8 @@ jobs:
matrix: matrix:
target: target:
- x86_64-unknown-linux-gnu - x86_64-unknown-linux-gnu
# TODO: enable after https://github.com/rust-lang/cargo/issues/4133 is resolved - aarch64-unknown-linux-gnu
# - aarch64-unknown-linux-gnu - i686-unknown-linux-gnu
# - i686-unknown-linux-gnu
name: Linux build name: Linux build
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -25,11 +24,12 @@ jobs:
toolchain: stable toolchain: stable
override: true override: true
target: ${{ matrix.target }} target: ${{ matrix.target }}
- name: Update git submodules - uses: Swatinem/rust-cache@v2
run: git submodule update --init --recursive - name: Install dependencies
- name: cargo build run: make installdeps
- name: cross build
run: | run: |
cargo build --release --target ${{ matrix.target }} --workspace --exclude rln-wasm cross build --release --target ${{ matrix.target }} --workspace --exclude rln-wasm
mkdir release mkdir release
cp target/${{ matrix.target }}/release/librln* release/ cp target/${{ matrix.target }}/release/librln* release/
tar -czvf ${{ matrix.target }}-rln.tar.gz release/ tar -czvf ${{ matrix.target }}-rln.tar.gz release/
@ -48,13 +48,10 @@ jobs:
matrix: matrix:
target: target:
- x86_64-apple-darwin - x86_64-apple-darwin
# TODO: enable after https://github.com/rust-lang/cargo/issues/4133 is resolved - aarch64-apple-darwin
# - aarch64-apple-darwin
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
with:
ref: master
- name: Install stable toolchain - name: Install stable toolchain
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
@ -62,11 +59,12 @@ jobs:
toolchain: stable toolchain: stable
override: true override: true
target: ${{ matrix.target }} target: ${{ matrix.target }}
- name: Update git submodules - uses: Swatinem/rust-cache@v2
run: git submodule update --init --recursive - name: Install dependencies
- name: cargo build run: make installdeps
- name: cross build
run: | run: |
cargo build --release --target ${{ matrix.target }} --workspace --exclude rln-wasm cross build --release --target ${{ matrix.target }} --workspace --exclude rln-wasm
mkdir release mkdir release
cp target/${{ matrix.target }}/release/librln* release/ cp target/${{ matrix.target }}/release/librln* release/
tar -czvf ${{ matrix.target }}-rln.tar.gz release/ tar -czvf ${{ matrix.target }}-rln.tar.gz release/
@ -84,22 +82,20 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
with:
ref: master
- name: Install stable toolchain - name: Install stable toolchain
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
profile: minimal profile: minimal
toolchain: stable toolchain: stable
override: true override: true
- run: git submodule update --init --recursive - uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: make installdeps
- name: Install wasm-pack - name: Install wasm-pack
uses: jetli/wasm-pack-action@v0.3.0 uses: jetli/wasm-pack-action@v0.3.0
- name: Install cargo-make - name: cross make build
run: cargo install cargo-make
- name: cargo make build
run: | run: |
cargo make build cross make build
mkdir release mkdir release
cp pkg/** release/ cp pkg/** release/
tar -czvf browser-rln-wasm.tar.gz release/ tar -czvf browser-rln-wasm.tar.gz release/

32
Cross.toml Normal file
View File

@ -0,0 +1,32 @@
[target.x86_64-pc-windows-gnu]
image = "ghcr.io/cross-rs/x86_64-pc-windows-gnu:latest"
[target.aarch64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:latest"
[target.x86_64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:latest"
[target.arm-unknown-linux-gnueabi]
image = "ghcr.io/cross-rs/arm-unknown-linux-gnueabi:latest"
[target.i686-pc-windows-gnu]
image = "ghcr.io/cross-rs/i686-pc-windows-gnu:latest"
[target.i686-unknown-linux-gnu]
image = "ghcr.io/cross-rs/i686-unknown-linux-gnu:latest"
[target.arm-unknown-linux-gnueabihf]
image = "ghcr.io/cross-rs/arm-unknown-linux-gnueabihf:latest"
[target.mips-unknown-linux-gnu]
image = "ghcr.io/cross-rs/mips-unknown-linux-gnu:latest"
[target.mips64-unknown-linux-gnuabi64]
image = "ghcr.io/cross-rs/mips64-unknown-linux-gnuabi64:latest"
[target.mips64el-unknown-linux-gnuabi64]
image = "ghcr.io/cross-rs/mips64el-unknown-linux-gnuabi64:latest"
[target.mipsel-unknown-linux-gnu]
image = "ghcr.io/cross-rs/mipsel-unknown-linux-gnu:latest"

View File

@ -6,8 +6,9 @@ all: .pre-build build
@git submodule update --init --recursive @git submodule update --init --recursive
.pre-build: .fetch-submodules .pre-build: .fetch-submodules
ifeq (, $(shell which cargo-make)) @cargo install cargo-make
@cargo install --force cargo-make ifdef CI
@cargo install cross --git https://github.com/cross-rs/cross --branch main
endif endif
installdeps: .pre-build installdeps: .pre-build

View File

@ -29,3 +29,7 @@ To build and test all crates, run the following commands from the root folder
make build make build
make test make test
``` ```
## Release assets
We use [`cross-rs`](https://github.com/cross-rs/cross) to cross-compile and generate release assets for rln.