Skip to content

Commit

Permalink
👷 Improve workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Nov 7, 2023
1 parent e9804d1 commit 255f1ac
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 55 deletions.
30 changes: 25 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Format & Analyze & Dry-run & Test
name: Verify packages abilities

on:
push:
Expand All @@ -14,6 +14,10 @@ on:
paths-ignore:
- "**.md"

defaults:
run:
shell: bash -leo pipefail {0}

jobs:
workflows:
runs-on: ubuntu-latest
Expand All @@ -31,13 +35,29 @@ jobs:
- run: |
chmod +x ./scripts/prepare_pinning_certs.sh
./scripts/prepare_pinning_certs.sh
shell: bash
- name: Install proxy for tests
run: sudo apt-get install -y squid
- run: dart pub get
- uses: bluefireteam/melos-action@v2
with:
run-bootstrap: false
- run: melos run files-patch
- run: melos run pre-bootstrap
- run: melos run github-ci
- name: Patching files for Flutter ${{ matrix.sdk }}
run: dart ./scripts/files_patch.dart
- name: Check satisfied packages
run: |
dart ./scripts/melos_ignored_packages.dart
echo $(cat .melos_ignored_packages) >> ~/.bash_profile
- name: Bootstrap
run: melos bootstrap $(eval echo $IGNORED_PACKAGES)
- name: Format
run: melos exec $(eval echo $IGNORED_PACKAGES) -- "dart format --set-exit-if-changed ."
- name: Analyze Dart packages
run: melos exec $(eval echo $IGNORED_PACKAGES) --no-flutter -- "dart analyze --fatal-infos"
- name: Analyze Flutter packages
run: melos exec $(eval echo $IGNORED_PACKAGES) --flutter -- "flutter analyze --fatal-infos"
- name: Publish dry-run
run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" -- "dart pub publish --dry-run"
- name: Test Dart packages
run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --no-flutter -- "dart test --chain-stack-traces --platform=vm,chrome,firefox"
- name: Test Flutter packages
run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --flutter -- "flutter test"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ plugins/http2_adapter/test/*_pinning.txt

# Miscellaneous
.DS_Store
.melos*packages

# IDEA configurations
/.idea/*
Expand Down
20 changes: 0 additions & 20 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,3 @@ ide:
command:
bootstrap:
runPubGetInParallel: false

scripts:
files-patch: # Apply files patches for different versions of SDKs.
run: |
dart $MELOS_ROOT_PATH/scripts/files_patch.dart
pre-bootstrap: # Filtering available packages that need to be bootstrapped.
run: |
export MELOS_PACKAGES=$(dart $MELOS_ROOT_PATH/scripts/melos_packages.dart true)
melos bootstrap
github-ci: # Executions for GitHub Action runners.
run: |
export MELOS_IGNORE_PACKAGES=$(dart $MELOS_ROOT_PATH/scripts/melos_packages.dart false)
melos exec $(eval echo $MELOS_IGNORE_PACKAGES) -- "dart format --set-exit-if-changed ."
melos exec $(eval echo $MELOS_IGNORE_PACKAGES) --no-flutter -- "dart analyze --fatal-infos"
melos exec $(eval echo $MELOS_IGNORE_PACKAGES) --flutter -- "flutter analyze --fatal-infos"
melos exec $(eval echo $MELOS_IGNORE_PACKAGES) --ignore="*example*" -- "dart pub publish --dry-run"
melos exec $(eval echo $MELOS_IGNORE_PACKAGES) --ignore="*example*" --no-flutter -- "dart test --chain-stack-traces --platform=vm,chrome,firefox"
melos exec $(eval echo $MELOS_IGNORE_PACKAGES) --ignore="*example*" --flutter -- "flutter test"
40 changes: 10 additions & 30 deletions scripts/melos_packages.dart → scripts/melos_ignored_packages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import 'package:melos/melos.dart'
import 'package:pub_semver/pub_semver.dart';
import 'package:yaml/yaml.dart';

void main(List<String> arguments) async {
final root = Platform.environment['MELOS_ROOT_PATH'] as String;
void main() async {
final root =
Platform.environment['MELOS_ROOT_PATH'] ?? Directory.current.path;
final config = MelosWorkspaceConfig.fromYaml(
loadYamlNode(
File('$root/melos.yaml').readAsStringSync(),
Expand All @@ -22,34 +23,13 @@ void main(List<String> arguments) async {
final current = Version.parse(
RegExp(r'\d*\.\d*\.\d*').firstMatch(Platform.version)!.group(0)!,
);
if (arguments.first == 'true') {
final satisfiedPackages = packages
.map(
(package) {
if (package.pubSpec.environment!.sdkConstraint!.allows(current)) {
return package.name;
}
return null;
},
)
.whereType<String>()
.join(',');
print(satisfiedPackages);
} else {
final ignoresPackages = packages
.map(
(package) {
if (package.pubSpec.environment!.sdkConstraint!.allows(current)) {
return null;
}
return package.name;
},
)
.whereType<String>()
.map((e) => '--ignore="$e"')
.join(' ');
print(ignoresPackages);
}
final ignoredPackages = packages
.where((e) => !e.pubSpec.environment!.sdkConstraint!.allows(current))
.map((e) => e.name);
File('$root/.melos_ignored_packages').writeAsStringSync(
'IGNORED_PACKAGES='
"'${ignoredPackages.map((e) => '--ignore="$e"').join(' ')}'",
);
}

extension YamlUtils on YamlNode {
Expand Down

0 comments on commit 255f1ac

Please sign in to comment.