Skip to content

Commit 2bd1170

Browse files
authored
Fix failure of new matcher (#180)
See https://github.com/firebase/firebase-functions-dart/actions/runs/25219434625/job/73947703292?pr=160 ## Summary of Investigation & Fix The issue occurred because the action was attempting to register the problem matcher using `path.join(actionPath, 'dart-analyzer.json')`. When executed in a workflow, `actionPath` relied entirely on the `GITHUB_ACTION_PATH` environment variable. Under certain execution contexts (such as the `firebase-functions-dart` workflow), this environment variable was resolving to an empty string or was completely missing. Consequently, the lookup path for `dart-analyzer.json` incorrectly defaulted to the *consumer repository's workspace* (`/home/runner/work/firebase-functions-dart/firebase-functions-dart/dart-analyzer.json`) where the file did not exist, ultimately breaking the build. ### Changes Made: - **Exposed Repository Root**: Modified [lib/main.mjs](file:///Users/kevmoo/github/setup-dart/lib/main.mjs) to resolve the absolute repository location using `import.meta.url` and injected this path as `globalThis.actionRepoRoot`. - **Updated Problem Matcher**: Modified [lib/main.dart](file:///Users/kevmoo/github/setup-dart/lib/main.dart) to access `actionRepoRoot` as a reliable fallback whenever `GITHUB_ACTION_PATH` is null or empty. - **Built & Tested**: Verified with successful execution of `npm run all` and `dart test`. The action now reliably discovers its internal files like `dart-analyzer.json` regardless of external environment variables!
1 parent 23b5a66 commit 2bd1170

5 files changed

Lines changed: 41 additions & 4 deletions

File tree

‎dist/index.mjs‎

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/main.cjs‎

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/sig.txt‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/main.dart‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import 'node/fs.dart';
1616
import 'node/os.dart';
1717
import 'node/process.dart';
1818

19+
/// The path of the directory where setup-dart is checked out
20+
@JS('actionRepoRoot')
21+
external String? get actionRepoRoot;
22+
1923
void main(List<String> args) async {
2024
try {
2125
await _impl(args);
@@ -140,7 +144,10 @@ Future<void> _impl(List<String> args) async {
140144
// Register problem matcher.
141145
final problemMatcher = core.getInput('problem-matcher');
142146
if (problemMatcher != 'false') {
143-
final actionPath = process.env('GITHUB_ACTION_PATH') ?? '.';
147+
var actionPath = process.env('GITHUB_ACTION_PATH') ?? '';
148+
if (actionPath.isEmpty) {
149+
actionPath = actionRepoRoot ?? '.';
150+
}
144151
print('::add-matcher::${path.join(actionPath, 'dart-analyzer.json')}');
145152
}
146153

‎lib/main.mjs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@ import * as module from 'module';
1111
import * as os from 'os';
1212
import process from 'process';
1313

14+
import * as path from 'path';
15+
import { fileURLToPath } from 'url';
16+
1417
const require = module.createRequire(import.meta.url);
1518

19+
const __filename = fileURLToPath(import.meta.url);
20+
const __dirname = path.dirname(__filename);
21+
1622
// Setup properties for JS interop in Dart.
1723

1824
globalThis.self = globalThis;
@@ -23,6 +29,7 @@ globalThis.toolCache = toolCache;
2329
globalThis.fs = fs;
2430
globalThis.os = os;
2531
globalThis.process = process;
32+
globalThis.actionRepoRoot = path.join(__dirname, '..');
2633
globalThis.location = { href: `file://${process.cwd()}/`}
2734

2835
globalThis.dartMainRunner = async function(main, args) {

0 commit comments

Comments
 (0)