-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change credential registry template flow: default and custom; run cli…
…ppy on all combinations of parameters
- Loading branch information
Showing
5 changed files
with
73 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,7 +134,7 @@ jobs: | |
with: | ||
name: ${{ env.PROJECT_NAME }} | ||
template: templates/credential-registry | ||
other: "-d description=myProject -d restorable=${{ matrix.restorable }} -d revocable_by_others=${{ matrix.revocable_by_others }}" | ||
other: "-d description=myProject -d template_type=custom -d restorable=${{ matrix.restorable }} -d revocable_by_others=${{ matrix.revocable_by_others }}" | ||
|
||
- name: Install toolchain | ||
uses: actions-rs/toolchain@v1 | ||
|
@@ -181,7 +181,57 @@ jobs: | |
with: | ||
name: ${{ env.PROJECT_NAME }} | ||
template: ${{ matrix.crates }} | ||
other: "-d description=myProject -d tokenMetadataBaseURL=https://some.example/token/ -d restorable=true -d revocable_by_others=true" | ||
other: "-d description=myProject -d tokenMetadataBaseURL=https://some.example/token/ -d template_type=default" | ||
|
||
- name: Install toolchain with clippy available | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: ${{ env.RUST_VERSION }} | ||
target: ${{ matrix.target }} | ||
override: true | ||
components: clippy | ||
|
||
# we need to move the generated project to a temp folder, away from the template project | ||
# otherwise `cargo` runs would fail | ||
# see https://github.com/rust-lang/cargo/issues/9922 | ||
- name: Run clippy with build-schema | ||
run: | | ||
mv $PROJECT_NAME ${{ runner.temp }}/ | ||
cd ${{ runner.temp }}/$PROJECT_NAME | ||
rustup target add wasm32-unknown-unknown | ||
cargo clippy --manifest-path ./Cargo.toml --target=${{ matrix.target }} --features concordium-std/build-schema -- -D warnings | ||
# The credential registry template used to generate code for all combinations of parameters | ||
# with the `cargo-generate` command and it is checked that the schemas can be built as part | ||
# of the 'clippy' command. | ||
clippy-credential-registry-template: | ||
name: Clippy on smart contract templates | ||
runs-on: ubuntu-latest | ||
needs: rustfmt | ||
strategy: | ||
matrix: | ||
target: | ||
- wasm32-unknown-unknown | ||
|
||
restorable: ["true", "false"] | ||
revocable_by_others: ["true", "false"] | ||
|
||
env: | ||
PROJECT_NAME: my-project | ||
|
||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: true | ||
|
||
- name: Run cargo-generate | ||
uses: cargo-generate/[email protected] | ||
with: | ||
name: ${{ env.PROJECT_NAME }} | ||
template: templates/credential-registry | ||
other: "-d description=myProject -d template_type=custom -d restorable=${{ matrix.restorable }} -d revocable_by_others=${{ matrix.revocable_by_others }}" | ||
|
||
- name: Install toolchain with clippy available | ||
uses: actions-rs/toolchain@v1 | ||
|
@@ -269,7 +319,7 @@ jobs: | |
with: | ||
name: ${{ env.PROJECT_NAME }} | ||
template: ${{ matrix.crates }} | ||
other: "-d description=Example-credential-registry -d restorable=true -d revocable_by_others=true" | ||
other: "-d description=Example-credential-registry -d template-type=default" | ||
|
||
- name: Install toolchain | ||
uses: actions-rs/toolchain@v1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
[template] | ||
cargo_generate_version = ">= 0.16.0, < 0.19.0" | ||
|
||
[hooks] | ||
pre = ["pre-script.rhai"] # a script for setting default values for the variables when `template_type = default` | ||
|
||
[placeholders] | ||
description = { type="string", prompt="Description for the project?" } | ||
revocable_by_others = { type="bool", prompt="Can credentials be revoked by someone other than the issuer or the holder?", default=true } | ||
restorable = { type="bool", prompt="Can revocation be reverted?", default=false } | ||
description = { type = "string", prompt = "Description for the project?" } | ||
template_type = { type = "string", prompt = "Select template type ('default' recommended for first-time users)", choices = ["default", "custom"], default = "default"} | ||
|
||
[values] | ||
revocable_by_others = true | ||
restorable = true | ||
|
||
[conditional.'template_type == "custom"'.placeholders] | ||
revocable_by_others = { type = "bool", prompt = "Can credentials be revoked by someone other than the issuer or the holder?", default = true } | ||
restorable = { type = "bool", prompt = "Can revocation be reverted?", default = false } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
let template_type = variable::get("template_type"); | ||
if template_type == "default" { | ||
variable::set("revocable_by_others", true); | ||
variable::set("restorable", true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters