Skip to content

Commit

Permalink
ci: Refactor GitHub workflows and add code coverage job (#120)
Browse files Browse the repository at this point in the history
* Split GitHub Actions definitions per language

* Add code coverage job for Rust crate

* Trigger CI run

* Fix Rust coverage job

* Fix Rust coverage job, take 2

* Add badges to README

* See if all statuses are reported this way

* Revert "See if all statuses are reported this way"

This reverts commit 02b9df5.

* Add code coverage job for Go library

* Add names to Rust jobs
  • Loading branch information
romac authored Nov 28, 2022
1 parent c03500b commit 4232e6c
Show file tree
Hide file tree
Showing 10 changed files with 201 additions and 126 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Go
on:
pull_request:
paths:
- go/**
push:
branches:
- master

permissions:
contents: read

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

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
# ci is set to go1.19 to match developer setups
go-version: 1.19.2
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.50.0
working-directory: go

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19.2
- name: test
working-directory: ./go
run: make test

coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19.2
- name: Run coverage
working-directory: ./go
run: go test -race -coverprofile=coverage.txt -covermode=atomic
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: go/coverage.txt
fail_ci_if_error: true

3 changes: 2 additions & 1 deletion .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Lint PR"
name: PR

on:
pull_request_target:
Expand All @@ -12,6 +12,7 @@ permissions:

jobs:
main:
name: Lint
permissions:
pull-requests: read # for amannn/action-semantic-pull-request to analyze PRs
statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR
Expand Down
54 changes: 0 additions & 54 deletions .github/workflows/lint.yml

This file was deleted.

100 changes: 100 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Rust
on:
pull_request:
paths:
- rust/**
push:
branches:
- master

permissions:
contents: read

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

jobs:
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Check formatting
working-directory: ./rust
run: cargo fmt -- --check

- name: Clippy (host-functions + std)
working-directory: ./rust
run: cargo clippy --tests -- -D warnings

- name: Clippy (no-std)
working-directory: ./rust
run: cargo clippy --tests --no-default-features -- -D warnings

- name: Clippy (host functions only)
working-directory: ./rust
run: cargo clippy --tests --no-default-features --features host-functions -- -D warnings

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Check all target in std
working-directory: ./rust
run: cargo check --all

- name: Check all target in no_std
working-directory: ./rust
run: cargo check --no-default-features --all

- name: Build all targets in std
working-directory: ./rust
run: cargo build --all --all-targets

- name: Build all targets in no_std
working-directory: ./rust
run: cargo build --all --no-default-features

- name: Run all tests with no-std
working-directory: ./rust
run: cargo test --all --no-default-features

- name: Run all tests with std
working-directory: ./rust
run: cargo test --all

- name: Check no_std compatibility
run: cd rust/no-std-check/; make setup; make all

coverage:
name: Code Coverage
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- name: Generate code coverage
working-directory: ./rust
run: cargo llvm-cov nextest --all-features --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: rust/lcov.info
fail_ci_if_error: true
69 changes: 0 additions & 69 deletions .github/workflows/test.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: TypeScript
on:
pull_request:
paths:
- js/**
push:
branches:
- master

permissions:
contents: read

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

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: test
working-directory: ./js
run: yarn && yarn test
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Proofs
[![Go](https://github.com/cosmos/ics23/actions/workflows/go.yml/badge.svg?branch=master)](https://github.com/cosmos/ics23/actions/workflows/go.yml)
[![Rust](https://github.com/cosmos/ics23/actions/workflows/rust.yml/badge.svg?branch=master)](https://github.com/cosmos/ics23/actions/workflows/rust.yml)
[![TypeScript](https://github.com/cosmos/ics23/actions/workflows/typescript.yml/badge.svg?branch=master)](https://github.com/cosmos/ics23/actions/workflows/typescript.yml)

# ICS 23

## Proofs

This is an attempt to define a generic, cross-language, binary representation
of merkle proofs, which can be generated by many underlying merkle tree storage
Expand Down Expand Up @@ -73,4 +79,3 @@ every step along the path in order to reconstruct the path, these are not suppor
require a much more complex format and most likely custom code for each such database. The design goal
was to be able to add new data sources with only configuration (spec object), rather than custom code.


1 change: 1 addition & 0 deletions go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ format:
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
find . -name '*.go' -type f -not -name "*.pb.go" | xargs gofumpt -w -l
$(golangci_lint_cmd) run --fix

.PHONY: format
1 change: 1 addition & 0 deletions js/jasmine-testrunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jasmine.loadConfig({
seed: null,
stopSpecOnExpectationFailure: false
});

jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 15*1000;

// setup console reporter
Expand Down
4 changes: 4 additions & 0 deletions rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Unless you modify the protobuf file, you can ignore this step.

`cargo clippy -- --test -W clippy::pedantic`

## Code Coverage

`cargo llvm-cov`

## MSRV

The minimum supported Rust version (MSRV) is 1.56.1.

0 comments on commit 4232e6c

Please sign in to comment.