Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
# top-most EditorConfig file
root = true

[Makefile]
indent_style = tab

[.github/workflows/**.{yml,yaml}]
indent_style = space
indent_size = 2

[*]
indent_style = space
indent_size = 4
Expand Down
34 changes: 16 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,61 @@ name: Build

on:
push:
branches: [ main, develop ]
branches: [ main ]
pull_request:
types: [ synchronize, opened, reopened, ready_for_review, converted_to_draft ]
workflow_dispatch:
inputs:
linting:
type: boolean
description: Run the linter
default: true
default: false
runCodeCoverage:
type: boolean
description: Run code coverage
default: true
default: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always

jobs:
linting:
name: Linting
runs-on: ubuntu-latest
if: github.event.inputs.linting || !github.event.pull_request.draft
if: github.event.inputs.linting || github.event_name == 'push' || (github.event_name == 'pull_request' && !github.event.pull_request.draft)
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install stable toolchain
- name: Install stable Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
components: clippy, rustfmt

- name: Cargo — Format
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
components: clippy

- name: Cargo — Clippy
uses: actions-rs/cargo@v1
env:
RUSTFLAGS: "-D warnings"
with:
command: clippy

- name: Cargo — Documentation # TODO: Move to new job that publishes the docs to GitHub Pages
- name: Cargo — Check documentation
uses: actions-rs/cargo@v1
env:
RUSTDOCFLAGS: "-D warnings"
with:
command: doc

check:
name: Check Project Integrity
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
RUN_CODE_COVERAGE:
${{
github.event.inputs.runCodeCoverage ||
Expand All @@ -67,7 +67,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Install stable toolchain
- name: Install stable Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
Expand All @@ -89,7 +89,7 @@ jobs:
if: always()
with:
check_name: "Test Results"
pull_request_build: "commit"
pull_request_build: ${{ github.event_name == 'push' && 'commit' || 'merge' }}
report_individual_runs: true
files: "test-results.xml"

Expand All @@ -109,5 +109,3 @@ jobs:
flags: unittests
fail_ci_if_error: true
verbose: true

# TODO: Add job for publishing Rustdocs to GitHub
100 changes: 100 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Upload Documentation

on:
release:
types: [ published ]
workflow_dispatch:
inputs:
targetTag:
type: string
description: The tag of the GitHub release to update
required: true
publishFiles:
type: boolean
description: Upload WASM & JSON schema to GitHub release
default: true
updateDocsSite:
type: boolean
description: Upload documentation to GitHub Pages
default: true

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always

jobs:
publish-files:
name: Publish Contract WASM & JSON schema
runs-on: ubuntu-latest
if: github.event.inputs.publishFiles || github.event_name == 'release'
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Generate JSON schema
run: make schema

- name: Build & optimize WASM
run: make optimize

- name: Get release information
id: release_info
uses: cardinalby/git-get-release-action@1.2.4
if: github.event_name != 'release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: ${{ github.event.inputs.targetTag }}

- name: Upload files to GitHub release
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ github.event_name == 'release' && github.event.release.id || steps.release_info.outputs.id }}
file: |
artifacts/asset_classification_smart_contract.wasm
artifacts/checksums.txt
schema/validation_oracle_smart_contract.json
overwrite: true

upload-docs:
name: Upload Documentation to GitHub Pages
runs-on: ubuntu-latest
if: github.event.inputs.updateDocsSite || (github.event_name == 'release' && !github.event.release.prerelease)
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install stable Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true

- name: Cargo — Generate & check documentation
uses: actions-rs/cargo@v1
env:
RUSTDOCFLAGS: '-D warnings'
with:
command: doc

- name: Stage documentation
if: env.UPLOAD_TO_GITHUB_PAGES
run: |
# Add redirect page to inner doc index
echo "<meta http-equiv=\"refresh\" content=\"0; url=docs\">" >> ./target/doc/index.html
# Create doc deployment location
mkdir ./pages-files
# Move documentation to its configured location in settings
cp -r target/doc ./pages-files/docs

- name: Deploy documentation to GitHub Pages
if: env.UPLOAD_TO_GITHUB_PAGES
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
branch: github-pages-for-docs
folder: pages-files
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ CONTAINER_RUNTIME := $(shell which docker 2>/dev/null || which podman 2>/dev/nul

### Use cosmwasm/rust-optimizer-arm64 on M1 Macs (https://hub.docker.com/r/cosmwasm/rust-optimizer-arm64)
OPTIMIZER_IMAGE := cosmwasm/rust-optimizer
### 0.12.10 is the latest tag (https://hub.docker.com/r/cosmwasm/rust-optimizer/tags)
OPTIMIZER_DOCKER_TAG := 0.12.10
### See tags here: https://hub.docker.com/r/cosmwasm/rust-optimizer/tags
OPTIMIZER_DOCKER_TAG ?= 0.12.11

.PHONY: all
all: clean build fmt lint test schema docs optimize
Expand Down