Skip to content

Commit

Permalink
GitHub Actions Integration (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirland authored Aug 29, 2022
1 parent 0204ea4 commit 43f2ddc
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 3 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/dart-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Dart CI
on:
pull_request:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- name: Install dependencies
run: dart pub get

- name: Verify formatting
run: dart format --output=none --set-exit-if-changed .

- name: Analyze project source
run: dart analyze --fatal-infos

- name: Analyze project source - Code Metrics
run: |
result=$(dart run dart_code_metrics:metrics analyze lib --fatal-style --fatal-performance --fatal-warnings)
echo "$result"
[[ $result == '✔ no issues found!' ]] || { echo -e "${RED}Linter error" ; exit 1; }
- name: Analyze project source - Check Unused Code
run: dart run dart_code_metrics:metrics check-unused-code lib --fatal-unused

- name: Analyze project source - Check Unused Files
run: dart run dart_code_metrics:metrics check-unused-files lib --fatal-unused

- name: Run tests
run: |
dart pub global activate coverage 1.2.0
dart test --coverage=coverage && dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.packages --report-on=lib
- uses: codecov/codecov-action@v3
with:
verbose: true
files: ./coverage/lcov.info
16 changes: 16 additions & 0 deletions .github/workflows/dartcodemetrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Dart Code Metrics

on: [pull_request]

jobs:
check:
name: dart-code-metrics-action
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: dart-code-metrics
uses: dart-code-checker/dart-code-metrics-action@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Stock
[![Pub](https://img.shields.io/pub/v/stock.svg?style=flat-square)](https://pub.dartlang.org/packages/stock)
[![Codecov](https://codecov.io/gh/xmartlabs/stock/branch/main/graph/badge.svg)](https://codecov.io/gh/xmartlabs/stock)
[![Dart CI](https://github.com/xmartlabs/stock/actions/workflows/dart-ci.yml/badge.svg?branch=main)](https://github.com/xmartlabs/stock/actions/workflows/dart-ci.yml)

Stock is a dart package for loading data from both remote and local sources.
It is inspired by the [Store] Kotlin library.
Expand Down Expand Up @@ -37,7 +40,7 @@ To use this package, add `stock` as a [dependency in your pubspec.yaml file](htt
### 1. Create a Fetcher

The `Fetcher` is required to fetch new data from the network.
You can create a it from a `Future` or from a `Stream`.
You can create it from a `Future` or from a `Stream`.

`FutureFetcher` is usually used alongside a RestApi, whereas `StreamFetcher` is used with a `Stream` source like a Web Socket.

Expand Down
4 changes: 2 additions & 2 deletions scripts/checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ echo ':: Check code format ::'
dart format --set-exit-if-changed . || { echo -e "${RED}Invalid format" ; exit 1; }

echo ':: Run linter ::'
dart analyze . || { echo -e "${RED}Linter error" ; exit 1; }
dart analyze --fatal-infos || { echo -e "${RED}Linter error" ; exit 1; }

result=$(dart run dart_code_metrics:metrics analyze lib --fatal-style --fatal-performance --fatal-warnings)
echo "$result"
[[ $result == '✔ no issues found!' ]] || { echo -e "${RED}Linter error" ; exit 1; }

dart run dart_code_metrics:metrics check-unused-code lib --fatal-unused || { echo -e "${RED}Linter error" ; exit 1; }

dart run dart_code_metrics:metrics check-unused-files lib --fatal-unused || { echo -e "${RED}Linter error" ; exit 1; }
dart run dart_code_metrics:metrics check-unused-files lib --fatal-unused || { echo -e "${RED}Linter error" ; exit 1; }

echo ':: Run tests ::'
dart test || { echo -e "${RED}Test error" ; exit 1; }

0 comments on commit 43f2ddc

Please sign in to comment.