Skip to content

Commit

Permalink
Use separate config directory for preview SDKs. (dart-lang#7271)
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos authored Dec 8, 2023
1 parent bba5d12 commit 5d220e8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
13 changes: 9 additions & 4 deletions Dockerfile.worker
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,32 @@ USER worker:2000
COPY --chown=worker:worker . /home/worker/pub-dev
WORKDIR /home/worker/pub-dev

# A config directory for preview SDKs.
# TODO(https://github.com/dart-lang/pub-dev/issues/7270): Use per-SDK config directory.
RUN mkdir -p /home/worker/config/preview

# Setup Dart SDK into /home/worker/dart/{stable,preview}/
RUN tool/setup-dart.sh /home/worker/dart 3.2.2
RUN mv /home/worker/dart/dart-sdk /home/worker/dart/stable
RUN tool/setup-dart.sh /home/worker/dart 3.3.0-174.2.beta
RUN tool/setup-webp.sh /home/worker/bin
RUN XDG_CONFIG_HOME=/home/worker/config/preview tool/setup-dart.sh /home/worker/dart 3.3.0-174.2.beta
RUN mv /home/worker/dart/dart-sdk /home/worker/dart/preview

# Setup Flutter SDK into /home/worker/flutter/{stable,preview}/
RUN tool/setup-flutter.sh /home/worker/flutter 3.16.2
RUN mv /home/worker/flutter/flutter /home/worker/flutter/stable
RUN tool/setup-flutter.sh /home/worker/flutter 3.18.0-0.1.pre
RUN XDG_CONFIG_HOME=/home/worker/config/preview tool/setup-flutter.sh /home/worker/flutter 3.18.0-0.1.pre
RUN mv /home/worker/flutter/flutter /home/worker/flutter/preview

# Setup webp
RUN tool/setup-webp.sh /home/worker/bin

# Configure SDKs to be used for analysis
ENV DART_SDK="/home/worker/dart/stable"
ENV FLUTTER_ROOT="/home/worker/flutter/stable"

# Use stable Dart-SDK in PATH
ENV PATH="/home/worker/bin:/home/worker/dart/stable/bin:${PATH}"


# Install dependencies for pub_worker
WORKDIR /home/worker/pub-dev/pkg/pub_worker
RUN dart pub get
Expand Down
16 changes: 15 additions & 1 deletion pkg/pub_worker/lib/src/bin/pana_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,26 @@ Future<void> main(List<String> args) async {
pubspec.flutterSdkConstraint,
);

// NOTE: This is a temporary workaround to use a different config directory for preview SDKs.
// TODO(https://github.com/dart-lang/pub-dev/issues/7270): Use per-SDK config directory.
final isPreviewSdk = flutterSdk?.version.isPreRelease ??
dartSdk?.version.isPreRelease ??
false;
final workerPreviewConfigDir = Directory('/home/worker/config/preview');
String? configDir;
if (isPreviewSdk && await workerPreviewConfigDir.exists()) {
configDir = workerPreviewConfigDir.path;
}

final toolEnv = await ToolEnvironment.create(
dartSdkDir: dartSdk?.path,
flutterSdkDir: flutterSdk?.path,
pubCacheDir: pubCache,
panaCacheDir: Platform.environment['PANA_CACHE'],
environment: {'CI': 'true'},
environment: {
'CI': 'true',
if (configDir != null) 'XDG_CONFIG_HOME': configDir,
},
useGlobalDartdoc: true,
globalDartdocVersion: '8.0.0',
);
Expand Down

0 comments on commit 5d220e8

Please sign in to comment.