Skip to content

Commit

Permalink
ci: revamp workflows (#4020)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel authored Dec 9, 2023
1 parent 3940e9a commit d6d8314
Show file tree
Hide file tree
Showing 19 changed files with 597 additions and 762 deletions.
15 changes: 0 additions & 15 deletions .github/DOCS_ISSUE_TEMPLATE.md

This file was deleted.

81 changes: 81 additions & 0 deletions .github/actions/angular_dart_package/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Angular Dart Package Workflow
description: Build and test Angular Dart packages.

inputs:
codecov_token:
required: true
description: The Codecov token used to upload coverage
concurrency:
required: false
default: "4"
description: The value of the concurrency flag (-j) used when running tests
coverage_excludes:
required: false
default: ""
description: Globs to exclude from coverage
dart_sdk:
required: false
default: "stable"
description: "The dart sdk version to use"
working_directory:
required: false
default: "."
description: The working directory for this workflow
min_coverage:
required: false
default: "100"
description: The minimum coverage percentage value
min_score:
required: false
default: "120"
description: The minimum pana score value
analyze_directories:
required: false
default: "lib test"
description: Directories to analyze
report_on:
required: false
default: "lib"
description: Directories to report on when collecting coverage
platform:
required: false
default: "vm"
description: Platform to use when running tests

runs:
using: "composite"
steps:
- name: 🎯 Setup Dart
uses: dart-lang/setup-dart@v1
with:
sdk: ${{inputs.dart_sdk}}

- name: 📦 Install Dependencies
working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: dart pub get

- name: 🛠️ Build
working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: |
dart pub global activate webdev
webdev build
- name: ✨ Format
working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: dart format --set-exit-if-changed .

- name: 🔍 Analyze
working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: dart analyze --fatal-warnings ${{inputs.analyze_directories}}

- name: 🧪 Test
working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: |
if [ -d "test" ]; then
dart run build_runner test --fail-on-severe
fi
103 changes: 103 additions & 0 deletions .github/actions/dart_package/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Dart Package Workflow
description: Build and test Dart packages.

inputs:
codecov_token:
required: true
description: The Codecov token used to upload coverage
concurrency:
required: false
default: "4"
description: The value of the concurrency flag (-j) used when running tests
coverage_excludes:
required: false
default: ""
description: Globs to exclude from coverage
dart_sdk:
required: false
default: "stable"
description: "The dart sdk version to use"
working_directory:
required: false
default: "."
description: The working directory for this workflow
min_coverage:
required: false
default: "100"
description: The minimum coverage percentage value
min_score:
required: false
default: "120"
description: The minimum pana score value
analyze_directories:
required: false
default: "lib test"
description: Directories to analyze
report_on:
required: false
default: "lib"
description: Directories to report on when collecting coverage

runs:
using: "composite"
steps:
- name: 🎯 Setup Dart
uses: dart-lang/setup-dart@v1
with:
sdk: ${{inputs.dart_sdk}}

- name: 📦 Install Dependencies
working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: dart pub get

- name: ✨ Format
working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: dart format --set-exit-if-changed .

- name: 🔍 Analyze
working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: dart analyze --fatal-warnings ${{inputs.analyze_directories}}

- name: 🧪 Test
working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: |
dart pub global activate coverage
dart test -j ${{inputs.concurrency}} --coverage=coverage && dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.dart_tool/package_config.json --report-on=${{inputs.report_on}} --check-ignore
- name: 📦 Detect Package Name
env:
PACKAGE_PATH: ${{ inputs.working_directory}}
id: package
shell: ${{ inputs.shell }}
run: echo "name=${PACKAGE_PATH##*/}" >> $GITHUB_OUTPUT

- name: ⬆️ Upload Coverage
uses: codecov/codecov-action@v3
env:
PACKAGE_PATH: ${{ inputs.working_directory}}
with:
flags: ${{ steps.package.outputs.name }}
token: ${{ inputs.codecov_token }}

- name: 📊 Verify Coverage
uses: VeryGoodOpenSource/very_good_coverage@v2
with:
path: ${{inputs.working_directory}}/coverage/lcov.info
exclude: ${{inputs.coverage_excludes}}
min_coverage: ${{inputs.min_coverage}}

- name: 💯 Verify Pub Score
working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: |
dart pub global activate pana
sudo apt-get install webp
PANA=$(pana . --no-warning); PANA_SCORE=$(echo $PANA | sed -n "s/.*Points: \([0-9]*\)\/\([0-9]*\)./\1\/\2/p")
echo "score: $PANA_SCORE"
IFS='/'; read -a SCORE_ARR <<< "$PANA_SCORE"; SCORE=SCORE_ARR[0]; TOTAL=SCORE_ARR[1]
if [ -z "$1" ]; then MINIMUM_SCORE=TOTAL; else MINIMUM_SCORE=$1; fi
if (( $SCORE < $MINIMUM_SCORE )); then echo "minimum score $MINIMUM_SCORE was not met!"; exit 1; fi
119 changes: 119 additions & 0 deletions .github/actions/flutter_package/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Flutter Package Workflow
description: Build and test a Flutter package.

inputs:
codecov_token:
required: true
description: The Codecov token used to upload coverage
collect_coverage:
required: false
default: "true"
description: Whether to collect code coverage
collect_score:
required: false
default: "true"
description: Whether to collect the pana score
concurrency:
required: false
default: "4"
description: The value of the concurrency flag (-j) used when running tests
coverage_excludes:
required: false
default: ""
description: Globs to exclude from coverage
working_directory:
required: false
default: "."
description: The working directory for this workflow
min_coverage:
required: false
default: "100"
description: The minimum coverage percentage value
analyze_directories:
required: false
default: "lib test"
description: Directories to analyze
report_on:
required: false
default: "lib"
description: Directories to report on when collecting coverage
platform:
required: false
default: "vm"
description: Platform to use when running tests

runs:
using: "composite"
steps:
- name: 🐦 Setup Flutter
uses: subosito/flutter-action@v2

- name: 📦 Install Dependencies
working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: flutter pub get

- name: ✨ Format
working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: dart format --set-exit-if-changed .

- name: 🔍 Analyze
working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: dart analyze --fatal-warnings ${{inputs.analyze_directories}}

- name: 🧪 Test
working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: |
if [ -d "test" ]; then
flutter test --no-pub --test-randomize-ordering-seed random --coverage
fi
- name: Exclude Generated Code from Coverage
if: ${{ inputs.collect_coverage == 'true' && inputs.coverage_excludes != '' }}
working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: |
mv coverage/lcov.info coverage/lcov.info.bak
sudo apt-get -y install lcov
lcov --remove coverage/lcov.info.bak "${{inputs.coverage_excludes}}" -o coverage/lcov.info
- name: 📦 Detect Package Name
if: inputs.collect_coverage == 'true'
env:
PACKAGE_PATH: ${{ inputs.working_directory}}
id: package
shell: ${{ inputs.shell }}
run: echo "name=${PACKAGE_PATH##*/}" >> $GITHUB_OUTPUT

- name: ⬆️ Upload Coverage
if: inputs.collect_coverage == 'true'
uses: codecov/codecov-action@v3
env:
PACKAGE_PATH: ${{ inputs.working_directory}}
with:
flags: ${{ steps.package.outputs.name }}
token: ${{ inputs.codecov_token }}

- name: 📊 Verify Coverage
if: inputs.collect_coverage == 'true'
uses: VeryGoodOpenSource/very_good_coverage@v2
with:
path: ${{inputs.working_directory}}/coverage/lcov.info
exclude: ${{inputs.coverage_excludes}}
min_coverage: ${{inputs.min_coverage}}

- name: 💯 Verify Pub Score
if: inputs.collect_score == 'true'
working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: |
dart pub global activate pana
sudo apt-get install webp
PANA=$(pana . --no-warning); PANA_SCORE=$(echo $PANA | sed -n "s/.*Points: \([0-9]*\)\/\([0-9]*\)./\1\/\2/p")
echo "score: $PANA_SCORE"
IFS='/'; read -a SCORE_ARR <<< "$PANA_SCORE"; SCORE=SCORE_ARR[0]; TOTAL=SCORE_ARR[1]
if [ -z "$1" ]; then MINIMUM_SCORE=TOTAL; else MINIMUM_SCORE=$1; fi
if (( $SCORE < $MINIMUM_SCORE )); then echo "minimum score $MINIMUM_SCORE was not met!"; exit 1; fi
3 changes: 3 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
flag_management:
default_rules:
carryforward: true
70 changes: 0 additions & 70 deletions .github/workflows/angular_bloc.yaml

This file was deleted.

Loading

0 comments on commit d6d8314

Please sign in to comment.