Skip to content

Commit

Permalink
Use stable channel rust and enable feature(asm_const) by condition (#4
Browse files Browse the repository at this point in the history
)

* feat: use stable channle rust and enable `feature(asm_const)` by condition

* ci: add stable and nightly build and test

* fix: use macro param instead of unspecified constants

* feat: throw error if the arch is not supported when feature `asm` is enabled

* ci: enable test for PR and push to main

* ci: fix
  • Loading branch information
han0110 authored Sep 19, 2022
1 parent f75ed26 commit 83c72d4
Show file tree
Hide file tree
Showing 12 changed files with 518 additions and 120 deletions.
43 changes: 29 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,58 @@
name: CI Check
on:
pull_request:
branches: [ master ]
push:
branches:
- main

jobs:
build:
if: github.event.pull_request.draft == false
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
include:
- rust: 1.63.0
feature: default
- rust: nightly
feature: asm

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
override: false
- name: Build all features
override: true
toolchain: ${{ matrix.rust }}
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --all-features
args: --features ${{ matrix.feature }}

test:
if: github.event.pull_request.draft == false
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
include:
- rust: 1.63.0
feature: default
- rust: nightly
feature: asm

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
override: false
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- name: Build
override: true
toolchain: ${{ matrix.rust }}
- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: --verbose --release --all --all-features
args: --verbose --release --all --features ${{ matrix.feature }}

fmt:
if: github.event.pull_request.draft == false
Expand All @@ -47,8 +63,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
override: false
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
Expand All @@ -64,13 +78,14 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
override: false
- name: bench arithmetic
override: true
toolchain: nightly
- name: Bench arithmetic
uses: actions-rs/cargo@v1
with:
command: test
args: --profile bench test_field -- --nocapture
- name: bench assembly arithmetic
- name: Bench assembly arithmetic
uses: actions-rs/cargo@v1
with:
command: test
Expand Down
7 changes: 7 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fn main() {
#[cfg(feature = "asm")]
if std::env::consts::ARCH != "x86_64" {
eprintln!("Currently feature `asm` can only be enabled on x86_64 arch.");
std::process::exit(1);
}
}
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2021-11-17
1.63.0
Loading

0 comments on commit 83c72d4

Please sign in to comment.