Permalink
Browse files

circle: improved workflow, app cleanup, refactors

Squashed commit of the following:

commit 341bed7bc89572cb410dda494c34ed3980b4fe38
Author: Matt Lewis <matt@mplewis.com>
Date:   Mon Sep 11 01:35:43 2017 -0600

    circle: rename workflow

commit fd6d380ed6d3dae65cc8c4355ca1ccb716f5eb7b
Author: Matt Lewis <matt@mplewis.com>
Date:   Mon Sep 11 01:32:30 2017 -0600

    circle: parallel jobs

commit 9a6a6e9e731fdfab735df5a48631c4945a7464d4
Author: Matt Lewis <matt@mplewis.com>
Date:   Mon Sep 11 01:13:32 2017 -0600

    fixtures: update with linux examples

commit 952f889093cfe4c147dd662e044219ee5c35dd1a
Author: Matt Lewis <matt@mplewis.com>
Date:   Mon Sep 11 01:04:02 2017 -0600

    script: fix wget

commit 38706f1b82beeb88986cce1da7f9b3b7d04efa63
Author: Matt Lewis <matt@mplewis.com>
Date:   Mon Sep 11 01:03:06 2017 -0600

    utils: script perms

commit cda9113543f718fbd1c446456b4971a13d174fee
Author: Matt Lewis <matt@mplewis.com>
Date:   Mon Sep 11 01:01:58 2017 -0600

    circle: fix utils path

commit fb6fbf8bdfbf63fd5ffab6dcf6d3cc95b643c033
Author: Matt Lewis <matt@mplewis.com>
Date:   Mon Sep 11 01:00:37 2017 -0600

    circle: fix working directory

commit 3a906a966e52905dd2a9eec89864165996a8a03f
Author: Matt Lewis <matt@mplewis.com>
Date:   Mon Sep 11 00:59:10 2017 -0600

    test: fira code install, cleanup

commit c623ed5839b0cac2c68b8a20ded9829c567439a8
Author: Matt Lewis <matt@mplewis.com>
Date:   Mon Sep 11 00:48:47 2017 -0600

    circle: cleanup

commit 73eb06a1fc23c723b008a2274d7349feea22c345
Author: Matt Lewis <matt@mplewis.com>
Date:   Mon Sep 11 00:48:26 2017 -0600

    artifacts: store

commit f1bee79f9e94fbd4c786f0f8a43ca6103b5189dc
Author: Matt Lewis <matt@mplewis.com>
Date:   Mon Sep 11 00:46:43 2017 -0600

    circle: no sudo

commit 4ea01c31ccd6f6dacdbb6915fe29fdd7fe31358b
Author: Matt Lewis <matt@mplewis.com>
Date:   Mon Sep 11 00:45:36 2017 -0600

    circle: apt get install imagemagick

commit 8a9013eb78d1296973ed8e0e60bee73082adac0f
Author: Matt Lewis <matt@mplewis.com>
Date:   Sun Sep 10 22:09:54 2017 -0600

    test: log identical

commit 20b159d2ecca5f1d56ae1f0787ced9246eefd7c6
Author: Matt Lewis <matt@mplewis.com>
Date:   Sun Sep 10 22:07:21 2017 -0600

    camera: create directories, spec debug

commit 77df9769b39c3011ac4c8561b7fdb7f2681b17f1
Author: Matt Lewis <matt@mplewis.com>
Date:   Sun Sep 10 22:03:50 2017 -0600

    args: no sandbox in ci

commit b64a2b62ef93c0ad22a58cd4394ed334bf429484
Author: Matt Lewis <matt@mplewis.com>
Date:   Sun Sep 10 22:00:30 2017 -0600

    circle: docker regviz/node-xcb

commit f3014d0315dec65c1f1d38fb2b8bc617c890f839
Author: Matt Lewis <matt@mplewis.com>
Date:   Sun Sep 10 21:56:03 2017 -0600

    test: integration

commit 1f945868eacee0d59ed356b45ac6164340e97a30
Author: Matt Lewis <matt@mplewis.com>
Date:   Sun Sep 10 21:55:25 2017 -0600

    eslint: ignore fixtures

commit da45f7cc87243cc89bb47977fd688b3f1823e33f
Author: Matt Lewis <matt@mplewis.com>
Date:   Sun Sep 10 21:52:41 2017 -0600

    eslint: js, jsx

commit 4c767d0b639fec3775fbfc1c79639218dde98a9a
Author: Matt Lewis <matt@mplewis.com>
Date:   Sun Sep 10 21:52:20 2017 -0600

    utils: crash identical

commit 74a22245cdf485b913674055007f55f13c9494d8
Author: Matt Lewis <matt@mplewis.com>
Date:   Sun Sep 10 21:49:49 2017 -0600

    refactor: testable specs
  • Loading branch information...
mplewis committed Sep 11, 2017
1 parent c457509 commit e11e93a20383c965ea71979910bcd8bde70de064
@@ -1,25 +1,100 @@
version: 2
jobs:
build:
checkout_code:
docker:
- image: circleci/node:7.10
- image: regviz/node-xcb
working_directory: ~/repo
steps:
- checkout
- run:
command: echo $CIRCLE_SHA1 > .circle-sha
- save_cache:
key: v1-repo-{{ checksum ".circle-sha" }}
paths:
- ~/repo
install_dependencies:
docker:
- image: regviz/node-xcb
working_directory: ~/repo
steps:
- run:
command: echo $CIRCLE_SHA1 > .circle-sha
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies- # fallback to using the latest cache if no exact match is found
- v1-repo-{{ checksum ".circle-sha" }}
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
- run: yarn install
- run: test/utils/install_fira_code
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- ~/.fonts
key: v1-dependencies-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
lint:
docker:
- image: regviz/node-xcb
working_directory: ~/repo
steps:
- run:
command: echo $CIRCLE_SHA1 > .circle-sha
- restore_cache:
keys:
- v1-repo-{{ checksum ".circle-sha" }}
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
- run: yarn lint
test_unit:
docker:
- image: regviz/node-xcb
working_directory: ~/repo
steps:
- run:
command: echo $CIRCLE_SHA1 > .circle-sha
- restore_cache:
keys:
- v1-repo-{{ checksum ".circle-sha" }}
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
- run: yarn test
test_integration:
docker:
- image: regviz/node-xcb
working_directory: ~/repo
steps:
- run:
command: echo $CIRCLE_SHA1 > .circle-sha
- restore_cache:
keys:
- v1-repo-{{ checksum ".circle-sha" }}
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
- run: yarn test-integration
- store_artifacts:
path: ~/repo/tmp
workflows:
version: 2
build_and_test:
jobs:
- checkout_code
- install_dependencies:
requires:
- checkout_code
- lint:
requires:
- install_dependencies
- test_unit:
requires:
- install_dependencies
- test_integration:
requires:
- install_dependencies
@@ -0,0 +1 @@
test/fixtures/**/*
@@ -6,9 +6,10 @@
"license": "MIT",
"scripts": {
"dev": "poi dev",
"test": "mocha test",
"test-server": "mocha test --watch",
"lint": "eslint ."
"test": "mocha test test/unit/**/*_test.js",
"test-server": "mocha test --watch test/unit/**/*_test.js",
"test-integration": "test/integration/integration_test.sh",
"lint": "eslint --ext js,jsx ."
},
"devDependencies": {
"chai": "^4.1.2",
@@ -1,6 +1,5 @@
const puppeteer = require('puppeteer')
const shell = require('shelljs')
const Jimp = require('jimp')
const cp = require('child_process')
const path = require('path')
const fs = require('fs')
@@ -16,7 +15,6 @@ function listSourceFiles () {
console.error('Usage: node src/camera.js YOUR_SOURCE_FILE')
process.exit(1)
}
shell.mkdir('-p', 'src/tmp')
return files
}
@@ -27,6 +25,11 @@ function startDevServer () {
proc.on('close', code => console.log(`child proc exited with code ${code}`))
}
async function startBrowser () {
const args = process.env.CI ? ['--no-sandbox', '--disable-setuid-sandbox'] : []
return puppeteer.launch({ args })
}
async function screenshot (browser, dst) {
const page = await browser.newPage()
@@ -48,9 +51,8 @@ async function screenshot (browser, dst) {
return page.evaluate(() => window.error)
}
async function trim (path) {
const img = await Jimp.read(path)
img.autocrop().write(path)
function trim (path) {
shell.exec(`convert ${path} -trim ${path}`)
}
function show (dst) {
@@ -60,7 +62,12 @@ function show (dst) {
async function main () {
const files = listSourceFiles()
startDevServer()
const browser = await puppeteer.launch()
shell.mkdir('-p', 'src/tmp')
shell.mkdir('-p', 'tmp')
const browser = await startBrowser()
const errors = []
for (const src of files) {
const dst = `tmp/${path.basename(src)}.png`
@@ -72,10 +79,12 @@ async function main () {
show(dst)
}
browser.close()
for (const error of errors) {
console.error(error)
}
process.exit() // kills any child processes (dev server)
}
main()
module.exports = { trim, main }
@@ -0,0 +1,3 @@
#!/usr/bin/env node
require('./src/camera').main()
@@ -0,0 +1,56 @@
extern "C" {
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include "utility/twi.h"
}
#include "Wire.h"
uint8_t TwoWire::transmitting = 0;
void (*TwoWire::user_onRequest)(void);
void (*TwoWire::user_onReceive)(int);
// must be called in:
// slave tx event callback
// or after beginTransmission(address)
size_t TwoWire::write(uint8_t data) {
if (transmitting) {
// in master transmitter mode
// don't bother if buffer is full
if (txBufferLength >= BUFFER_LENGTH) {
setWriteError();
return 0;
}
// put byte in tx buffer
txBuffer[txBufferIndex] = data;
++txBufferIndex;
// update amount in buffer
txBufferLength = txBufferIndex;
} else {
// in slave send mode
// reply to master
twi_transmit(&data, 1);
}
return 1;
}
// must be called in:
// slave rx event callback
// or after requestFrom(address, numBytes)
int TwoWire::available(void) { return rxBufferLength - rxBufferIndex; }
// must be called in:
// slave rx event callback
// or after requestFrom(address, numBytes)
int TwoWire::read(void) {
int value = -1;
// get each successive byte on each call
if (rxBufferIndex < rxBufferLength) {
value = rxBuffer[rxBufferIndex];
++rxBufferIndex;
}
return value;
}
@@ -0,0 +1,51 @@
class Game extends React.Component {
constructor() {
super();
this.state = {
history: [
{
squares: Array(9).fill(null)
}
],
stepNumber: 0,
xIsNext: true
};
}
render() {
const history = this.state.history;
const current = history[this.state.stepNumber];
const winner = calculateWinner(current.squares);
const moves = history.map((step, move) => {
const desc = move ? "Move #" + move : "Game start";
return (
<li key={move}>
<a href="#" onClick={() => this.jumpTo(move)}>{desc}</a>
</li>
);
});
let status;
if (winner) {
status = "Winner: " + winner;
} else {
status = "Next player: " + (this.state.xIsNext ? "X" : "O");
}
return (
<div className="game">
<div className="game-board">
<Board
squares={current.squares}
onClick={i => this.handleClick(i)}
/>
</div>
<div className="game-info">
<div>{status}</div>
<ol>{moves}</ol>
</div>
</div>
);
}
}
@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
from flask import (
Blueprint, render_template, session, g, flash, request, redirect, url_for,
current_app
)
from accounts.models import User
from accounts.forms import (
LoginForm, SignupForm, SignupConfirmForm, RecoverPasswordForm,
RecoverPasswordConfirmForm
)
from common.utils import get_signer
accounts_app = Blueprint('accounts_app', __name__)
@accounts_app.before_app_request
def load_user():
g.user = None
if 'user_id' in session:
try:
g.user = User.objects.get(pk=session['user_id'])
except:
pass
@accounts_app.route('/login/', methods=['GET', 'POST'])
def login():
next = request.values.get('next', '/')
form = LoginForm()
form.next.data = next
if form.validate_on_submit():
session['user_id'] = unicode(form.user.pk)
flash(u'Login successfully', 'success')
return redirect(next)
return render_template('accounts/login.html', form=form)
@accounts_app.route('/logout/')
def logout():
next = request.args.get('next', '/')
flash(u'Logout successfully', 'success')
session.pop('user_id', None)
return redirect(next)
@accounts_app.route('/signup/', methods=['GET', 'POST'])
def signup():
form = SignupForm()
if form.validate_on_submit():
form.save()
flash(
u'Check your email to confirm registration.',
'success'
)
return redirect(url_for('pages_app.index'))
return render_template('accounts/signup.html', form=form)
Oops, something went wrong.

0 comments on commit e11e93a

Please sign in to comment.