Skip to content

Commit

Permalink
cleanup and check hash
Browse files Browse the repository at this point in the history
  • Loading branch information
dcharkes committed Jan 6, 2025
1 parent d65b97c commit 6cdcfa5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
14 changes: 2 additions & 12 deletions .github/workflows/download_asset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:

- run: dart pub get

# Keep this list consistent with pkgs/native_assets_cli/example/build/download_asset/lib/src/hook_helpers/target_versions.dart
- name: Build Linux host
if: matrix.os == 'ubuntu'
run: |
Expand Down Expand Up @@ -86,7 +87,7 @@ jobs:
pkgs/native_assets_cli/example/build/download_asset/.dart_tool/download_asset/**/*.so
if-no-files-found: error

check:
release:
needs: build
runs-on: ubuntu-latest

Expand All @@ -108,17 +109,6 @@ jobs:
- name: Display structure of downloaded assets
run: ls -R .dart_tool/download_asset/

# - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
# with:
# sdk: stable

# - run: dart pub get

# - name: Check hashes of released artifacts
# run: |
# dart tool/generate_asset_hashes.dart
# git diff --exit-code

- name: Release
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8
if: startsWith(github.ref, 'refs/tags/download_asset-prebuild-assets')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Run tests with `dart --enable-experiment=native-assets test`.

A typical layout of a package which downloads assets:

* `tool/build.dart` prebuilts assets and is exercised from a GitHub workflow.
* A [github workflow](../../../../../.github/workflows/native.yaml) that builds assets.
* `hook/build.dart` downloads the prebuilt assets.
* `lib/` contains Dart code which uses the assets.
* `tool/build.dart` prebuilts assets and is exercised from the GitHub CI.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'dart:io';

import 'package:download_asset/src/hook_helpers/c_build.dart';
import 'package:download_asset/src/hook_helpers/download.dart';
import 'package:download_asset/src/hook_helpers/hashes.dart';
import 'package:native_assets_cli/code_assets_builder.dart';
import 'package:native_assets_cli/native_assets_cli.dart';

Expand All @@ -30,6 +31,15 @@ void main(List<String> args) async {
iOSSdk,
outputDirectory,
);
final fileHash = await hashAsset(file);
final expectedHash = assetHashes[createTargetName(
targetOS.name,
targetArchitecture.name,
iOSSdk?.type,
)];
if (fileHash != expectedHash) {
throw Exception('File $file was not downloaded correctly.');
}
output.codeAssets.add(CodeAsset(
package: config.packageName,
name: 'native_add.dart',
Expand Down

0 comments on commit 6cdcfa5

Please sign in to comment.