dart-sdk/tools/bots
Ömer Sinan Ağacan affc3392a0 [dart2wasm] Implement Wasm FfiNative support
This CL introduces a new kernel-to-kernel pass in Wasm backend to
compile `FfiNative`-annotated external functions to external functions
with `wasm:import` pragmas.

The new pass `WasmFfiNativeTransformer` extends `FfiNativeTransformer`.
Some `FfiNativeTransformer` methods made public to allow reuse in the
pass.

The conversion works like this: when we see a member like:

    @FfiNative<Int8 Function(Int8, Int8)>("ffi.addInt8")
    external int addInt8(int a, int b);

We generate a Wasm import using Wasm ABI types according to emscripten
calling conventions:

    @pragma('wasm:import', 'ffi.addInt8')
    external static WasmI32 addInt8_$import(WasmI32 a, WasmI32 b);

and convert the original member (`addInt8()`) to a wrapper function that
calls the Wasm import, converting the arguments and return values to
Dart types:

    static int addInt8(int a, int b) {
      return WasmI32.toIntSigned(
        addInt8_$import(
            WasmI32::int8FromInt(a),
            WasmI32::int8FromInt(b),
        ));
    }

Build, test, and CI changes:

- Test runner now uses `// SharedObjects=...` lines in dart2wasm tests
  to pass extra Wasm modules to d8 command used to run the tests.

  Support for `// SharedObjects=...` lines were already used in
  native/AOT FFI tests, not added in this CL. We just start to use those
  lines in dart2wasm tests.

- dart2wasm gn file updated with a target "test_wasm_modules" that
  builds FFI test Wasm modules to Wasm using emcc (emscripten C
  compiler).

- CI dart2wasm_hostasserts configuration updated to copy the Wasm files
  generated by the "test_wasm_modules" target to the shards.

TEST=tests/web/wasm/ffi_native_test

Change-Id: I6527fe4e2ca2b582e16d84fee244e9cbe6dee307
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252822
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2022-09-23 09:41:22 +00:00
..
flutter Remove a few uses of bin/pub 2022-02-09 17:13:37 +00:00
lib/src Migrate several files in tools/. 2022-06-10 16:31:04 +00:00
__init__.py
bot_utils.py [infra] Upload RISCV64 SDK. 2022-03-30 22:18:50 +00:00
compare_results.dart [tools] migrate the rest of tools/ to null safety 2022-06-24 16:38:39 +00:00
dart_sdk.py [infra] Allow upload of SDK to CIPD to fail in SDK builders 2022-03-15 17:27:18 +00:00
dartdoc_footer.html
dartdoc_footer_text.html Bump dartdoc to ab98003fc368f484fcc4c055770adea47bc83fbd 2020-09-10 02:20:30 +00:00
extend_results.dart [tools] migrate the rest of tools/ to null safety 2022-06-24 16:38:39 +00:00
find_base_commit.dart Revert "[infra] Add dart_ci scripts to Dart SDK DEPS" 2022-08-31 15:47:29 +00:00
get_builder_status.dart [infra] Remove old pub/sub processing of results 2021-12-02 13:14:27 +00:00
pub_integration_test.py Remove a few uses of bin/pub 2022-02-09 17:13:37 +00:00
README.md [infra] Remove obsolete "global" key from the test_matrix.json 2021-06-23 14:53:52 +00:00
test_matrix.json [dart2wasm] Implement Wasm FfiNative support 2022-09-23 09:41:22 +00:00
try_benchmarks.sh Move swarm to a test folder to avoid confusion that this might 2022-09-07 14:08:18 +00:00
update_blamelists.dart [tools] migrate the rest of tools/ to null safety 2022-06-24 16:38:39 +00:00
update_flakiness.dart [tools] migrate the rest of tools/ to null safety 2022-06-24 16:38:39 +00:00

tools/bots

This folder contains scripts and configuration files used by Dart's continuous integration and testing infrastructure.

Test matrix

The file test_matrix.json defines the test configurations run by Dart's CI infrastructure. Changes to the test matrix affect all builds that include them.

Structure

The test matrix is a JSON document and consists of the "filesets" object, the "configurations" list, and the "builder_configurations" list as well as a "branches" list.

Filesets

The file sets define files and/or directories that need to be present for a test configuration at runtime. Any directory specified will be included along with its subdirectories recursively. Directory names must have a / at the end. All paths are relative to the SDK checkout's root directory.

"filesets": {
  "a_fileset_name": [
    "a/directory/",
    "a/file"
  ],
  "another_fileset_name": [
    "another/directory/",
    "another/file"
  ]
}

Configurations

The configurations describe all named configurations that the CI infrastructure supports. It consists of a list of configuration descriptions.

Each configuration description defines one or more configuration names using a simple template syntax, where a group (a|b|c) means taking each of the options for a different configuration name. The set of all configuration names is the result of picking each combination of group options.

The configuration name implicitly defines the options of the configuration (system, architecture, compiler, etc.), but additional options can be given in an options field.

"configurations": {
  "unittest-(linux|win|mac)": {
    "options": {
      "compiler": "dartk",
      "mode": "release",
}},

Builder Configurations

The builder configurations describes all test configurations a specific builder must execute. Each builder configuration is an object that specifies which builders it applies to, defines the build steps for the builders, and some additional metadata. Only one builder configuration can apply to a builder.

"builder_configurations": [
  {
    "builders": [
      "a-builder",
      "another-builder"
    ],
    "meta": {
      "description": "Description of this configuration."
    },
    "steps": [
    ]
  }
]

Each step is an object and must have a name. A step may also specify a script to run instead of the default script: tools/test.py. Additional arguments may be specified. These arguments will be passed to the script.

Inside arguments, the following variables will be expanded to values extracted from the builder name:

  • ${mode}: the mode in which to run the tests; e.g., release, debug
  • ${arch}: architecture to run the tests on; e.g., ia32, x64
  • $[system}: the system on which to run the tests; e.g., win, linux, mac
  • ${runtime}: the runtime to use to run the tests; e.g., vm, chrome, d8
"steps": [
  {
    "name": "build it",
    "script": "tools/build.py",
    "arguments": ["--a-flag", "target", "another_target"]
  },
  {
    "name": "test it",
    "arguments": ["-nconfiguration-${system}"]
  }
]

A step that uses the script tools/test.py either explicitely or by default is called a "test step". Test steps must include the -n command line argument to select one of the named configurations defined in the configurations section.

A step using the default script may also be sharded across many machines using the "shards" parameter. If a step is sharded, it must specify a "fileset". Only the files and directories defined by the file set will be available to the script when it's running on a shard.

{
  "name": "shard the tests",
  "shards": 10,
  "fileset": "a_fileset_name"
}

Builders

Builder name parsing

The builder names are split by '-' and each part is then examined if it is an option. Options can be runtimes (e.g. "chrome"), architectures (e.g. x64) and operating system families (e.g. win). For each valid option, additional arguments are passed to the tools/build.py script.

Adding a new builder

To add a builder:

  1. Decide on a name.
  2. Add the builder name to a new or existing configuration.
  3. File an issue labelled "area-infrastructure" to get your builder activated.

Testing a new or modified builder

Builders can be tested using a tool called led that is included in depot_tools. Replace buildername and CL number with the correct values and run:

led get-builder luci.dart.ci:<builder name> | \
led edit-cr-cl 'https://dart-review.googlesource.com/c/<cl number>' | \
led launch

Adding a builder to the commit queue

For now, file an issue labeled "area-infrastructure" to get your builder added to the commit queue.

Glossary

Builder

A builder has a name and defines the steps the need to be run when it is executed by a bot. In general, a builder defines how to build and test software.

Bot

A physical or virtual machine (or even a docker container) that executes all commands it receives. Often, these commands are the steps defined by a builder.

Sharding

Sharded steps copy all files in a file set to as many bots as specified and runs the same command on all of the shards. Each shard has a shard number. The shard number and the total number of shards are passed as arguments to the command. The command is then responsible for running a subset of its work on each shard based on these arguments.