Merge pull request #62 from QURIresearch/first-sprint-devops

First sprint devops
This commit is contained in:
Quinn 2022-03-24 20:25:33 -04:00 committed by GitHub
commit cfa2379a16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 467 additions and 124 deletions

BIN
.DS_Store vendored

Binary file not shown.

23
.github/CODEOWNERS vendored Normal file
View File

@ -0,0 +1,23 @@
# CODEOWNERS file
#
# This file is used to describe who owns what in this repository.
#
# For documentation on this file, see https://help.github.com/articles/about-codeowners/
# Mentioned users will get code review requests.
#
# IMPORTANT NOTE: in order to actually get pinged, commit access is required.
# This also holds true for GitHub teams.
# This file
/.github/CODEOWNERS @quinn-dougherty
# Any rescript code
*.res @Hazelfire @OAGr @quinn-dougherty
# Any typescript code
*.tsx @Hazelfire @OAGr @quinn-dougherty
# Any opsy files
*.json @quinn-dougherty
*.yaml @quinn-dougherty
*.yml @quinn-dougherty

14
.github/ISSUE_TEMPLATE/developer-bug.md vendored Normal file
View File

@ -0,0 +1,14 @@
---
name: Developer friction when contributing to Squiggle
about: Did your yarn scripts fail? Did the CI diverge from a README? Etc.
labels: 'ops'
---
# Description:
# The OS and version, yarn version, etc. in which this came up
# Desired behavior

7
.github/ISSUE_TEMPLATE/future.md vendored Normal file
View File

@ -0,0 +1,7 @@
---
name: Idea or feature request
about: Where would you like to see Squiggle go over the next few months, several months, or few years?
---
# Description

18
.github/ISSUE_TEMPLATE/user-bug.md vendored Normal file
View File

@ -0,0 +1,18 @@
---
name: Bug reports for Squiggle users
about: Rendering oddly, trouble with the playground, something like this?
labels: 'bug'
---
# Description:
# Steps to reproduce:
1.
2.
3.
# Expected behavior:
# What I got instead:

85
.github/workflows/ci.yaml vendored Normal file
View File

@ -0,0 +1,85 @@
name: Squiggle packages check
on: [push]
jobs:
pre_check:
name: Precheck for skipping redundant jobs
runs-on: ubuntu-latest
outputs:
should_skip_lang: ${{ steps.skip_lang_check.outputs.should_skip }}
should_skip_components: ${{ steps.skip_components_check.outputs.should_skip }}
should_skip_website: ${{ steps.skip_website_check.outputs.should_skip }}
steps:
- id: skip_lang_check
name: Check if the changes are about squiggle-lang src files
uses: fkirc/skip-duplicate-actions@master
with:
paths: '["packages/squiggle-lang/*"]'
- id: skip_components_check
name: Check if the changes are about components src files
uses: fkirc/skip-duplicate-actions@master
with:
paths: '["packages/components/*"]'
- id: skip_website_check
name: Check if the changes are about website src files
uses: fkirc/skip-duplicate-actions@master
with:
paths: '["packages/website/*"]'
lang-build-test:
name: Language build and test
runs-on: ubuntu-latest
needs: pre_check
if: ${{ needs.pre_check.outputs.should_skip_lang != 'true' }}
defaults:
run:
shell: bash
working-directory: packages/squiggle-lang
steps:
- uses: actions/checkout@v2
- name: Install dependencies from monorepo level
run: cd ../../ && yarn
- name: Build rescript codebase
run: yarn build
- name: Run tests
run: yarn test
- name: Run webpack
run: yarn bundle
components-build-test:
name: Components build and test
runs-on: ubuntu-latest
needs: [pre_check]
if: ${{ needs.pre_check.outputs.should_skip_components != 'true' }}
defaults:
run:
shell: bash
working-directory: packages/components
steps:
- uses: actions/checkout@v2
- name: Install dependencies from monorepo level
run: cd ../../ && yarn
- name: Build rescript in squiggle-lang
run: cd ../squiggle-lang && yarn build
- name: Run webpack
run: yarn bundle
- name: Build storybook
run: yarn build
website-build:
name: Website build
runs-on: ubuntu-latest
needs: pre_check
if: ${{ needs.pre_check.outputs.should_skip_website != 'true' }}
defaults:
run:
shell: bash
working-directory: packages/website
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: yarn
- name: Build website assets
run: yarn build

View File

@ -1,19 +0,0 @@
name: Squiggle Lang Jest Tests
on: [push]
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: packages/squiggle-lang
steps:
- uses: actions/checkout@v2
- name: Install Packages
run: yarn
- name: Build rescript
run: yarn run build
- name: Run tests
run: yarn test

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ yarn-error.log
.cache
.merlin
.parcel-cache
.DS_Store

6
.parcelrc Normal file
View File

@ -0,0 +1,6 @@
{
"extends": "@parcel/config-default",
"transformers": {
"*.res": ["@parcel/transformer-raw"]
}
}

42
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,42 @@
_The current document was written quickly and not exhaustively, yet, it's unfinished. [Template here](https://mozillascience.github.io/working-open-workshop/contributing/)_
# Contributing to Squiggle
We welcome contributions from developers, especially people in react/typescript, rescript, and interpreters/parsers. We also are keen to hear issues filed by users!
Squiggle is currently pre-alpha.
# Quick links
- [Roadmap to the alpha](https://github.com/QURIresearch/squiggle/projects/2)
- The team presently communicates via the **EA Forecasting and Epistemics** slack (channels `#squiggle` and `#squiggle-ops`), you can track down an invite by reaching out to Ozzie Gooen
- [Squiggle documentation](https://www.squiggle-language.com/docs/Language)
- [Rescript documentation](https://rescript-lang.org/docs/manual/latest/introduction)
- You can email `quinn@quantifieduncertainty.org` if you need assistance in onboarding or if you have questions
# Bug reports
Anyone (with a github account) can file an issue at any time. Please allow Quinn, Sam, and Ozzie to triage, but otherwise just follow the suggestions in the issue templates.
# Project structure
Squiggle is a **monorepo** with four **packages**.
- **components** is where we improve reactive interfacing with Squiggle
- **playground** is the site `playground.squiggle-language.com`
- **squiggle-lang** is where the magic happens: probability distributions, the interpreter, etc.
- **website** is the site `squiggle-language.com`
# Deployment ops
We use netlify, and it should only concern Quinn, Sam, and Ozzie.
# Development environment, building, testing, dev server
You need `yarn`.
TODO: fill this out based on all the different packages scripts once they cool down.
# Pull request protocol
Please work against `staging` branch. **Do not** work against `master`. Please do not merge without approval from some subset of Quinn, Sam, and Ozzie; they will be auto-pinged.

View File

@ -1,32 +1,43 @@
# Squiggle
This is an experiment DSL/language for making probabilistic estimates.
This is an experiment DSL/language for making probabilistic estimates. The full story can be found [here](https://www.lesswrong.com/s/rDe8QE5NvXcZYzgZ3).
This monorepo has several packages that can be used for various purposes. All
the packages can be found in `packages`.
`@squiggle/lang` in `packages/squiggle-lang` contains the core language, particularly
- `@quri/squiggle-lang` in `packages/squiggle-lang` contains the core language, particularly
an interface to parse squiggle expressions and return descriptions of distributions
or results.
`@squiggle/components` in `packages/components` contains React components that
- `@quri/squiggle-components` in `packages/components` contains React components that
can be passed squiggle strings as props, and return a presentation of the result
of the calculation.
`@squiggle/playground` in `packages/playground` contains a website for a playground
- `@quri/playground` in `packages/playground` contains a website for a playground
for squiggle. This website is hosted at `playground.squiggle-language.com`
`@squiggle/website` in `packages/website` The main descriptive website for squiggle,
- `@quri/squiggle-website` in `packages/website` The main descriptive website for squiggle,
it is hosted at `squiggle-language.com`.
The playground depends on the components library which then depends on the language.
This means that if you wish to work on the components library, you will need
to package the language, and for the playground to work, you will need to package
the components library and the playground.
The playground depends on the components library which then depends on the language. This means that if you wish to work on the components library, you will need to build (no need to bundle) the language, and as of this writing playground doesn't really work.
Scripts are available for you in the root directory to do important activities,
such as:
# Develop
`yarn build:lang`. Builds and packages the language
`yarn storybook:components`. Hosts the component storybook
For any project in the repo, begin by running `yarn` in the top level (TODO: is this true?)
``` sh
yarn
```
See `packages/*/README.md` to work with whatever project you're interested in.
## `codium` for `rescript`
If you have `nix` installed with `flakes` enabled, you can build a `codium` in this repo for `rescript` development, if you don't want to pollute your machine's global editor with another mode/extension.
``` sh
nix develop
codium
```
The `nix develop` shell also provides `yarn`.
# Contributing
See `CONTRIBUTING.md`.

9
flake-compat.nix Normal file
View File

@ -0,0 +1,9 @@
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
inherit (lock.nodes.flake-compat.locked) owner repo rev narHash;
flake-compat = builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
sha256 = narHash;
};
in
import flake-compat { src = ./.; }

44
flake.lock Normal file
View File

@ -0,0 +1,44 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1641205782,
"narHash": "sha256-4jY7RCWUoZ9cKD8co0/4tFARpWB+57+r1bLLvXNJliY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b7547d3eed6f32d06102ead8991ec52ab0a4f1a7",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1647893727,
"narHash": "sha256-pOi7VdCb+s5Cwh5CS7YEZVRgH9uCmE87J5W7iXv29Ck=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "1ec61dd4167f04be8d05c45780818826132eea0d",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

93
flake.nix Normal file
View File

@ -0,0 +1,93 @@
{
description = "Building codium for rescript development";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs =
{ self
, nixpkgs
, flake-compat
}:
let
# Generate a user-friendly version number.
version = builtins.substring 0 8 self.lastModifiedDate;
# System types to support.
supportedSystems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
# Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (system:
import nixpkgs {
inherit system;
overlays = [ self.overlay ];
});
in
{
overlay = final: prev: { };
# the default devShell used when running `nix develop`
devShell = forAllSystems (system: self.devShells.${system}.defaultShell);
devShells = forAllSystems (system:
let
pkgs = nixpkgsFor."${system}";
in
{
# In case we don't want to provide an editor, this defaultShell will provide only coq packages we need.
defaultShell = pkgs.mkShell {
buildInputs = with pkgs; [
yarn
yarn2nix
nodePackages.npm
nodejs
(pkgs.vscode-with-extensions.override {
vscode = pkgs.vscodium;
vscodeExtensions = pkgs.vscode-utils.extensionsFromVscodeMarketplace [
{
name = "rescript-vscode";
publisher = "chenglou92";
version = "1.2.1";
sha256 = "sha256-7/YakKtJ4WhgAR4rZltrq8g4TtM5QZ2spbrEUrNoXVg=";
}
{
name = "vim";
publisher = "vscodevim";
version = "1.22.2";
sha256 = "sha256-dtIlgODzRdoMKnG9050ZcCX3w15A/R3FaMc+ZylvBbU=";
}
{
name = "vscode-typescript-next";
publisher = "ms-vscode";
version = "4.7.20220323";
sha256 = "sha256-mjiBCyg5As/XAU9I5k6jEZWGJA3P6P5o1roe2bS7aUI=";
}
{
name = "nix-ide";
publisher = "jnoortheen";
version = "0.1.20";
sha256 = "sha256-Q6X41I68m0jaCXaQGEFOoAbSUrr/wFhfCH5KrduOtZo=";
}
{
name = "json";
publisher = "ZainChen";
version = "2.0.2";
sha256 = "sha256-nC3Q8KuCtn/jg1j/NaAxWGvnKe/ykrPm2PUjfsJz8aI=";
}
{
name = "prettier-vscode";
publisher = "esbenp";
version = "9.3.0";
sha256 = "sha256-hJgPjWf7a8+ltjmXTK8U/MwqgIZqBjmcCfHsAk2G3PA=";
}
];
})
];
};
}
);
};
}

View File

@ -2,14 +2,7 @@
"private": true,
"name": "squiggle",
"scripts": {
"build:lang": "cd packages/squiggle-lang && yarn && yarn build && yarn package",
"storybook:components": "cd packages/components && yarn && yarn storybook",
"build-storybook:components": "cd packages/components && yarn && yarn build-storybook",
"build:components": "cd packages/components && yarn && yarn package",
"build:playground": "cd packages/playground && yarn && yarn parcel-build",
"ci:lang": "yarn workspace @squiggle/lang ci",
"ci:components": "yarn ci:lang && yarn workspace @squiggle/components ci",
"ci:playground": "yarn ci:components && yarn workspace @squiggle/playground ci"
"nodeclean": "rm -r node_modules && rm -r packages/*/node_modules"
},
"workspaces": [
"packages/*"

View File

@ -1,15 +1,11 @@
//const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const custom = require('../webpack.config.js');
module.exports = {
/* webpackFinal: async (config) => {
config.resolve.plugins = [
...(config.resolve.plugins || []),
new TsconfigPathsPlugin({
extensions: config.resolve.extensions,
}),
];
return config;
},*/
webpackFinal: async (config) => {
config.resolve.alias = custom.resolve.alias;
return { ...config, module: { ...config.module, rules: config.module.rules.concat(custom.module.rules) } };
},
"stories": [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"

View File

@ -1,6 +1,25 @@
# Squiggle Components
This package contains all the components for squiggle. These can be used either as a library or hosted as a [storybook](https://storybook.js.org/).
This package contains all the components for squiggle. These can be used either
as a library or hosted as a [storybook](https://storybook.js.org/).
# Build for development
We assume that you had run `yarn` at monorepo level, installing dependencies.
To run the storybook, run `yarn` then `yarn storybook`.
You need to _prepare_ by building and bundling `squiggle-lang`
``` sh
cd ../squiggle-lang
yarn build
```
If you've otherwise done this recently you can skip those.
Run a development server
``` sh
yarn start
```
And build artefacts for production,
``` sh
yarn bundle # builds components library
yarn build # builds storybook app
```

View File

@ -26,10 +26,10 @@
"webpack-cli": "^4.9.2"
},
"scripts": {
"storybook": "cross-env REACT_APP_FAST_REFRESH=false && start-storybook -p 6006 -s public",
"build-storybook": "build-storybook -s public",
"package": "tsc",
"ci": "yarn package"
"start": "cross-env REACT_APP_FAST_REFRESH=false && start-storybook -p 6006 -s public",
"build": "build-storybook -s public",
"bundle": "webpack",
"all": "yarn bundle && yarn build"
},
"eslintConfig": {
"extends": [
@ -80,7 +80,6 @@
"@types/react": "17.0.39"
},
"source": "./src/index.ts",
"module": "dist/index.js",
"main": "dist/bundle.js",
"types": "dist/index.d.ts"
"types": "dist/src/index.d.ts"
}

View File

@ -1,5 +0,0 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
name = "squiggle-components";
buildInputs = with pkgs; [ nodePackages.yarn nodejs ];
}

View File

@ -10,7 +10,7 @@ import type {
} from "@quri/squiggle-lang";
import { createClassFromSpec } from "react-vega";
import * as chartSpecification from "./spec-distributions.json";
import * as percentilesSpec from "./spec-pertentiles.json";
import * as percentilesSpec from "./spec-percentiles.json";
let SquiggleVegaChart = createClassFromSpec({
spec: chartSpecification as Spec,

View File

@ -1,5 +1,8 @@
{
"compilerOptions": {
"paths": {
"@quri/squiggle-lang": ["../squiggle-lang/src/js"]
},
"module": "commonjs",
"jsx": "react",
"resolveJsonModule": true,
@ -7,12 +10,19 @@
"esModuleInterop": true,
"removeComments": true,
"preserveConstEnums": true,
"composite": true,
"outDir": "./dist",
"declarationDir": "./dist",
"declaration": true,
"sourceMap": true
},
"files": ["src/spec-distributions.json","src/spec-percentiles.json"],
"target": "ES6",
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
"include": ["src/**/*", "src/*"],
"exclude": ["node_modules", "**/*.spec.ts"],
"references": [
{
"path": "../squiggle-lang"
}
]
}

View File

@ -8,13 +8,17 @@ module.exports = {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
loader: "ts-loader",
options: { projectReferences: true },
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".js", ".tsx", ".ts"],
alias: {
"@quri/squiggle-lang": path.resolve(__dirname, '../squiggle-lang/src/js')
},
},
output: {
filename: "bundle.js",

View File

@ -1,9 +1,11 @@
# TODO: REVIVE PLAYGROUND.
# Squiggle Playground
This repository contains the squiggle playground, a small web interface
for playing around with squiggle concepts.
It depends on `@squiggle/components` and `@squiggle/lang` so both of them will
It depends on `@quri/squiggle-components` and `@quri/squiggle-lang` so both of them will
need to be packaged for this to work. This can be done from the root directory
with

View File

@ -1,5 +0,0 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
name = "squiggle";
buildInputs = with pkgs; [ yarn yarn2nix nodePackages.npm ];
}

View File

@ -1,5 +1,5 @@
import { FC, useState } from "react"
import { SquiggleChart } from "@squiggle/components"
import { SquiggleChart } from "@quri/squiggle-components"
import { CodeEditor } from "./CodeEditor"
import { Form, Input, Card, Row, Col } from "antd"
import { css } from '@emotion/react'

View File

@ -1,9 +1,28 @@
# Squiggle language
# Build for development
We assume that you ran `yarn` at the monorepo level.
``` sh
yarn build
```
`yarn bundle` is needed for a deployment.
Other:
``` sh
yarn start # listens to files and recompiles at every mutation
yarn test
yarn test:watch # keeps an active session and runs all tests at every mutation
```
# TODO: clean up this README.md
# Squiggle Language
Squiggle is a language for representing probability distributions, as well as
functions that return probability distributions. Its original intended use is
for improving epistemics around EA decisions.
This package, @squiggle/lang, contains the core language of squiggle. The main
This package, @quri/squiggle-lang, contains the core language of squiggle. The main
feature revolves around evaluating squiggle expressions. Currently the package
only exports a single function, named "run", which from a squiggle string returns
an object representing the result of the evaluation.

View File

@ -1,5 +1,5 @@
{
"name": "@squiggle/lang",
"name": "@quri/squiggle-lang",
"reason": {},
"sources": [
{

View File

@ -1,18 +1,15 @@
{
"name": "@quri/squiggle-lang",
"version": "0.2.2",
"homepage": "https://foretold-app.github.io/estiband/",
"homepage": "https://squiggle-language.com",
"scripts": {
"build": "rescript build -with-deps",
"bundle": "tsc && webpack",
"bundle": "webpack",
"start": "rescript build -w -with-deps",
"clean": "rescript clean",
"test": "jest",
"test:ci": "yarn jest ./__tests__/Lodash__test.re",
"watch:test": "jest --watchAll",
"watch:s": "yarn jest -- Converter_test --watch",
"package": "tsc",
"ci": "yarn build && yarn package"
"test:watch": "jest --watchAll",
"all": "yarn build && yarn bundle && yarn test"
},
"keywords": [
"Rescript"

View File

@ -1,5 +0,0 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
name = "squiggle";
buildInputs = with pkgs; [ yarn yarn2nix nodePackages.npm ];
}

View File

@ -1,6 +1,6 @@
import {runAll} from '../rescript/ProgramEvaluator.gen';
import type { Inputs_SamplingInputs_t as SamplingInputs,exportEnv, exportType, exportDistribution} from '../rescript/ProgramEvaluator.gen';
export type { SamplingInputs , exportEnv, exportDistribution }
import type { Inputs_SamplingInputs_t as SamplingInputs, exportEnv, exportType, exportDistribution} from '../rescript/ProgramEvaluator.gen';
export type { SamplingInputs, exportEnv, exportDistribution }
export type {t as DistPlus} from '../rescript/pointSetDist/DistPlus.gen';
export let defaultSamplingInputs : SamplingInputs = {

View File

@ -9,7 +9,8 @@
"sourceMap": true,
"outDir": "./dist",
"declarationDir": "./dist",
"declaration": true
"declaration": true,
"composite": true
},
"target": "ES6",
"include": ["src/**/*"],

View File

@ -4,38 +4,32 @@ This website is built using [Docusaurus 2](https://docusaurus.io/), a modern sta
### Installation
```
$ yarn
``` sh
yarn
```
### Local Development
```
$ yarn start
``` sh
yarn start
```
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
### Build
```
$ yarn build
``` sh
yarn build
```
This command generates static content into the `build` directory and can be served using any static contents hosting service.
### Deployment
### Clean
Using SSH:
```
$ USE_SSH=true yarn deploy
Clean up the build artefacts.
``` sh
yarn clean
```
Not using SSH:
```
$ GIT_USER=<Your GitHub username> yarn deploy
```
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
# TODO: unify formatting across `packages/*/README.md`
# TODO: build docs in `ci.yaml`.

View File

@ -3,15 +3,10 @@
"version": "0.0.0",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids"
"clean": "docusaurus clear",
"all": "yarn build"
},
"dependencies": {
"@docusaurus/core": "2.0.0-beta.15",

View File

@ -1,5 +0,0 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
name = "squiggle-root";
buildInputs = with pkgs; [ nodePackages.yarn ];
}