Skip to content

ci: monorepo setup #14

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

Merged
merged 11 commits into from
Mar 6, 2023
Merged
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
65 changes: 65 additions & 0 deletions .github/actions/dart_package/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Dart Package Workflow

inputs:
concurrency:
required: false
type: number
default: 4
coverage_excludes:
required: false
type: string
default: ""
dart_sdk:
required: false
type: string
default: "stable"
working_directory:
required: false
type: string
default: "."
min_coverage:
required: false
type: number
default: 100
analyze_directories:
required: false
type: string
default: "lib test"
report_on:
required: false
type: string
default: "lib"
platform:
required: false
type: string
default: "vm"

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

- working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: dart pub get

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

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

- working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: |
dart pub global activate coverage
dart test -j ${{inputs.concurrency}} --coverage=coverage --platform=${{inputs.platform}} && 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
- uses: VeryGoodOpenSource/very_good_coverage@v2
with:
path: ${{inputs.working_directory}}/coverage/lcov.info
exclude: ${{inputs.coverage_excludes}}
min_coverage: ${{inputs.min_coverage}}
34 changes: 34 additions & 0 deletions .github/actions/pana/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Pana Workflow

inputs:
min_score:
required: false
type: number
default: 120
pana_version:
required: false
type: string
working_directory:
required: false
type: string
default: "."

runs:
using: "composite"
steps:
- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true

- working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: flutter pub global activate pana ${{inputs.pana_version}}

- working-directory: ${{ inputs.working_directory }}
shell: ${{ inputs.shell }}
run: |
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];
if (( $SCORE < ${{inputs.min_score}} )); then echo "The minimum score of ${{inputs.min_score}} was not met!"; exit 1; fi
27 changes: 27 additions & 0 deletions .github/actions/verify_version/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Verify Version Workflow

inputs:
working_directory:
required: false
type: string
default: "."

runs:
using: "composite"

steps:
- name: πŸ“š Git Checkout
uses: actions/checkout@v3

- name: 🎯 Setup Dart
uses: dart-lang/setup-dart@v1

- name: πŸ“¦ Install Dependencies
shell: ${{ inputs.shell }}
run: dart pub get
working-directory: ${{ inputs.working_directory }}

- name: πŸ”Ž Verify version
shell: ${{ inputs.shell }}
run: dart run test --run-skipped -t version-verify
working-directory: ${{ inputs.working_directory }}
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
name: shorebird_code_push_api
name: deploy_shorebird_code_push_api

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

on:
pull_request:
paths:
- ".github/workflows/shorebird_code_push_api.yaml"
- "packages/shorebird_code_push_api/lib/**"
- "packages/shorebird_code_push_api/test/**"
- "packages/shorebird_code_push_api/pubspec.yaml"
push:
branches:
- main
paths:
- ".github/workflows/shorebird_code_push_api.yaml"
- ".github/workflows/deploy_shorebird_code_push_api.yaml"
- "packages/shorebird_code_push_api/lib/**"
- "packages/shorebird_code_push_api/test/**"
- "packages/shorebird_code_push_api/pubspec.yaml"
Expand All @@ -26,30 +20,13 @@ env:
REGION: us-central1

jobs:
semantic-pull-request:
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/semantic_pull_request.yml@v1

build:
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_package.yml@v1
with:
working_directory: packages/shorebird_code_push_api

pana:
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/pana.yml@v1
with:
working_directory: packages/shorebird_code_push_api

deploy:
needs: build

defaults:
run:
working-directory: packages/shorebird_code_push_api

runs-on: ubuntu-latest

if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}

steps:
- uses: actions/checkout@v2

Expand Down
142 changes: 142 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: ci

on:
pull_request:
branches:
- main

jobs:
semantic_pull_request:
name: βœ… Semantic Pull Request
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/semantic_pull_request.yml@v1

changes:
runs-on: ubuntu-latest

permissions:
pull-requests: read

outputs:
needs_build: ${{ steps.needs_build.outputs.changes }}
needs_pana: ${{ steps.needs_pana.outputs.changes }}
needs_verify: ${{ steps.needs_verify.outputs.changes }}

name: πŸ‘€ Detect Changes

steps:
- uses: dorny/paths-filter@v2
name: Pana Detection
id: needs_pana
with:
filters: |
shorebird_cli:
- ./.github/actions/dart_package
- packages/shorebird_cli/**
shorebird_code_push_api:
- ./.github/actions/dart_package
- packages/shorebird_code_push_api/**
shorebird_code_push_api_client:
- ./.github/actions/dart_package
- packages/shorebird_code_push_api_client/**

- uses: dorny/paths-filter@v2
name: Build Detection
id: needs_build
with:
filters: |
shorebird_cli:
- ./.github/actions/dart_package
- packages/shorebird_cli/**
- packages/shorebird_code_push_api_client/**
shorebird_code_push_api:
- ./.github/actions/dart_package
- packages/shorebird_code_push_api/**
shorebird_code_push_api_client:
- ./.github/actions/dart_package
- packages/shorebird_code_push_api_client/**

- uses: dorny/paths-filter@v2
name: Verify Detection
id: needs_verify
with:
filters: |
shorebird_cli:
- ./.github/actions/dart_package
- packages/shorebird_cli/**

pana_packages:
needs: changes
if: ${{ needs.changes.outputs.needs_pana != '[]' }}

continue-on-error: true

strategy:
matrix:
package: ${{ fromJSON(needs.changes.outputs.needs_pana) }}

runs-on: ubuntu-latest

name: πŸ“Š Pana ${{ matrix.package }}

steps:
- name: πŸ“š Git Checkout
uses: actions/checkout@v3

- name: πŸ“Š Pana ${{ matrix.package }}
uses: ./.github/actions/pana
with:
working_directory: packages/${{ matrix.package }}

build_packages:
needs: changes
if: ${{ needs.changes.outputs.needs_build != '[]' }}

strategy:
matrix:
package: ${{ fromJSON(needs.changes.outputs.needs_build) }}

runs-on: ubuntu-latest

name: 🎯 Build ${{ matrix.package }}

steps:
- name: πŸ“š Git Checkout
uses: actions/checkout@v3

- name: 🎯 Build ${{ matrix.package }}
uses: ./.github/actions/dart_package
with:
working_directory: packages/${{ matrix.package }}

verify_packages:
needs: changes
if: ${{ needs.changes.outputs.needs_verify != '[]' }}

strategy:
matrix:
package: ${{ fromJSON(needs.changes.outputs.needs_verify) }}

runs-on: ubuntu-latest

name: πŸ”Ž Verify ${{ matrix.package }}

steps:
- name: πŸ“š Git Checkout
uses: actions/checkout@v3

- name: πŸ”Ž Verify ${{ matrix.package }}
uses: ./.github/actions/verify_version
with:
working_directory: packages/${{ matrix.package }}

ci:
needs:
[semantic_pull_request, pana_packages, build_packages, verify_packages]
if: ${{ always() }}

runs-on: ubuntu-latest

steps:
- name: ⛔️ exit(1) on failure
if: ${{ contains(join(needs.*.result, ','), 'failure') }}
run: exit 1
58 changes: 0 additions & 58 deletions .github/workflows/shorebird_cli.yaml

This file was deleted.

Loading