Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Commit

Permalink
Provide static libraries as artifacts (#387)
Browse files Browse the repository at this point in the history
* Add no_mangle to svm_init

* Provide static libs as artifacts

* Fix .a file on Linux

* Simplify CI definition

* Fix Rust cache in test

* Fix use of Rust cache

* Remove unnecessary cache key and fix lib name on windows

* Remove minor version from maplit

* Unify artifact steps

* Remove test dependency from build step

* Move doc step from test to lints

* Fix Cargo fmt call

* Add cache to doc step

* Copy target files, don't move

* Add -p flag to mkdir

* Remove useless rustdoc dep

* Remove caching step for tests

* Remove name of step

* Add cache-on-failure behavior

* Clear cache monthly

* Add names to some steps

* Improve comment

* Remove automake for macOS

* Don't hardcode rustc profile "release"

* Add matrix.os as key to rust cache

* Add matrix.os cache for builds too

* Remove matrix.os cache key

* Remove wasm cache key

* Add dummy cache key for tests

* Only test svm-sdk-test

* Remove monthly cache clear

* Separate cache key for tests

* Switch back to testing all crates

* Switch back to only testing svm-sdk-tests

* Add default-cranelift feature

* Specify matrix profile in test

* Fix yaml syntax

* Fix cargo profile in test

* Add back nocapture to tests

* Test only svm-sdk-tests

* Remove cache for tests

* Add back test cache with another key

* Add explanatory comment

* remove tests key

* Test in build step as well

* Remove llvm cache windows

* Cache on failure for tests

* Cargo unify builds

* Shorten build times

* Test with default features

* Switch back to no-default-features

* Remove test cache

* Only test svm-sdk-tests

* Switch to testing all

* Add default-cranelift

* Add back test caching

* Disable cache on Windows

* Set Rust toolchain as default

* Remove .toml extension to rust-toolchain

* Remove profiles

* Try using raw rustup

* Fix formatting

* Disable caching on Windows

* Add empty line

* Enable test cache with build step before that

* Remove debug flag

* Rename rust-toolchain with rust-toolchain.toml

* Use custom caching

* Fix key

* Use custom caching even for wasm

* Replace the paths with suggested ones

* Add cargo to cache

* Add empty line

* Fix formatting

* Fix formatting

* Change cached paths

* More atomic cache keys

* Replace key suffix with job name

* Add explanatory comment

* Remove cache of lints

* Add separate doc job
  • Loading branch information
neysofu authored Sep 27, 2021
1 parent 8dd0cba commit 76be2e2
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 137 deletions.
225 changes: 89 additions & 136 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
name: SVM CI

# On Rust caching
# ---------------
# <https://github.com/Swatinem/rust-cache> is a very attractive alternative to
# rolling your own caching solution, but it's not very effective for Rust
# nightly and it throws away intermediate compilation artifacts, which might
# result in linkage bugs...

on:
push:
branches:
Expand All @@ -18,90 +25,50 @@ jobs:
fail-fast: False
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
profile: ["release"]
profile: [release]
include:
- os: ubuntu-latest
lib_name: libsvm
static: a
shared: so
- os: macos-latest
lib_name: libsvm
static: a
shared: dylib
- os: windows-latest
lib_name: svm
static: lib
shared: dll
steps:
- name: Automake (macOS)
if: matrix.os == 'macos-latest'
run: |
set -e
brew update
brew install automake
- name: Cache LLVM (Windows)
if: matrix.os == 'windows-latest'
id: cache-llvm-windows
uses: actions/cache@v2
with:
path: |
C:\\Temp\\chocolatey\llvm
C:\\Program Files\\LLVM\bin
key: llvm-windows
- name: Install LLVM (Windows)
if: matrix.os == 'windows-latest' && steps.cache-llvm-windows.outputs.cache-hit != 'true'
run: |
choco config set cacheLocation C:\\Temp\\chocolatey
choco install llvm -y
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Cache Cargo Registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
key: build-${{ runner.os }}-${{ matrix.profile }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
build-${{ runner.os }}-${{ matrix.profile }}-cargo-registry-
- name: Cache Cargo Index
uses: actions/cache@v2
with:
path: ~/.cargo/git
key: build-${{ runner.os }}-${{ matrix.profile }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
build-${{ runner.os }}-${{ matrix.profile }}-cargo-index-
- name: Cache Cargo Build
uses: actions/cache@v2
with:
path: target/${{ matrix.profile }}
key: build-${{ runner.os }}-${{ matrix.profile }}-nightly-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
build-${{ runner.os }}-${{ matrix.profile }}-nightly-target-
- name: Install Rust
run: rustup update nightly
- name: Cargo Build
uses: actions-rs/cargo@v1
run: |
rustup update nightly
rustup default nightly
- uses: actions/cache@v2
with:
toolchain: nightly
command: build
args: --${{ matrix.profile }} --package svm-runtime-ffi --features=default-cranelift --no-default-features
- name: Cargo Build CLI
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/
./target/
key: ${{ runner.os }}-cargo-${{ github.job }}
- name: Cargo Build
uses: actions-rs/cargo@v1
with:
toolchain: nightly
command: build
args: --${{ matrix.profile }} --package svm-cli
- name: Prepare Artifact (General)
run: |
set -e
mkdir bins
mv target/${{ matrix.profile }}/svm.h bins/svm.h
- name: Prepare Artifact (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
set -e
mv target/${{ matrix.profile }}/libsvm_runtime_ffi.so bins/libsvm.so
mv target/${{ matrix.profile }}/svm-cli bins/svm-cli
- name: Prepare Artifact (macOS)
if: matrix.os == 'macos-latest'
run: |
set -e
mv target/${{ matrix.profile }}/libsvm_runtime_ffi.dylib bins/libsvm.dylib
mv target/${{ matrix.profile }}/svm-cli bins/svm-cli
- name: Prepare Artifact (Windows)
if: matrix.os == 'windows-latest'
args: --${{ matrix.profile }} -p svm-runtime-ffi -p svm-cli --features=default-cranelift --no-default-features
- name: Prepare Artifacts
run: |
set -e
mv target/${{ matrix.profile }}/svm_runtime_ffi.dll bins/svm.dll
mv target/${{ matrix.profile }}/svm-cli bins/svm-cli
mkdir -p bins
cp target/${{ matrix.profile }}/${{ matrix.lib_name }}_runtime_ffi.${{ matrix.shared }} bins/${{ matrix.lib_name }}.${{ matrix.shared }}
cp target/${{ matrix.profile }}/${{ matrix.lib_name }}_runtime_ffi.${{ matrix.static }} bins/${{ matrix.lib_name }}.${{ matrix.static }}
cp target/${{ matrix.profile }}/svm-cli bins/svm-cli
cp target/${{ matrix.profile }}/svm.h bins/svm.h
- name: Upload Artifacts
uses: actions/upload-artifact@master
with:
Expand All @@ -118,47 +85,29 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Cache Cargo Registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
key: test-${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
test-${{ runner.os }}-cargo-registry-
- name: Cache Cargo Index
uses: actions/cache@v2
with:
path: ~/.cargo/git
key: test-${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
test-${{ runner.os }}-cargo-index-
- name: Cache Cargo Test
uses: actions/cache@v2
with:
path: target/tests
key: test-${{ runner.os }}-${{ matrix.profile }}-nightly-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
test-${{ runner.os }}-${{ matrix.profile }}-nightly-target-
- name: Install Rust
run: rustup update nightly
run: |
rustup update nightly
rustup default nightly
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/
./target/
key: ${{ runner.os }}-cargo-${{ github.job }}
- name: Cargo Test
uses: actions-rs/cargo@v1
with:
toolchain: nightly
command: test
args: --all --features=default-cranelift --no-default-features -- --nocapture
components: rustdoc
- name: Run `cargo doc`
uses: actions-rs/cargo@v1
with:
command: doc
args: --all
wasm_codec:
runs-on: macos-latest
runs-on: ubuntu-latest
strategy:
fail-fast: False
matrix:
profile: ["release"]
profile: [release]
defaults:
run:
shell: bash
Expand All @@ -171,31 +120,19 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Cache Cargo Registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
key: codec-${{ runner.os }}-${{ matrix.profile }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
codec-${{ runner.os }}-${{ matrix.profile }}-cargo-registry-
- name: Cache Cargo Index
uses: actions/cache@v2
with:
path: ~/.cargo/git
key: codec-${{ runner.os }}-${{ matrix.profile }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
codec-${{ runner.os }}-${{ matrix.profile }}-cargo-index-
- name: Cache Cargo wasm32
uses: actions/cache@v2
with:
path: target/wasm32-unknown-unknown
key: codec-${{ runner.os }}-${{ matrix.profile }}-nightly-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
codec-${{ runner.os }}-${{ matrix.profile }}-nightly-target-
- name: Install Rust
run: |
rustup update nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
rustup default nightly
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/
./target/
key: ${{ runner.os }}-cargo-${{ github.job }}
- name: Test svm-codec
working-directory: crates/codec/examples
run: |
Expand All @@ -205,24 +142,40 @@ jobs:
uses: actions/upload-artifact@master
with:
name: svm_codec.wasm
path: target/wasm32-unknown-unknown/release/svm_codec.wasm
lints:
path: target/wasm32-unknown-unknown/${{ matrix.profile }}/svm_codec.wasm
cargo-fmt:
runs-on: ubuntu-latest
strategy:
fail-fast: False
matrix:
profile: [release]
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rustfmt
- name: Install Rust
run: |
rustup update nightly
rustup default nightly
- name: Run `cargo fmt`
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
cargo-doc:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install Rust
run: |
rustup update nightly
rustup default nightly
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/
./target/
key: ${{ runner.os }}-cargo-${{ github.job }}
- name: Run `cargo doc`
uses: actions-rs/cargo@v1
with:
command: doc
args: --workspace --no-deps
2 changes: 1 addition & 1 deletion crates/gas/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ thiserror = "1"

[dev-dependencies]
wat = "1"
maplit = "1.0.2"
maplit = "1"

0 comments on commit 76be2e2

Please sign in to comment.