Skip to content

Commit 5fe4b06

Browse files
authored
Merge pull request #138 from zkcrypto/ci-overhaul
CI overhaul
2 parents 17973bd + 1d844eb commit 5fe4b06

6 files changed

Lines changed: 119 additions & 77 deletions

File tree

.github/workflows/ci.yml

Lines changed: 71 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,92 @@
11
name: CI checks
22

3-
on: [push, pull_request]
3+
on:
4+
pull_request:
5+
push:
6+
branches: main
47

58
jobs:
6-
lint:
7-
name: Lint
8-
runs-on: ubuntu-latest
9-
9+
test-msrv:
10+
name: Test MSRV on ${{ matrix.os }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, windows-latest, macOS-latest]
1015
steps:
11-
- uses: actions/checkout@v1
12-
- uses: actions-rs/toolchain@v1
13-
with:
14-
toolchain: 1.56.0
15-
override: true
16-
17-
# Ensure all code has been formatted with rustfmt
18-
- run: rustup component add rustfmt
19-
- name: Check formatting
20-
uses: actions-rs/cargo@v1
21-
with:
22-
command: fmt
23-
args: -- --check --color always
16+
- uses: actions/checkout@v4
17+
- name: Run tests
18+
run: cargo test --verbose --all-features
19+
- name: Verify working directory is clean
20+
run: git diff --exit-code
2421

25-
test:
26-
name: Test on ${{ matrix.os }}
22+
test-latest:
23+
name: Test latest on ${{ matrix.os }}
2724
runs-on: ${{ matrix.os }}
2825
strategy:
2926
matrix:
3027
os: [ubuntu-latest, windows-latest, macOS-latest]
31-
3228
steps:
33-
- uses: actions/checkout@v1
34-
- uses: actions-rs/toolchain@v1
35-
with:
36-
toolchain: 1.56.0
37-
override: true
38-
- name: cargo fetch
39-
uses: actions-rs/cargo@v1
40-
with:
41-
command: fetch
42-
- name: Build tests
43-
uses: actions-rs/cargo@v1
44-
with:
45-
command: build
46-
args: --verbose --release --tests
29+
- uses: actions/checkout@v4
30+
- uses: dtolnay/rust-toolchain@stable
31+
id: toolchain
32+
- run: rustup override set ${{steps.toolchain.outputs.name}}
33+
- name: Remove lockfile to build with latest dependencies
34+
run: rm Cargo.lock
4735
- name: Run tests
48-
uses: actions-rs/cargo@v1
49-
with:
50-
command: test
51-
args: --verbose --release
36+
run: cargo test --verbose --all-features
37+
- name: Verify working directory is clean (excluding lockfile)
38+
run: git diff --exit-code ':!Cargo.lock'
5239

53-
no-std:
54-
name: Check no-std compatibility
40+
build-nodefault:
41+
name: Build target ${{ matrix.target }}
5542
runs-on: ubuntu-latest
56-
43+
strategy:
44+
matrix:
45+
target:
46+
- wasm32-wasi
47+
- thumbv6m-none-eabi
48+
- thumbv7em-none-eabihf
5749
steps:
58-
- uses: actions/checkout@v1
59-
- uses: actions-rs/toolchain@v1
50+
- uses: actions/checkout@v4
6051
with:
61-
toolchain: 1.56.0
62-
override: true
63-
- run: rustup target add thumbv6m-none-eabi
64-
- name: cargo fetch
65-
uses: actions-rs/cargo@v1
66-
with:
67-
command: fetch
68-
- name: Build
69-
uses: actions-rs/cargo@v1
70-
with:
71-
command: build
72-
args: --verbose --target thumbv6m-none-eabi --no-default-features
52+
path: crate_root
53+
# We use a synthetic crate to ensure no dev-dependencies are enabled, which can
54+
# be incompatible with some of these targets.
55+
- name: Create synthetic crate for testing
56+
run: cargo init --edition 2021 --lib ci-build
57+
- name: Copy Rust version into synthetic crate
58+
run: cp crate_root/rust-toolchain.toml ci-build/
59+
- name: Copy patch directives into synthetic crate
60+
run: |
61+
echo "[patch.crates-io]" >> ./ci-build/Cargo.toml
62+
cat ./crate_root/Cargo.toml | sed "0,/.\+\(patch.crates.\+\)/d" >> ./ci-build/Cargo.toml
63+
- name: Add no_std pragma to lib.rs
64+
run: |
65+
echo "#![no_std]" > ./ci-build/src/lib.rs
66+
- name: Add pairing as a dependency of the synthetic crate
67+
working-directory: ./ci-build
68+
# run: cargo add --no-default-features --path ../crate_root
69+
run: sed -i 's;\[dependencies\];\[dependencies\]\npairing = { path = "../crate_root", default-features = false };g' ./Cargo.toml
70+
- name: Add target
71+
working-directory: ./ci-build
72+
run: rustup target add ${{ matrix.target }}
73+
- name: Build for target
74+
working-directory: ./ci-build
75+
run: cargo build --verbose --target ${{ matrix.target }}
7376

7477
doc-links:
75-
name: Nightly lint
78+
name: Intra-doc links
7679
runs-on: ubuntu-latest
77-
7880
steps:
79-
- uses: actions/checkout@v1
80-
- uses: actions-rs/toolchain@v1
81-
with:
82-
toolchain: nightly
83-
override: true
84-
- name: cargo fetch
85-
uses: actions-rs/cargo@v1
86-
with:
87-
command: fetch
88-
89-
# Ensure intra-documentation links all resolve correctly
90-
# Requires #![deny(intra_doc_link_resolution_failure)] in crate.
81+
- uses: actions/checkout@v4
82+
- run: cargo fetch
83+
# Requires #![deny(rustdoc::broken_intra_doc_links)] in crates.
9184
- name: Check intra-doc links
92-
uses: actions-rs/cargo@v1
93-
with:
94-
command: doc
95-
args: --document-private-items
85+
run: cargo doc --all-features --document-private-items
86+
87+
fmt:
88+
name: Rustfmt
89+
runs-on: ubuntu-latest
90+
steps:
91+
- uses: actions/checkout@v4
92+
- run: cargo fmt -- --check

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
target/
22
**/*.rs.bk
3-
Cargo.lock

Cargo.lock

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
name = "pairing"
33
version = "0.23.0"
44
authors = ["Sean Bowe <ewillbefull@gmail.com>", "Jack Grigg <jack@z.cash>"]
5+
edition = "2021"
6+
rust-version = "1.56"
57
readme = "README.md"
68
license = "MIT/Apache-2.0"
79

810
description = "Pairing-friendly elliptic curve library"
911
documentation = "https://docs.rs/pairing/"
1012
homepage = "https://github.com/zkcrypto/pairing"
1113
repository = "https://github.com/zkcrypto/pairing"
12-
edition = "2021"
1314

1415
[dependencies]
1516
group = { version = "0.13", default-features = false }

rust-toolchain

Lines changed: 0 additions & 1 deletion
This file was deleted.

rust-toolchain.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "1.56.0"
3+
components = [ "clippy", "rustfmt" ]

0 commit comments

Comments
 (0)