chore(shorebird_ci): make package cleanly publishable (#3753)
This commit is contained in:
@@ -1 +1,11 @@
|
||||
include: ../../analysis_options.yaml
|
||||
# Self-contained (does NOT `include: ../../analysis_options.yaml`).
|
||||
# Reason: pub publish uploads only this package, and pana scores it
|
||||
# in an isolated copy. A relative include of the workspace-root file
|
||||
# is unresolvable in those environments, which causes dart_style to
|
||||
# silently drop the `formatter:` block and reformat against defaults.
|
||||
# Keeping the formatter config local to the package guarantees the
|
||||
# same formatting behavior here, in CI, in pana, and on pub.dev.
|
||||
include: package:very_good_analysis/analysis_options.10.0.0.yaml
|
||||
formatter:
|
||||
page_width: 80
|
||||
trailing_commas: preserve
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# Example
|
||||
|
||||
`shorebird_ci.yaml` is the workflow `shorebird_ci generate` produces for
|
||||
a minimal Dart workspace with two packages — `app` (depends on `core`)
|
||||
and `core`:
|
||||
|
||||
```
|
||||
my_repo/
|
||||
pubspec.yaml # workspace root
|
||||
packages/
|
||||
app/pubspec.yaml # depends on core
|
||||
core/pubspec.yaml
|
||||
```
|
||||
|
||||
Reproduce it with:
|
||||
|
||||
```sh
|
||||
dart pub global activate shorebird_ci
|
||||
shorebird_ci generate --repo-root . --dry-run
|
||||
```
|
||||
|
||||
The workflow has two jobs. `setup` activates `shorebird_ci` on the
|
||||
runner, calls `verify` to fail fast if CI coverage has drifted from the
|
||||
dep graph, then calls `affected_packages` to emit the JSON matrix.
|
||||
`dart_ci` fans out across that matrix, running format / analyze / test
|
||||
for each affected package — including transitive dependents (a change
|
||||
to `core` runs `app` too).
|
||||
|
||||
For Flutter packages a parallel `flutter_ci` job is added, with
|
||||
`flutter_version` resolved from the pubspec when pinned. With codecov
|
||||
configured, coverage upload steps are added. With a cspell config
|
||||
present, a `cspell` job is added. None of those apply to this minimal
|
||||
example.
|
||||
|
||||
See the package README for the static (`--style static`) variant and
|
||||
other options.
|
||||
@@ -0,0 +1,65 @@
|
||||
# Generated by shorebird_ci. Safe to edit.
|
||||
# Run `shorebird_ci verify` to check for dep graph drift.
|
||||
# shorebird_ci-managed: dynamic
|
||||
name: Shorebird CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
dart_packages: ${{ steps.affected.outputs.dart_packages }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: dart-lang/setup-dart@v1
|
||||
- run: dart pub global activate shorebird_ci
|
||||
# Verify first so we fail fast if CI coverage is broken and
|
||||
# don't waste time computing affected packages.
|
||||
- name: Verify CI coverage
|
||||
run: shorebird_ci verify
|
||||
- id: affected
|
||||
run: |
|
||||
DART=$(shorebird_ci affected_packages --sdk dart)
|
||||
echo "dart_packages=$DART" >> $GITHUB_OUTPUT
|
||||
|
||||
dart_ci:
|
||||
needs: setup
|
||||
if: needs.setup.outputs.dart_packages != '[]'
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include: ${{ fromJSON(needs.setup.outputs.dart_packages) }}
|
||||
name: ${{ matrix.name }}
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ${{ matrix.path }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: dart-lang/setup-dart@v1
|
||||
- name: Setup Bloc Tools
|
||||
if: matrix.has_bloc_lint == true
|
||||
uses: felangel/setup-bloc-tools@v0
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
dart pub get --no-example
|
||||
for sub in ${{ matrix.subpackages }}; do
|
||||
dart pub get --no-example -C $sub
|
||||
done
|
||||
- run: dart format --set-exit-if-changed .
|
||||
- run: dart analyze .
|
||||
- name: Bloc Lint
|
||||
if: matrix.has_bloc_lint == true
|
||||
run: bloc lint .
|
||||
- run: dart test
|
||||
@@ -3,7 +3,7 @@ import 'package:path/path.dart' as p;
|
||||
/// Candidate paths for codecov config files.
|
||||
///
|
||||
/// See https://docs.codecov.com/docs/codecov-yaml#can-i-name-the-file-codecovyml
|
||||
final codecovFileNames = {
|
||||
final codecovFileNames = <String>{
|
||||
'codecov.yml',
|
||||
'.codecov.yml',
|
||||
p.join('.github', 'codecov.yml'),
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:path/path.dart' as p;
|
||||
/// Candidate paths for cSpell config files.
|
||||
///
|
||||
/// See https://cspell.org/docs/getting-started#1-create-a-configuration-file
|
||||
final cSpellConfigFileNames = {
|
||||
final cSpellConfigFileNames = <String>{
|
||||
'.cspell.json',
|
||||
'cspell.json',
|
||||
'.cSpell.json',
|
||||
|
||||
@@ -9,6 +9,9 @@ repository: https://github.com/shorebirdtech/shorebird/tree/main/packages/shoreb
|
||||
topics: [ci, github-actions, monorepo, shorebird]
|
||||
resolution: workspace
|
||||
|
||||
executables:
|
||||
shorebird_ci:
|
||||
|
||||
environment:
|
||||
sdk: ^3.9.0
|
||||
|
||||
@@ -21,3 +24,4 @@ dependencies:
|
||||
|
||||
dev_dependencies:
|
||||
test: ^1.31.1
|
||||
very_good_analysis: ^10.2.0
|
||||
|
||||
Reference in New Issue
Block a user