Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy demo of Datasette on every commit that passes tests #313

Closed
simonw opened this issue Jun 17, 2018 · 6 comments
Closed

Deploy demo of Datasette on every commit that passes tests #313

simonw opened this issue Jun 17, 2018 · 6 comments
Labels

Comments

@simonw
Copy link
Owner

simonw commented Jun 17, 2018

We can use Travis CI and Zeit Now to ensure there is always a live demo of current master. We can ship archived demos for releases as well.

@simonw simonw added the medium label Jun 17, 2018
simonw added a commit that referenced this issue Jun 17, 2018
The fixtures database created by our unit tests makes for a good "live" demo
of Datasette in action.

I've improved the metadata it ships with to better support this use-case.

I've also improved the mechanism for writing out fixtures: you can do this:

	python tests/fixtures.py fixtures.db

To get just the fixtures database written out... or you can do this:

	python tests/fixtures.py fixtures.db fixtures.json

To get metadata which you can then serve like so:

	datasette fixtures.db -m fixtures.json

Refs #313
@simonw
Copy link
Owner Author

simonw commented Jun 17, 2018

This will require some relatively sophisticated Travis build steps. Useful docs: https://docs.travis-ci.com/user/build-stages/ - useful example: https://docs.travis-ci.com/user/build-stages/deploy-heroku/

simonw added a commit that referenced this issue Jun 17, 2018
This is a relatively obscure new command-line argument that helps solve the
problem of showing accurate version information in deployed instances of
Datasette even if they were deployed directly from source code.

You can pass --version-note to datasette publish and package and it will then
in turn be passed to datasette when it starts:

    datasette --version-note=hello fixtures.db

Now if you visit /-/versions.json you will see this:

    {
        "datasette": {
            "note": "hello",
            "version": "0+unknown"
        },
        "python": {
            "full": "3.6.5 (default, Jun  6 2018, 19:19:24) \n[GCC 6.3.0 20170516]",
            "version": "3.6.5"
        },
        ...
    }

I plan to use this in some Travis CI configuration, refs #313
simonw added a commit that referenced this issue Jun 17, 2018
If the tests pass in Travis CI, deploy an instance containing Datasette's test
fixtures to https://latest.datasette.io/

Also set up an alias of truncated-commit-hash.datasette.io
@simonw
Copy link
Owner Author

simonw commented Jun 17, 2018

This very nearly works...

But... https://f0c1722.datasette.io/-/versions isn't showing the correct note:

{
    "datasette": {
        "version": "0.22.1"
    }
    ...

There should be a "note" field there with the full commit hash.

@simonw
Copy link
Owner Author

simonw commented Jun 17, 2018

It looks like all of my test deploys ended up going to the same Zeit deployment ID: https://zeit.co/simonw/datasette-latest/rbmtcedvlj

This is strange... the Dockerfile should be different for each one (due to the differing version-note).

db1e6bc#diff-34418c57343344c73271e13b01b7fcd9R255

@simonw
Copy link
Owner Author

simonw commented Jun 17, 2018

The command "datasette publish now fixtures.db -m fixtures.json --token=$NOW_TOKEN --branch=$TRAVIS_COMMIT --version-note=$TRAVIS_COMMIT" exited with 0.

Partial log of the datasette publish now output:

> Step 5/7 : RUN datasette inspect fixtures.db --inspect-file inspect-data.json
>  ---> Running in d373f330e53e
>  ---> 09bab386aaa3
> Removing intermediate container d373f330e53e
> Step 6/7 : EXPOSE 8001
>  ---> Running in e0fe37b3061c
>  ---> 47798440e214
> Removing intermediate container e0fe37b3061c
> Step 7/7 : CMD datasette serve --host 0.0.0.0 fixtures.db --cors --port 8001 --inspect-file inspect-data.json --metadata metadata.json --version-note f0c17229b7a7914d3da02e087dfd0e25d8321448

So it looks like --version-note is being correctly set there.

simonw added a commit that referenced this issue Jun 17, 2018
@simonw
Copy link
Owner Author

simonw commented Jun 17, 2018

Aha!

> Error! Couldn't find a deployment to alias. Please provide one as an argument.
The command "now alias --token=$NOW_TOKEN" exited with 1.

That explains it. I need to set the same alias in my call to datasette publish.

@simonw
Copy link
Owner Author

simonw commented Jun 17, 2018

That fixed it! https://958b75c.datasette.io/-/versions

{
  "python": {
    "version": "3.6.5",
    "full": "3.6.5 (default, Jun  6 2018, 19:19:24) \n[GCC 6.3.0 20170516]"
  },
  "datasette": {
    "version": "0+unknown",
    "note": "958b75c69841ef5913da86e0eb2df634a9b95fda"
  },
  "sqlite": {
    "version": "3.16.2",
    "fts_versions": [
      "FTS5",
      "FTS4",
      "FTS3"
    ],
    "extensions": {
      "json1": null
    }
  }
}

@simonw simonw closed this as completed Jun 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant