Migrate from Azure Pipelines to GitHub Actions.
This commit migrates the CI from Azure Pipelines to GitHub Actions.
This commit is contained in:
parent
d5982dc01c
commit
ce35a2fa8e
|
@ -1,37 +0,0 @@
|
|||
variables:
|
||||
protobuf-version: 3.9.2
|
||||
lkg-rust-nightly: "2019-09-25"
|
||||
|
||||
trigger:
|
||||
- master
|
||||
- dev
|
||||
|
||||
jobs:
|
||||
- template: jobs/formatting.yml
|
||||
parameters:
|
||||
toolchains:
|
||||
- name: stable
|
||||
version: stable
|
||||
- name: nightly
|
||||
version: nightly-${{ variables['lkg-rust-nightly'] }}
|
||||
- template: jobs/linting.yml
|
||||
parameters:
|
||||
toolchains:
|
||||
- name: stable
|
||||
version: stable
|
||||
- name: nightly
|
||||
version: nightly-${{ variables['lkg-rust-nightly'] }}
|
||||
- template: jobs/protobufs.yml
|
||||
parameters:
|
||||
version: ${{ variables['protobuf-version'] }}
|
||||
toolchains:
|
||||
- name: stable
|
||||
version: stable
|
||||
- template: jobs/build.yml
|
||||
parameters:
|
||||
toolchains:
|
||||
- name: stable
|
||||
version: stable
|
||||
- name: nightly
|
||||
version: nightly-${{ variables['lkg-rust-nightly'] }}
|
||||
features: unstable
|
|
@ -1,19 +0,0 @@
|
|||
jobs:
|
||||
- ${{ each toolchain in parameters.toolchains }}:
|
||||
- job: build_${{ toolchain.name }}
|
||||
displayName: Build and test with ${{ toolchain.name }} on
|
||||
pool:
|
||||
vmImage: $(image)
|
||||
strategy:
|
||||
matrix:
|
||||
Linux:
|
||||
image: ubuntu-16.04
|
||||
macOS:
|
||||
image: macos-10.13
|
||||
Windows:
|
||||
image: vs2017-win2016
|
||||
steps:
|
||||
- template: ../steps/build-and-test.yml
|
||||
parameters:
|
||||
toolchain: ${{ toolchain.version }}
|
||||
features: ${{ toolchain.features }}
|
|
@ -1,10 +0,0 @@
|
|||
jobs:
|
||||
- ${{ each toolchain in parameters.toolchains }}:
|
||||
- job: formatting_${{ toolchain.name }}
|
||||
displayName: Check source formatting with ${{ toolchain.name }}
|
||||
pool:
|
||||
vmImage: ubuntu-16.04
|
||||
steps:
|
||||
- template: ../steps/check-source-formatting.yml
|
||||
parameters:
|
||||
toolchain: ${{ toolchain.version }}
|
|
@ -1,10 +0,0 @@
|
|||
jobs:
|
||||
- ${{ each toolchain in parameters.toolchains }}:
|
||||
- job: linting_${{ toolchain.name }}
|
||||
displayName: Check source linting with ${{ toolchain.name }}
|
||||
pool:
|
||||
vmImage: ubuntu-16.04
|
||||
steps:
|
||||
- template: ../steps/check-source-linting.yml
|
||||
parameters:
|
||||
toolchain: ${{ toolchain.version }}
|
|
@ -1,12 +0,0 @@
|
|||
jobs:
|
||||
- ${{ each toolchain in parameters.toolchains }}:
|
||||
- job: protobufs_${{ toolchain.name }}
|
||||
displayName: Compile protobufs with ${{ toolchain.name }}
|
||||
pool:
|
||||
vmImage: ubuntu-16.04
|
||||
steps:
|
||||
- template: ../steps/compile-protobufs.yml
|
||||
parameters:
|
||||
version: ${{ parameters.version }}
|
||||
toolchain: ${{ toolchain.version }}
|
||||
platform: linux-x86_64
|
|
@ -1,14 +0,0 @@
|
|||
steps:
|
||||
- template: install-rust.yml
|
||||
parameters:
|
||||
toolchain: ${{ parameters.toolchain }}
|
||||
- bash: cargo build --release
|
||||
displayName: Build workspace
|
||||
- bash: cargo test --release
|
||||
displayName: Run tests
|
||||
- ${{ if ne(parameters.features, '') }}:
|
||||
- bash: |
|
||||
set -ex
|
||||
cd azure-functions
|
||||
cargo test --release --features ${{ parameters.features }}
|
||||
displayName: Build and test with features
|
|
@ -1,13 +0,0 @@
|
|||
steps:
|
||||
- template: install-rust.yml
|
||||
parameters:
|
||||
toolchain: ${{ parameters.toolchain }}
|
||||
- template: install-component.yml
|
||||
parameters:
|
||||
component: rustfmt
|
||||
- bash: |
|
||||
set -ex
|
||||
cargo fmt --version || true
|
||||
cargo fmt -- --check
|
||||
git diff
|
||||
displayName: Check source formatting
|
|
@ -1,12 +0,0 @@
|
|||
steps:
|
||||
- template: install-rust.yml
|
||||
parameters:
|
||||
toolchain: ${{ parameters.toolchain }}
|
||||
- template: install-component.yml
|
||||
parameters:
|
||||
component: clippy
|
||||
- bash: |
|
||||
set -ex
|
||||
cargo clippy --version || true
|
||||
cargo clippy --release -- -Dwarnings
|
||||
displayName: Check source for linter errors
|
|
@ -1,23 +0,0 @@
|
|||
steps:
|
||||
- template: install-rust.yml
|
||||
parameters:
|
||||
toolchain: ${{ parameters.toolchain }}
|
||||
- template: install-component.yml
|
||||
parameters:
|
||||
component: rustfmt
|
||||
- bash: |
|
||||
set -ex
|
||||
mkdir /tmp/protoc
|
||||
cd /tmp/protoc
|
||||
curl -Lo protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v${{ parameters.version }}/protoc-${{ parameters.version }}-${{ parameters.platform }}.zip
|
||||
unzip protoc.zip
|
||||
echo "##vso[task.prependpath]/tmp/protoc/bin"
|
||||
displayName: Install Protobuf ${{ parameters.version }}
|
||||
- bash: git submodule sync && git submodule update --init
|
||||
displayName: Sync Azure Functions Protocol submodule
|
||||
- bash: |
|
||||
set -ex
|
||||
cd azure-functions-shared
|
||||
cargo build --release --features compile_protobufs
|
||||
git diff --exit-code -- cache
|
||||
displayName: Compile protobufs
|
|
@ -1,5 +0,0 @@
|
|||
steps:
|
||||
- bash: |
|
||||
set -ex
|
||||
rustup component add ${{ parameters.component }}
|
||||
displayName: Install ${{ parameters.component }}
|
|
@ -1,10 +0,0 @@
|
|||
steps:
|
||||
- bash: |
|
||||
set -ex
|
||||
curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path --default-toolchain none
|
||||
export PATH=$HOME/.cargo/bin:$PATH
|
||||
rustup install --no-self-update ${{ parameters.toolchain }}
|
||||
rustup default ${{ parameters.toolchain }}
|
||||
rustc -Vv
|
||||
echo "##vso[task.prependpath]$HOME/.cargo/bin"
|
||||
displayName: Install Rust
|
|
@ -0,0 +1,142 @@
|
|||
name: CI
|
||||
on:
|
||||
push:
|
||||
branches: [master, dev]
|
||||
pull_request:
|
||||
branches: [master, dev]
|
||||
|
||||
jobs:
|
||||
rustfmt:
|
||||
name: Check source formatting
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
submodules: true
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
default: true
|
||||
components: rustfmt
|
||||
- name: Run rustfmt
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
|
||||
test:
|
||||
name: Build and test
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
build: [stable, beta, nightly, windows, macos]
|
||||
include:
|
||||
- build: stable
|
||||
os: ubuntu-latest
|
||||
toolchain: stable
|
||||
- build: beta
|
||||
os: ubuntu-latest
|
||||
toolchain: beta
|
||||
- build: nightly
|
||||
os: ubuntu-latest
|
||||
toolchain: nightly
|
||||
- build: macos
|
||||
os: macos-latest
|
||||
toolchain: stable
|
||||
- build: windows
|
||||
os: windows-latest
|
||||
toolchain: stable
|
||||
steps:
|
||||
- name: Checkout out source
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
submodules: true
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ matrix.toolchain }}
|
||||
default: true
|
||||
- name: Build and test
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --all
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
|
||||
unstable:
|
||||
name: Build and test (unstable feature)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
submodules: true
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
default: true
|
||||
- name: Build and test
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --features unstable --manifest-path azure-functions/Cargo.toml
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
|
||||
clippy:
|
||||
name: Lint source code
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
submodules: true
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
default: true
|
||||
components: clippy
|
||||
- name: Run clippy
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: -- -Dwarnings
|
||||
|
||||
protobufs:
|
||||
name: Build protobufs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
submodules: true
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
default: true
|
||||
- name: Install Protocol Buffers
|
||||
run: |
|
||||
mkdir /tmp/protoc
|
||||
cd /tmp/protoc
|
||||
curl -Lo protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-$PROTOBUF_PLATFORM.zip
|
||||
unzip protoc.zip
|
||||
echo ::add-path::/tmp/protoc/bin
|
||||
env:
|
||||
PROTOBUF_VERSION: 3.9.2
|
||||
PROTOBUF_PLATFORM: linux-x86_64
|
||||
- name: Build protobufs
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --features compile_protobufs --manifest-path azure-functions-shared/Cargo.toml
|
||||
- name: Check for source differences
|
||||
run: |
|
||||
cd azure-functions-shared
|
||||
git diff --exit-code -- cache
|
28
README.md
28
README.md
|
@ -1,13 +1,27 @@
|
|||
# Azure Functions for Rust
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
|
||||
|
||||
[![crates.io](https://img.shields.io/crates/v/azure-functions.svg)](https://crates.io/crates/azure-functions)
|
||||
[![docs.rs](https://docs.rs/azure-functions/badge.svg)](https://docs.rs/azure-functions)
|
||||
[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors)
|
||||
[![Gitter](https://badges.gitter.im/azure-functions-rs/community.svg)](https://gitter.im/azure-functions-rs/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||
[![Build Status](https://dev.azure.com/azure-functions-rs/Azure%20Functions%20for%20Rust/_apis/build/status/peterhuene.azure-functions-rs?branchName=master)](https://dev.azure.com/azure-functions-rs/Azure%20Functions%20for%20Rust/_build/latest?definitionId=2&branchName=master)
|
||||
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=peterhuene/azure-functions-rs)](https://dependabot.com)
|
||||
[![license](https://img.shields.io/crates/l/azure-functions.svg)](https://github.com/peterhuene/azure-functions-rs/blob/master/LICENSE)
|
||||
[crates-status]: https://img.shields.io/crates/v/azure-functions.svg
|
||||
[crates-url]: https://crates.io/crates/azure-functions
|
||||
[docs-status]: https://docs.rs/azure-functions/badge.svg
|
||||
[docs-url]: https://docs.rs/azure-functions
|
||||
[all-contributors-status]: https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square
|
||||
[gitter-status]: https://badges.gitter.im/azure-functions-rs/community.svg
|
||||
[gitter-url]: https://gitter.im/azure-functions-rs/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
|
||||
[build-status]: https://github.com/peterhuene/azure-functions-rs/workflows/CI/badge.svg?branch=dev
|
||||
[build-url]: https://github.com/peterhuene/azure-functions-rs/actions?query=workflow%3ACI%20branch%3Adev
|
||||
[dependabot-status]: https://api.dependabot.com/badges/status?host=github&repo=peterhuene/azure-functions-rs
|
||||
[dependabot-url]: https://dependabot.com
|
||||
[license-status]: https://img.shields.io/crates/l/azure-functions.svg
|
||||
[license-url]: https://github.com/peterhuene/azure-functions-rs/blob/master/LICENSE
|
||||
|
||||
[![crates-status]][crates-url]
|
||||
[![docs-status]][docs-url]
|
||||
[![all-contributors-status]](#contributors)
|
||||
[![gitter-status]][gitter-url]
|
||||
[![build-status]][build-url]
|
||||
[![dependabot-status]][dependabot-url]
|
||||
[![license-status]][license-url]
|
||||
|
||||
A framework for implementing [Azure Functions](https://azure.microsoft.com/en-us/services/functions/)
|
||||
in [Rust](https://www.rust-lang.org/).
|
||||
|
|
|
@ -318,7 +318,9 @@ impl Field {
|
|||
let ident = &self.ident;
|
||||
match &self.ty {
|
||||
FieldType::Direction => quote!(#ident: Default::default()),
|
||||
FieldType::OptionalString | FieldType::OptionalBoolean | FieldType::OptionalInteger => quote!(#ident),
|
||||
FieldType::OptionalString | FieldType::OptionalBoolean | FieldType::OptionalInteger => {
|
||||
quote!(#ident)
|
||||
}
|
||||
FieldType::StringArray => quote!(#ident: #ident.unwrap_or(Cow::Borrowed(&[]))),
|
||||
_ => quote!(#ident: #ident.unwrap()),
|
||||
}
|
||||
|
@ -327,13 +329,23 @@ impl Field {
|
|||
pub fn get_quotable_decl(&self) -> TokenStream {
|
||||
let ident = &self.ident;
|
||||
match self.ty {
|
||||
FieldType::String => quote!(let #ident = crate::codegen::quotable::QuotableBorrowedStr(&self.#ident);),
|
||||
FieldType::OptionalString => quote!(let #ident = crate::codegen::quotable::QuotableOption(self.#ident.as_ref().map(|x| crate::codegen::quotable::QuotableBorrowedStr(x)));),
|
||||
FieldType::String => {
|
||||
quote!(let #ident = crate::codegen::quotable::QuotableBorrowedStr(&self.#ident);)
|
||||
}
|
||||
FieldType::OptionalString => {
|
||||
quote!(let #ident = crate::codegen::quotable::QuotableOption(self.#ident.as_ref().map(|x| crate::codegen::quotable::QuotableBorrowedStr(x)));)
|
||||
}
|
||||
FieldType::Boolean => quote!(let #ident = self.#ident;),
|
||||
FieldType::Direction => quote!(let #ident = crate::codegen::quotable::QuotableDirection(self.#ident);),
|
||||
FieldType::StringArray => quote!(let #ident = crate::codegen::quotable::QuotableStrArray(self.#ident.as_ref());),
|
||||
FieldType::Direction => {
|
||||
quote!(let #ident = crate::codegen::quotable::QuotableDirection(self.#ident);)
|
||||
}
|
||||
FieldType::StringArray => {
|
||||
quote!(let #ident = crate::codegen::quotable::QuotableStrArray(self.#ident.as_ref());)
|
||||
}
|
||||
FieldType::Integer => quote!(let #ident = self.#ident),
|
||||
FieldType::OptionalBoolean | FieldType::OptionalInteger => quote!(let #ident = crate::codegen::quotable::QuotableOption(self.#ident);),
|
||||
FieldType::OptionalBoolean | FieldType::OptionalInteger => {
|
||||
quote!(let #ident = crate::codegen::quotable::QuotableOption(self.#ident);)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue