name: Rust
on: [push, pull_request]
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-rust_stable-${{ hashFiles('**/Cargo.lock') }}
- name: Format
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
override: true
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-rust_stable-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-build-rust_stable-clippy-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-rust_stable-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-build-rust_stable-docs-${{ hashFiles('**/Cargo.lock') }}
- name: Documentation
uses: actions-rs/cargo@v1
with:
command: doc
check:
needs:
- format
- clippy
- docs
strategy:
fail-fast: ${{ github.event_name == 'pull_request' || startsWith(github.ref, 'refs/tags/') }}
matrix:
include:
- name: valico
features: valico
- name: jsonschema
features: jsonschema
- name: jsonschema-valid
features: jsonschema-valid
- name: all-validators
features: all-validators
- name: schemastore
features: schemastore,native-tls
- name: schemastore-file-cache
features: schemastore,file-cache,native-tls
- name: schemastore-sled-cache
features: schemastore,sled-cache,native-tls
- name: infers
features: infers
- name: minimal-json5
features: minimal,json5
- name: minimal-yaml
features: minimal,yaml
- name: minimal-toml
features: minimal,toml
- name: minimal-ron
features: minimal,ron
- name: minimal-bson
features: minimal,bson
- name: minimal-cbor
features: minimal,cbor
- name: minimal-pickle
features: minimal,pickle
- name: minimal-txt-parsers
features: minimal,txt-parsers
- name: minimal-bin-parsers
features: minimal,bin-parsers
- name: minimal-all-parsers
features: minimal,all-parsers
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-rust_stable-features_${{ matrix.name }}-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-build-rust_stable-features_${{ matrix.name }}-${{ hashFiles('**/Cargo.lock') }}
- name: Check features set ${{ matrix.features }}
uses: actions-rs/cargo@v1
with:
command: check
args: --no-default-features --features ${{ matrix.features }}
build:
needs:
- check
strategy:
fail-fast: ${{ github.event_name == 'pull_request' || startsWith(github.ref, 'refs/tags/') }}
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
rust:
- stable
- nightly
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-rust_${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/cache@v2
if: |
!startsWith(matrix.os, 'macos')
with:
path: target
key: ${{ runner.os }}-build-rust_${{ matrix.rust }}-debug-${{ hashFiles('**/Cargo.lock') }}
- name: Build with Rust ${{ matrix.rust }}
uses: actions-rs/cargo@v1
with:
command: build
args: --verbose
- name: Test with Rust ${{ matrix.rust }}
uses: actions-rs/cargo@v1
with:
command: test
build-release:
if: github.repository == 'katyo/jsonschema' && startsWith(github.ref, 'refs/tags/v')
needs:
- build
strategy:
fail-fast: false
matrix:
include:
- name: linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
ext:
- name: linux-i686
os: ubuntu-latest
target: i686-unknown-linux-gnu
ext:
- name: windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
ext: .exe
- name: windows-i686
os: windows-latest
target: i686-pc-windows-msvc
ext: .exe
- name: macos-x86_64
os: macos-latest
target: x86_64-apple-darwin
ext:
runs-on: ${{ matrix.os }}
steps:
- if: matrix.name == 'linux-i686'
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y gcc-multilib libssl-dev:i386 pkg-config-x86-64-linux-gnux32
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-rust_stable-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/cache@v2
if: |
!startsWith(matrix.os, 'macos')
with:
path: target
key: ${{ runner.os }}-build-rust_stable-target_${{ matrix.target }}-release-${{ hashFiles('**/Cargo.lock') }}
- name: Build release
uses: actions-rs/cargo@v1
env:
PKG_CONFIG_i686_unknown_linux_gnu: i686-linux-gnu-pkg-config
RUSTFLAGS: -C link-arg=-s
with:
command: build
args: --release --target ${{ matrix.target }}
- name: Compress binary
if: false
uses: svenstaro/upx-action@v2
with:
file: target/${{ matrix.target }}/release/jsonst${{ matrix.ext }}
args: --ultra-brute
- name: Create archive
uses: papeloto/action-zip@v1
with:
files: target/${{ matrix.target }}/release/jsonst${{ matrix.ext }} README.md LICENSE.txt
dest: jsonst_${{ matrix.name }}.zip
recursive: true
- name: Upload archive
uses: actions/upload-artifact@v2
with:
name: binary
path: jsonst_${{ matrix.name }}.zip
publish-release:
if: github.repository == 'katyo/jsonschema' && startsWith(github.ref, 'refs/tags/v')
needs:
- build-release
runs-on: ubuntu-latest
steps:
- name: Download archive
uses: actions/download-artifact@v2
with:
name: binary
- name: Create release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: '*.zip'
prerelease: true
draft: true
publish-package:
if: github.repository == 'katyo/jsonschema' && startsWith(github.ref, 'refs/tags/v')
needs:
- publish-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Publish package
uses: actions-rs/cargo@v1
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }}
with:
command: publish
args: --no-verify