Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add script for linting & formatting code #116

Closed
Closed
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
27 changes: 27 additions & 0 deletions .github/actions/init/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Initialize
description: This action initializes a runner for use in other actions.
inputs:
cache-key:
description: "The key to be used for the cache"

runs:
using: "composite"
steps:
- name: Setup Ubuntu dependencies
shell: bash
run: sudo apt update && sudo apt install -y protobuf-compiler

- name: Free up space on runner
shell: bash
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"

- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.3
with:
cache-on-failure: true
cache-all-crates: true
key: ${{ inputs.cache-key }}
32 changes: 0 additions & 32 deletions .github/templates/setup-worker/action.yaml

This file was deleted.

127 changes: 0 additions & 127 deletions .github/workflows/build.yml

This file was deleted.

120 changes: 120 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: ci

on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Check formatting
run: cargo +stable fmt --all -- --check

check:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: "./.github/actions/init"

- name: Check Build
run: |
cargo check --release --locked --features=runtime-benchmarks,try-runtime

clippy:
needs: lint
runs-on: ubuntu-latest
permissions:
checks: write
env:
SKIP_WASM_BUILD: 1
steps:
- uses: actions/checkout@v4

- uses: "./.github/actions/init"

- name: Annotate with Clippy warnings
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --release --locked --features=runtime-benchmarks

format:
needs: check
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup worker
uses: "./.github/templates/setup-worker"

- name: Cache Build artefacts
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-debug

- name: Format check packages
run: cargo +nightly fmt --all -- --check

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "style: apply formatting changes"
branch: ${{ github.head_ref }}

test:
needs: [lint, format]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: "./.github/actions/init"

- name: Run tests
run: cargo test --release --locked --workspace --features=runtime-benchmarks --exclude integration-tests

integration-tests:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: "./.github/actions/init"

- name: Run integration tests
run: cargo test --release --locked --package integration-tests

coverage:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: "./.github/actions/init"

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Generate code coverage
run: cargo llvm-cov --all-features --workspace --exclude integration-tests --lib --bins --codecov --output-path codecov.json

- name: Upload to codecov.io
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: codecov.json
fail_ci_if_error: true
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
run: rustup target add ${{ matrix.platform.target }}

- name: Build node
run: cargo build --profile=production -p pop-node --target ${{ matrix.platform.target }} --features paseo
run: cargo build --profile=production -p pop-node --target ${{ matrix.platform.target }}

- name: Package binary (Linux)
if: contains(matrix.platform.target, 'linux')
Expand Down
Loading
Loading