Skip to content

Commit c56740f

Browse files
committed
Action build and test + audit
1 parent 45a1f9b commit c56740f

File tree

8 files changed

+236
-1
lines changed

8 files changed

+236
-1
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 'publish-rust'
2+
description: 'Publishes Rust library to crates.io'
3+
inputs:
4+
crates-token:
5+
description: 'used for authenticating towards crates.io'
6+
required: true
7+
version:
8+
description: 'the version to release under (e.g. `1.2.3-dev.1`)'
9+
required: true
10+
dry-run:
11+
description: "'true' = only log potential result; 'false' = publish'"
12+
required: true
13+
runs:
14+
using: "composite"
15+
steps:
16+
- name: Setup Rust
17+
uses: './.github/actions/rust/rust-setup'
18+
with:
19+
os: ${{ runner.os }}
20+
job: ${{ github.job }}
21+
22+
- name: Install cargo-release
23+
shell: bash
24+
run: cargo install cargo-release
25+
26+
- name: Publish library to crates.io
27+
shell: bash
28+
run: |
29+
echo "dry-run: '${{ inputs.dry-run }}'"
30+
echo "version: '${{ inputs.version }}'"
31+
cargo release --workspace --token ${{ inputs.crates-token }} --isolated --no-dev-version --no-push --no-tag --dependent-version error --verbose $(if [ "${{ inputs.dry-run }}" = "false" ]; then echo --execute --no-confirm; fi) ${{ inputs.version }}

.github/workflows/audit.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Audit
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "**/Cargo.lock"
9+
- "**/Cargo.toml"
10+
- ".github/workflows/audit.yml"
11+
- ".cargo/audit.toml"
12+
pull_request:
13+
branches:
14+
- main
15+
paths:
16+
- "**/Cargo.lock"
17+
- "**/Cargo.toml"
18+
- ".github/workflows/audit.yml"
19+
- ".cargo/audit.toml"
20+
21+
jobs:
22+
audit:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v3
26+
- uses: actions-rs/audit-check@v1
27+
with:
28+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/build-and-test.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build and run tests Ubuntu
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [ opened, synchronize, reopened, ready_for_review ]
9+
branches:
10+
- main
11+
- 'epic/**'
12+
- 'support/**'
13+
paths:
14+
- '.github/workflows/build-and-test.yml'
15+
- '.github/actions/**'
16+
- '**.rs'
17+
- '**.toml'
18+
19+
env:
20+
RUST_BACKTRACE: full
21+
22+
jobs:
23+
check-for-run-condition:
24+
runs-on: ubuntu-latest
25+
outputs:
26+
should-run: ${{ !github.event.pull_request || github.event.pull_request.draft == false }}
27+
steps:
28+
- run: |
29+
# this run step does nothing, but is needed to get the job output
30+
31+
build-and-test:
32+
runs-on: ubuntu-latest
33+
needs: [ check-for-run-condition ]
34+
if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }}
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
os: [ ubuntu-latest]
39+
40+
steps:
41+
- uses: actions/checkout@v3
42+
43+
- name: Setup Rust
44+
uses: './.github/actions/rust/rust-setup'
45+
46+
- name: Build
47+
run: cargo build --workspace --tests --examples --all-features --release
48+
49+
- name: Run tests
50+
run: cargo test --workspace --all-features --release
51+
52+
- name: Run Rust example
53+
run: cargo run --example sd_jwt

.github/workflows/build-windows.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Build on Windows
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [ opened, synchronize, reopened, ready_for_review ]
9+
branches:
10+
- main
11+
- 'epic/**'
12+
- 'support/**'
13+
paths:
14+
- '.github/workflows/build-and-test.yml'
15+
- '.github/actions/**'
16+
- '**.rs'
17+
- '**.toml'
18+
19+
env:
20+
RUST_BACKTRACE: full
21+
22+
jobs:
23+
check-for-run-condition:
24+
runs-on: ubuntu-latest
25+
outputs:
26+
should-run: ${{ !github.event.pull_request || github.event.pull_request.draft == false }}
27+
steps:
28+
- run: |
29+
# this run step does nothing, but is needed to get the job output
30+
31+
build-and-test:
32+
runs-on: windows-latest
33+
needs: [ check-for-run-condition ]
34+
if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }}
35+
strategy:
36+
fail-fast: false
37+
38+
steps:
39+
- uses: actions/checkout@v3
40+
41+
- name: Setup Rust
42+
uses: './.github/actions/rust/rust-setup'
43+
44+
- name: Build
45+
run: cargo build --workspace --all-features --release

.github/workflows/format.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Format
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
- 'epic/**'
11+
- 'support/**'
12+
paths:
13+
- '.github/workflows/format.yml'
14+
- '**.rs'
15+
- '**.toml'
16+
- '**.ts'
17+
- '**.js'
18+
- '**.json'
19+
20+
jobs:
21+
format:
22+
runs-on: ubuntu-latest
23+
strategy:
24+
fail-fast: false
25+
26+
steps:
27+
- uses: actions/checkout@v3
28+
29+
# we use nightly to get access to advanced format capabilities
30+
- name: Setup Rust
31+
uses: './.github/actions/rust/rust-setup'
32+
with:
33+
toolchain: nightly
34+
components: rustfmt
35+
36+
- name: Install cargo-license-template
37+
run: cargo install cargo-license-template
38+
39+
- name: core fmt check
40+
run: cargo +nightly fmt --all -- --check
41+
42+
- name: cargo-license-template check
43+
run: cargo +nightly license-template --template .license_template --ignore .license_template_ignore --verbose
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Rust publish to crates.io
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to publish Rust under (e.g. `1.2.3-dev.1`)'
8+
required: true
9+
branch:
10+
description: 'Branch to run publish from'
11+
required: true
12+
dry-run:
13+
description: 'Run in dry-run mode'
14+
type: boolean
15+
required: false
16+
default: true
17+
18+
jobs:
19+
publish-rust:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
with:
25+
ref: ${{ github.event.inputs.branch }}
26+
- name: Publish to crates.io
27+
uses: './.github/actions/publish/publish-rust'
28+
with:
29+
version: ${{ github.event.inputs.version }}
30+
crates-token: ${{ secrets.CRATES_IO_TOKEN }}
31+
dry-run: ${{ github.event.inputs.dry-run }}

.license_template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Copyright {20\d{2}(-20\d{2})?} IOTA Stiftung
2+
// SPDX-License-Identifier: Apache-2.0

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ edition = "2021"
55
authors = ["IOTA Stiftung"]
66
homepage = "https://www.iota.org"
77
license = "Apache-2.0"
8+
repository = "https://github.com/iotaledger/sd-jwt"
9+
rust-version = "1.65"
810

911
[dependencies]
1012
multibase = { version = "0.9", default-features = false, features = ["std"] }
1113
serde_json = { version = "1.0", default-features = false, features = ["std" ] }
1214
rand = { version = "0.8.5", default-features = false, features = ["std", "std_rng"] }
1315
thiserror = { version = "1.0", default-features = false }
1416
strum = { version = "0.25", default-features = false, features = ["std", "derive"] }
15-
itertools = { version = "0.11", default-features = false, features = ["use_std"] }
17+
itertools = { version = "0.12", default-features = false, features = ["use_std"] }
1618
iota-crypto = { version = "0.23", default-features = false, features = ["std", "sha"] }
1719
serde = { version = "1.0", default-features = false, features = ["derive"] }
1820

0 commit comments

Comments
 (0)