-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dart): Add build check for Dart (#886)
* feat(dart): Add build check for Dart * feat(dart): Add dart analyze to check * fix(dart): remove dart analyze * feat(dart): Ignore unused variable and add dart analyze
- Loading branch information
Showing
6 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# This workflow will install Dart SDK, run format and build with Dart | ||
|
||
name: Dart | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
paths: ["codes/dart/**/*.dart"] | ||
pull_request: | ||
branches: ["main"] | ||
paths: ["codes/dart/**/*.dart"] | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
name: Dart ${{ matrix.dart-sdk }} on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
dart-sdk: [stable, beta, dev] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Dart ${{ matrix.dart-sdk }} | ||
uses: dart-lang/setup-dart@v1 | ||
with: | ||
sdk: ${{ matrix.dart-sdk}} | ||
- name: Run format | ||
run: dart format codes/dart | ||
- name: Run analyze | ||
run: dart analyze codes/dart | ||
- name: Run build | ||
run: dart codes/dart/build.dart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'dart:io'; | ||
|
||
void main() { | ||
Directory foldPath = Directory('codes/dart/'); | ||
List<FileSystemEntity> files = foldPath.listSync(); | ||
int totalCount = 0; | ||
int errorCount = 0; | ||
for (var file in files) { | ||
if (file.path.endsWith('build.dart')) continue; | ||
if (file is File && file.path.endsWith('.dart')) { | ||
totalCount++; | ||
try { | ||
Process.runSync('dart', [file.path]); | ||
} catch (e) { | ||
errorCount++; | ||
print('Error: $e'); | ||
print('File: ${file.path}'); | ||
} | ||
} else if (file is Directory) { | ||
List<FileSystemEntity> subFiles = file.listSync(); | ||
for (var subFile in subFiles) { | ||
if (subFile is File && subFile.path.endsWith('.dart')) { | ||
totalCount++; | ||
try { | ||
Process.runSync('dart', [subFile.path]); | ||
} catch (e) { | ||
errorCount++; | ||
print('Error: $e'); | ||
print('File: ${file.path}'); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
print('===== Build Complete ====='); | ||
print('Total: $totalCount'); | ||
print('Error: $errorCount'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
* Author: Jefferson ([email protected]) | ||
*/ | ||
|
||
// ignore_for_file: unused_local_variable | ||
|
||
import 'dart:math'; | ||
|
||
/* 随机访问元素 */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
* Author: Jefferson ([email protected]) | ||
*/ | ||
|
||
// ignore_for_file: unused_local_variable | ||
|
||
/* Driver Code */ | ||
void main() { | ||
/* 初始化列表 */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
* Author: Jefferson ([email protected]) | ||
*/ | ||
|
||
// ignore_for_file: unused_local_variable | ||
|
||
import 'dart:collection'; | ||
import '../utils/list_node.dart'; | ||
import '../utils/print_util.dart'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
* Author: Jefferson ([email protected]) | ||
*/ | ||
|
||
// ignore_for_file: unused_local_variable | ||
|
||
/* 常数阶 */ | ||
int constant(int n) { | ||
int count = 0; | ||
|