Skip to content

Commit

Permalink
Merge feat/nm_ci into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jtacoma committed Oct 3, 2020
2 parents 398d618 + b2d041c commit 1178699
Show file tree
Hide file tree
Showing 48 changed files with 1,856 additions and 403 deletions.
11 changes: 11 additions & 0 deletions .gpm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
packages:
- path: packages/nm_delta
test:
steps:
- run: dart test --coverage=coverage
- run: format_coverage --in=coverage --packages=.packages --report-on=lib --lcov --out=coverage.lcov
- path: packages/nm_delta_notus
test:
steps:
- run: dart test --coverage=coverage
- run: format_coverage --in=coverage --packages=.packages --report-on=lib --lcov --out=coverage.lcov
46 changes: 36 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 Google LLC
# Copyright 2019-2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,12 +12,38 @@
# See the License for the specific language governing permissions and
# limitations under the License.

language: go
go:
- 1.x
before_install:
- go get github.com/mattn/goveralls
script:
- ./githooks/pre-commit
- go test -cpu 1,4 -race -v ./...
- ./build/ci/travis-coverage
os:
- linux

addons:
apt:
packages:
- lcov

matrix:
include:
- language: go
go:
- 1.x
- 1.14
before_install:
- go get github.com/mattn/goveralls
script:
- ./githooks/pre-commit
- go test -cpu 1,4 -race -v ./...
- ./build/ci/travis-coverage
- language: dart
dart:
- stable
- dev
cache:
directories:
- $HOME/.pub-cache
script:
- pub global activate coverage
- pub global activate coveralls
- pub global activate gpm ^0.2.1
- pub global run gpm get
- pub global run gpm test --platform=vm
- ./build/ci/collect-dart-coverage-lcov
- pub global run coveralls dart-coverage.lcov
6 changes: 6 additions & 0 deletions build/ci/collect-dart-coverage-lcov
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

find packages -name coverage.lcov | while read filename ; do
sed -e 's/^SF:.*\/packages\//SF:packages\//' < "${filename}" > "${filename}.relative"
done
find packages -name coverage.lcov.relative -exec echo -a {} \; | xargs lcov -o dart-coverage.lcov
69 changes: 69 additions & 0 deletions docs/data-model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Note Maps: Data Model

A **note map** is a a collection of *notes*.

A **note** has the following properties.

* **ID**: a string that uniquely identifies this note within its note map.
* `si`: **subject identifiers**: a sequence of IRIs that globally uniquely
identify the subject of this note.
* `c`: **content IDs**: a sequence of note IDs for notes that together are
the *content* of this note.
* `t`: **type IDs**: a sequence of note IDs for notes that describe the
*type* of the subject of this note.
* `v`: **value**: an optional string, any valid Unicode string, required if
*value type ID* is present.
* `vt`: **value type ID**: an optional note ID for a note that describes the
data type of the *value* string.
* `a`: **association ID**: an optional note ID for a note that describes an
association between subjects, required if **player ID** is present.
* `ap`: **player ID**: an optional note ID for a note that describes a
subject that plays a role in an association, required if **association ID**
is present.

Additional constraints:

* In some cases, it may be more convenient to embed whole notes instead of
note IDs.
* When creating new notes, it may be easier sometimes to leave IDs
unspecified.
* For any note that has both an *association ID* and a *role ID*, that note's
*ID* should be present in the *content IDs* of the corresponding
association and role notes.

Example, in JSON:

```json
{
"id": "111"
"si": ["https://git-scm.com"],
"c": [
{
"t": ["name"],
"v": "git"
},
{
"v": "A distributed version-control system."
},
{
"ap": "111",
"a": {
"c": [
{
"t": ["name"],
"v": "software"
}
]
}
}
]
}
```

The example above could hypothetically be rendered as:

> ### git
>
> A distributed version-control system.
>
> *example..type:* **software**
9 changes: 7 additions & 2 deletions githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ exec 1>&2
# If there are whitespace errors, print the offending file names and fail.
git diff-index --check --cached $against -- || ( echo "found whitespace errors" ; exit 1 )

# Find relevant packages.
gopkgs="$(go list ./... | grep -v 'vendor|third_party')"
dartpkgs="$(ls -d ./packages/* )"

gofmt -d . 2>&1 || ( echo "gofmt found diffs" ; exit 1 )
# Fail if automatic formatting would change anything
[[ "$(type -P gofmt)" ]] && gofmt -d . 2>&1 || ( echo "gofmt would change some files" ; exit 1 )
#[[ "$(type -P flutter)" ]] && flutter format --dry-run --set-exit-if-changed ./packages > /dev/null || ( echo "flutter format would change some files" ; exit 1 )

go test -timeout 30s -short ${gopkgs} || ( echo "go test failed" ; exit 1 )
# Run tests, but quickly.
#go test -timeout 30s -short ${gopkgs} || ( echo "go test failed" ; exit 1 )
16 changes: 3 additions & 13 deletions packages/nm_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import 'package:nm_gql_go_link/nm_gql_go_link.dart';
import 'package:nm_gql_go_link/note_graphql.dart';
import 'package:quilljs_webview/quilljs_webview.dart';

import 'src/editor_page.dart';

void main() {
runApp(NmApp());
}
Expand All @@ -37,7 +39,7 @@ class NmApp extends StatelessWidget {
initialRoute: '/',
routes: {
'/': (context) => NmHomePage(title: 'Note Maps'),
'/editor': (context) => NmEditor(),
'/editor': (context) => EditorPage(),
},
);
}
Expand Down Expand Up @@ -116,15 +118,3 @@ class _NmHomePageState extends State<NmHomePage> {
);
}
}

class NmEditor extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Editor'),
),
body: QuillJSWebView(),
);
}
}
81 changes: 81 additions & 0 deletions packages/nm_app/lib/src/editor_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'dart:convert';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:nm_delta/nm_delta.dart';
import 'package:nm_delta_notus/nm_delta_notus.dart';
import 'package:quill_delta/quill_delta.dart';
import 'package:zefyr/zefyr.dart';

class EditorPage extends StatefulWidget {
@override
EditorPageState createState() => EditorPageState();
}

class EditorPageState extends State<EditorPage> {
ZefyrController _controller;
FocusNode _focusNode;
NoteMapNotusDocument _noteMapNotusDocument;

@override
void initState() {
super.initState();
_focusNode = FocusNode();
_noteMapNotusDocument = NoteMapNotusDocument('prototype-root-node-id');
_controller = ZefyrController(_noteMapNotusDocument.notusDocument);
}

@override
Widget build(BuildContext context) {
final body = (_controller == null)
? Center(child: CircularProgressIndicator())
: ZefyrScaffold(
child: ZefyrEditor(
padding: EdgeInsets.all(16),
controller: _controller,
focusNode: _focusNode,
),
);

return Scaffold(
appBar: AppBar(
title: Text('Note Maps'),
actions: <Widget>[
Builder(
builder: (context) => IconButton(
icon: Icon(Icons.save),
onPressed: () => _saveDocument(context),
),
)
],
),
body: body,
);
}

void _saveDocument(BuildContext context) {
// Notus documents can be easily serialized to JSON by passing to
// `jsonEncode` directly:
final contents = jsonEncode(_controller.document);
// For this example we save our document to a temporary file.
final file = File(Directory.systemTemp.path + '/quick_start.json');
// And show a snack bar on success.
file.writeAsString(contents).then((_) {
Scaffold.of(context).showSnackBar(SnackBar(content: Text('Saved.')));
});
}
}
4 changes: 4 additions & 0 deletions packages/nm_app/linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
#include "generated_plugin_registrant.h"

#include <nm_gql_go_link/nm_gql_go_link_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) nm_gql_go_link_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "NmGqlGoLinkPlugin");
nm_gql_go_link_plugin_register_with_registrar(nm_gql_go_link_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
}
1 change: 1 addition & 0 deletions packages/nm_app/linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

list(APPEND FLUTTER_PLUGIN_LIST
nm_gql_go_link
url_launcher_linux
)

set(PLUGIN_BUNDLED_LIBRARIES)
Expand Down
2 changes: 2 additions & 0 deletions packages/nm_app/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import FlutterMacOS
import Foundation

import nm_gql_go_link
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
NmGqlGoLinkPlugin.register(with: registry.registrar(forPlugin: "NmGqlGoLinkPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}
11 changes: 11 additions & 0 deletions packages/nm_app/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,31 @@ PODS:
- FlutterMacOS (1.0.0)
- nm_gql_go_link (0.0.1):
- FlutterMacOS
- url_launcher (0.0.1)
- url_launcher_macos (0.0.1):
- FlutterMacOS

DEPENDENCIES:
- FlutterMacOS (from `Flutter/ephemeral/.symlinks/flutter/darwin-x64`)
- nm_gql_go_link (from `Flutter/ephemeral/.symlinks/plugins/nm_gql_go_link/macos`)
- url_launcher (from `Flutter/ephemeral/.symlinks/plugins/url_launcher/macos`)
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)

EXTERNAL SOURCES:
FlutterMacOS:
:path: Flutter/ephemeral/.symlinks/flutter/darwin-x64
nm_gql_go_link:
:path: Flutter/ephemeral/.symlinks/plugins/nm_gql_go_link/macos
url_launcher:
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher/macos
url_launcher_macos:
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos

SPEC CHECKSUMS:
FlutterMacOS: 15bea8a44d2fa024068daa0140371c020b4b6ff9
nm_gql_go_link: 82d50f765447bb387c3c8245a28e1fbcb3da7efb
url_launcher: af78307ef9bafff91273b34f1c6c0c86a0004fd7
url_launcher_macos: 45af3d61de06997666568a7149c1be98b41c95d4

PODFILE CHECKSUM: d8ba9b3e9e93c62c74a660b46c6fcb09f03991a7

Expand Down

0 comments on commit 1178699

Please sign in to comment.