-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: include bot to update when exclusion table needs changes (#132)
* feat: include bot to update when exclusion table needs changes * revert: exclusion reasons * revert: format on save
- Loading branch information
Showing
7 changed files
with
149 additions
and
12 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,56 @@ | ||
name: bot_update_exclusions | ||
|
||
on: | ||
# This should ideally trigger whenever there is a commit to the [Dart Linter rules](https://raw.githubusercontent.com/dart-lang/sdk/main/pkg/linter/tool/machine/rules.json). | ||
# However, this is not yet possible see: https://github.com/orgs/community/discussions/26323 | ||
schedule: | ||
# At 08:06 on every day-of-week from Monday through Friday. | ||
- cron: "6 8 * * 1-5" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
defaults: | ||
run: | ||
working-directory: tool/linter_rules | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: 📚 Git Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: 🎯 Setup Dart | ||
uses: dart-lang/setup-dart@v1 | ||
|
||
- name: 📦 Install Dependencies | ||
run: dart pub get | ||
|
||
- name: 🔍 Check for changes | ||
id: make | ||
run: if dart lib/exclusion_reason_table.dart --set-exit-if-changed; then echo "did_change=false"; else echo "did_change=true"; fi >> $GITHUB_ENV | ||
|
||
- name: 🔑 Config Git User | ||
if: ${{ env.did_change == 'true' }} | ||
run: | | ||
git config user.name VGV Bot | ||
git config user.email [email protected] | ||
- name: ✍️ Make changes | ||
if: ${{ env.did_change == 'true' }} | ||
run: dart lib/exclusion_reason_table.dart | ||
|
||
- name: 📝 Create Pull Request | ||
if: ${{ env.did_change == 'true' }} | ||
uses: peter-evans/[email protected] | ||
with: | ||
base: main | ||
branch: chore/update-spdx-license | ||
commit-message: "docs: update exclusion table" | ||
title: "docs: update exclusion table" | ||
body: | | ||
There are rules that require an update to their exclusion reasons. | ||
labels: bot | ||
author: VGV Bot <[email protected]> | ||
assignees: vgvbot | ||
committer: VGV Bot <[email protected]> |
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
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
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
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
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 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:path/path.dart' as path; | ||
|
||
/// The file path containing the latest Very Good Analysis options version. | ||
/// | ||
/// It assumes that the current directory is the root of the `linter_rules` | ||
/// package (tool/linter_rules). | ||
final _latestVeryGoodAnalaysisFilePath = path.joinAll( | ||
['..', '..', 'lib', 'analysis_options.yaml'], | ||
); | ||
|
||
/// Returns the latest Very Good Analysis version from the analysis options | ||
/// file. | ||
String latestVgaVersion() { | ||
final analysisOptionsFile = File(_latestVeryGoodAnalaysisFilePath); | ||
|
||
if (!analysisOptionsFile.existsSync()) { | ||
throw ArgumentError( | ||
'''Could not find analysis options file at ${analysisOptionsFile.path}''', | ||
); | ||
} | ||
|
||
final yaml = analysisOptionsFile.readAsStringSync(); | ||
|
||
final versionRegex = RegExp(r'analysis_options\.(\d+\.\d+\.\d+)\.yaml'); | ||
final match = versionRegex.firstMatch(yaml); | ||
|
||
if (match == null) { | ||
throw ArgumentError( | ||
'''Could not find Very Good Analysis version in ${analysisOptionsFile.path}''', | ||
); | ||
} | ||
|
||
return match.group(1)!; | ||
} |
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