Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

feat: Switch to Notion.js #179

Merged
merged 1 commit into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 0 additions & 108 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,113 +11,6 @@ layout_poetry() {

set -e

# nvm based on https://github.com/steve-ross/direnv-helpers

__prompt_install_nvm(){
_log warn "Couldn't find nvm (node version manager)..."
read -p "Should I install it? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
_log info "Installing NVM"
curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
__source_nvm # make sure nvm is sourced
else
log_error "Install nvm first and make sure it is in your path and try again"
_log warn "To install NVM visit https://github.com/creationix/nvm#installation"
exit
fi
}

__source_nvm(){
local NVM_PATH=$(find_up .nvm/nvm.sh)
[ -s "$NVM_PATH" ] && \. "$NVM_PATH" # This loads nvm
}

__load_or_install_nvm(){
local NVM_PATH=$(find_up .nvm/nvm.sh)
if [ -z "$NVM_PATH" ]; then
# didn't find it
__prompt_install_nvm
else
# source NVM
__source_nvm
fi
}

__direnv_nvm_use_node(){
local NVM_PATH=$(find_up .nvm/nvm.sh)
# load version direnv way
local NVM_NODE_VERSION_DIR=versions/node
local NODE_VERSION=$(< .nvmrc)

# two possible locations for node versions in nvm...
local ALT_NVM_PATH="${NVM_PATH/\/nvm.sh}"
local TYPICAL_NVM_PATH="${NVM_PATH/nvm.sh/$NVM_NODE_VERSION_DIR}"

# set the nvm path to the typical place NVM stores node versions
local NVM_PATH="$TYPICAL_NVM_PATH"

#check alt path (seems old versions are here)
if [ -d "$ALT_NVM_PATH/v$NODE_VERSION" ]; then
NVM_PATH="$ALT_NVM_PATH"
fi

export NODE_VERSIONS=$NVM_PATH
export NODE_VERSION_PREFIX="v"

use node
}

__nvm_use_or_install_version(){
local version=$(< .nvmrc)
local nvmrc_node_version=$(nvm version "$version")
if [ "$nvmrc_node_version" = "N/A" ]; then
_log warn "Installing missing node version"
local install_output=$(nvm install "$version")
fi
nvm use
}

_log() {
local msg=$*
local color_normal
local color_success

color_normal=$(tput sgr0)
color_success=$(tput setaf 2)
color_warn=$(tput setaf 3)
color_info=$(tput setaf 5)

# default color
current_color="${color_normal}"

if ! [[ -z $2 ]]; then
local message_type=$1
# remove message type from the string (plus a space)
msg=${msg/$message_type /}
if [ "$message_type" = "warn" ]; then
current_color="${color_warn}"
fi
if [ "$message_type" = "info" ]; then
current_color="${color_info}"
fi
if [ "$message_type" = "success" ]; then
current_color="${color_success}"
fi
fi

if [[ -n $DIRENV_LOG_FORMAT ]]; then
# shellcheck disable=SC2059
printf "${current_color}${DIRENV_LOG_FORMAT}${color_normal}\n" "$msg" >&2
fi
}

requires_nvm(){
__load_or_install_nvm
__nvm_use_or_install_version
__direnv_nvm_use_node
}

# check if python version is set in current dir
if [ -f ".python-version" ] ; then
if [ ! -d ".venv" ] ; then
Expand All @@ -128,6 +21,5 @@ if [ -f ".python-version" ] ; then
source .venv/bin/activate
fi

requires_nvm
layout node
layout_poetry
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
- redis-server
- postgresql
python:
- "3.7"
- '3.7'
cache:
yarn: true
directories:
Expand All @@ -18,8 +18,7 @@ env:
- PIP_DISABLE_PIP_VERSION_CHECK=on
install:
- curl -sSL https://raw.githubusercontent.com/sdispater/poetry/0.12.10/get-poetry.py | python
- nvm install $(cat .nvmrc)
- npm install -g yarn@1.7.0
- curl -sSLf https://get.notionjs.com | bash
- PATH=$HOME/.poetry/bin:$PATH NODE_ENV= make
script:
- git --version
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ RUN set -ex \
# install nvm, node, and npm
# gpg keys listed at https://github.com/nodejs/node
COPY .nvmrc /usr/src/zeus/
ENV YARN_VERSION 1.7.0
ARG YARN_VERSION 1.13.0
ENV YARN_VERSION $YARN_VERSION
ARG NODE_VERSION 8.11.3
ENV NODE_VERSION $NODE_VERSION
RUN set -x \
&& export NODE_VERSION=$(cat /usr/src/zeus/.nvmrc) \
&& export GNUPGHOME="$(mktemp -d)" \
&& export NPM_CONFIG_CACHE="$(mktemp -d)" \
&& apt-get update && apt-get install -y --no-install-recommends dirmngr gnupg && rm -rf /var/lib/apt/lists/* \
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ reset-db: drop-db db
build-docker-image:
docker build \
-t zeus \
--build-arg NODE_VERSION=$(shell bin/get-node-version | tr -d '\n') \
--build-arg YARN_VERSION=$(shell bin/get-yarn-version | tr -d '\n') \
--build-arg BUILD_REVISION=$(shell git rev-parse HEAD | tr -d '\n') \
.

Expand Down
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ If you want to use Zeus with a build system that's not currently supported, see

### Supported Artifact Types

While you can upload any kind of Artifact to zeus (e.g. ``.html`` output), the platform has knowledge of certain types
While you can upload any kind of Artifact to zeus (e.g. `.html` output), the platform has knowledge of certain types
and will grant additional functionality if they're present.

The recommended way to support artifacts is to configure a post-build step (on both failure and success) to do something similar to the following:
Expand Down Expand Up @@ -70,14 +70,14 @@ Webpack stats can be generated with:
webpack --profile --json > webpack-stats.json
```

They should be submitted with the ``application/x-webpack-stats+json`` type.
They should be submitted with the `application/x-webpack-stats+json` type.

## Contributing

### Requirements

- Python 3.7
- Node
- Node (and [Notion.js](https://www.notionjs.com/))
- Postgres 9.4+

Note: If you're using pyenv for Python and macOS Mojave and having issues installing 3.7.1, take a look here:
Expand All @@ -97,7 +97,7 @@ make
poetry run zeus init
```

Note, before running any future Python commands (including ``zeus``), you'll
Note, before running any future Python commands (including `zeus`), you'll
need to activate the environment:

```shell
Expand All @@ -106,7 +106,7 @@ poetry shell

You can also setup [direnv](https://direnv.net/) to automatically activate the environment.

Once dependencies are resolved, bootstrap the database (see ``Makefile`` for details):
Once dependencies are resolved, bootstrap the database (see `Makefile` for details):

```shell
make db
Expand Down Expand Up @@ -169,8 +169,8 @@ zeus
### Data Model

- Most models contain a GUID (UUID) primary key.
- Some generalized models (such as ``ItemStat``) are keyed by GUID, and do not contain backrefs or constraints.
- Access is controlled at the repository level, and is generally enforced if you use the ``{ModelClass}.query`` utilities.
- Some generalized models (such as `ItemStat`) are keyed by GUID, and do not contain backrefs or constraints.
- Access is controlled at the repository level, and is generally enforced if you use the `{ModelClass}.query` utilities.

```
zeus
Expand Down Expand Up @@ -202,7 +202,6 @@ zeus
└── Identity
```


### Hooks

A subset of APIs are exposed using simple hook credentials. These credentials are coupled to a provider (e.g. `travis-ci`) and a single repository.
Expand Down Expand Up @@ -264,7 +263,6 @@ And here's how you upload an artifact:
zeus upload -b $MY_BUILD_ID -j $MY_JOB_ID -t 'text/xml+coverage' coverage.xml
```


### Updating data with `curl`

Here's an example of how you can publish job details without the native webhooks with `curl` from Travis:
Expand All @@ -290,4 +288,4 @@ curl $ZEUS_HOOK_BASE/builds/$TRAVIS_BUILD_NUMBER/jobs/$TRAVIS_JOB_NUMBER \
-d "{\"status\": \"$1\", \"result\": \"$2\", \"url\": \"https://travis-ci.org/${TRAVIS_REPO_SLUG}/jobs/${TRAVIS_JOB_ID}\", \"allow_failure\": ${TRAVIS_ALLOW_FAILURE}}"
```

From there you can submit artifacts using ``zeus-cli`` and its standard mechanisms.
From there you can submit artifacts using `zeus-cli` and its standard mechanisms.
8 changes: 8 additions & 0 deletions bin/get-node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python

import json

with open("package.json") as fp:
data = json.load(fp)

print(data["toolchain"]["node"])
8 changes: 8 additions & 0 deletions bin/get-yarn-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python

import json

with open("package.json") as fp:
data = json.load(fp)

print(data["toolchain"]["yarn"])
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,9 @@
"rules": {
"react/no-deprecated": "off"
}
},
"toolchain": {
"node": "8.11.3",
"yarn": "1.13.0"
}
}