balena-io-modules / scrutinizer

Extract a git repository's metadata relying on open source conventions
Apache License 2.0
8 stars 0 forks source link

Version 2 #107

Open dimitrisnl opened 5 years ago

dimitrisnl commented 5 years ago

Preparing for version 2 of Scrutinizer

Main points

Improvements

Testing

We're currently using e2e tests against a dummy repository. This approach works but doesn't cover all the cases. It would be better to test against a schema.

For example lastCommitDate will break if we update the test repo, but not if we were to test against a Date type.

dimitrisnl commented 5 years ago

Using GraphQL in node -> https://github.com/octokit/graphql.js/

dimitrisnl commented 5 years ago

A great deal of our plugins (without the file parsing) can be expressed by the following snippet:

{
  repository(owner: "balena-io-modules", name: "scrutinizer") {
    licenseInfo {
      id
      name
    }
    pushedAt
    description
    isPrivate
    name
    releases(last: 1) {
      edges {
        node {
          tagName
          releaseAssets {
            edges {
              node {
                name
                downloadUrl
              }
            }
          }
        }
      }
    }
    issues(last: 10) {
      edges {
        node {
          title
          url
        }
      }
    }
    isFork
    forkCount
    stargazers {
      totalCount
    }
    homepageUrl
    isArchived
    isDisabled
    owner {
      avatarUrl
      login
      url
      __typename
    }
    codeOfConduct {
      name
      body
      url
    }
  }
}
dimitrisnl commented 5 years ago

Get folder contents

query {
  repository(owner: "balena-io", name: "landr") {
    folder: object(expression: "master:docs") {
      ... on Tree {
        entries {
          oid
          type
          object {
            ... on Blob {
              text
            }
          }
          name
        }
      }
    }
  }
}

{
  "data": {
    "repository": {
      "folder": {
        "entries": [
          {
            "oid": "ddcc9425819ab7b82a846a947cf755b4e65ce46f",
            "type": "blob",
            "object": {
              "text": "Getting Started\n===============\n\nWelcome to Landr! Setting up Landr in your project is extremely easy. First,\nmake sure you install the `landr` CLI from npmjs.org if you haven't already by\nrunning:\n\n```sh\nnpm install --global landr\n```\n\nLets also install the excellent [`serve`](https://www.npmjs.com/package/serve)\nstatic HTTP server as a way to preview our site:\n\n```sh\nnpm install --global serve\n```\n\nNow that everything is in place, head over to your project's repository and\nrun:\n\n```sh\nlandr build\n```\n\nGive it a bunch of seconds, and you should get various HTML, CSS, and\nJavaScript files in the `dist` directory. You can preview your site by running:\n\n```sh\nserve dist\n```\n\nAnd pointing your browser to `localhost:5000`.\n\nAt this point, you have working, but not perfect, website. Landr generates\nwebsites based on the content of the repository and relies on various OSS\nconventions for doing its job. Making sure your repository is well structured\nand follows the community conventions will do wonders for you website, and for\nyour repository overall!\n\nOnce you are happy with your site, run the following command to deploy to Netlify:\n\n```\nNETLIFY_AUTH_TOKEN=<token> landr deploy\n```\n\nPassing your Netlify authentication token as an environment variable.\n"
            },
            "name": "01-getting-started.md"
          },
          {
            "oid": "ccff7e38964d717af7fca5b488f5813a49dea8d1",
            "type": "blob",
            "object": {
              "text": "CLI\n===\n\nThe Landr CLI is able to generate websites and deploy them to Netlify and it\nfeatures the following small set of commands:\n\n`landr [meta.json]`\n-------------------\n\nThis is an alias for `landr deploy [meta.json]`. Please refer to that command's\nhelp section.\n\n`landr build [meta.json]`\n-------------------------\n\nBuild the site in the current working directory and store the generated files\nin `dist`. Any existing `dist` directory will be removed.\n\n| Arguments | Description | Optional? | Default |\n|-----------|-------------|-----------|---------|\n| `[meta.json]` | Path to `meta.json` | Y | `$PWD/meta.json` |\n\nThis command supports the following environment variables:\n\n| Name | Description | Optional? |\n|-----------|-------------|-----------|\n| `LANDR_MIXPANEL_TOKEN` | Your Mixpanel token | Y |\n| `LANDR_MIXPANEL_PROXY` | Your Mixpanel proxy URL | N |\n\n### Examples:\n\n```sh\n$ cd path/to/repo\n$ landr build\n\n  / /  __ _ _ __   __| |_ __\n / /  / _` | '_ \\ / _` | '__|\n/ /__| (_| | | | | (_| | |\n\\____/\\__,_|_| |_|\\__,_|_|\n\nGenerate great websites for your projects with zero configuration\n\n[landr] Trying to load repository contract from /Users/jviotti/Projects/resin/landr/meta.json\n[landr] Running from /Users/jviotti/Projects/resin/landr/meta.json into /Users/jviotti/Projects/resin/landr/dist\n...\n[landr] Site generated successfully\n```\n\n`landr deploy [meta.json]`\n--------------------------\n\nRun `landr build [meta.json]` on the current working directory and deploy the\nresulting files to Netlify. The content of `dist` are removed after deployment.\n\n| Arguments | Description | Optional? | Default |\n|-----------|-------------|-----------|---------|\n| `[meta.json]` | Path to `meta.json` | Y | `$PWD/meta.json` |\n\nThis command supports the following environment variables:\n\n| Name | Description | Optional? |\n|-----------|-------------|-----------|\n| `NETLIFY_AUTH_TOKEN` | You Netlify token | N |\n| `LANDR_MIXPANEL_TOKEN` | Your Mixpanel token | Y |\n| `LANDR_MIXPANEL_PROXY` | Your Mixpanel proxy URL | N |\n\n### Examples:\n\n```sh\n$ cd path/to/repo\n$ landr deploy\n\n  / /  __ _ _ __   __| |_ __\n / /  / _` | '_ \\ / _` | '__|\n/ /__| (_| | | | | (_| | |\n\\____/\\__,_|_| |_|\\__,_|_|\n\nGenerate great websites for your projects with zero configuration\n\n[landr] Trying to load repository contract from /Users/jviotti/Projects/resin/landr/meta.json\n[landr] Running from /Users/jviotti/Projects/resin/landr/meta.json into /Users/jviotti/Projects/resin/landr/dist\n...\n[landr] Site generated successfully\n[landr] Deploying site to https://landr.netlify.com\n[landr] Deployed with Landr v4.2.1\n[landr] Visit https://landr.netlify.com\n[landr] Head over to https://app.netlify.com/sites/landr/settings/domain/setup to setup a different domain\n```\n"
            },
            "name": "02-cli.md"
          },
          {
            "oid": "bb2d2ec16355837314c79d7e2e6ba128e46c23aa",
            "type": "blob",
            "object": {
              "text": "Conventions\n===========\n\nLandr prides itself with being a zero configuration tool, and relying on your\nrepository and related conventions to perform its job.\n\nThis document presents a list of conventions we recommend in order to make the\nbest out of Landr. Apart from this list, The [Landr GitHub\nRepository](https://github.com/balena-io/landr) aims to be an example of what\nyou can do with Landr, so check out how we do things there if unsure!\n\n`README.md`\n-----------\n\n### Image Banner\n\nLandr will parse the `README` file and if it finds an image at the top, it will\nuse it as the project banner/logo.\n\n### Description\n\nThe first paragraph in the `README` before any section is considered to be the\nrepository description.\n\n### Features\n\nA list of paragraphs after the repository description, where each entry starts\nwith a set of words, a colon, and a paragraph is considered to be the project\nfeatures highlights.\n\n### Motivation\n\nA `README` section called `Motivation` is considered to be a longer description\nof why the project exists.\n\n`ARCHITECTURE.md`\n-----------------\n\nAn in-depth description of how the project works under the hood, targetted at\npotential contributors.\n\n`CODE_OF_CONDUCT.md`\n--------------------\n\nThe project's code of conduct for contributors.\n\n`SECURITY.md`\n-------------\n\nInstructions on how to report a security vulnerability to the project.\n\n`FAQ.md`\n--------\n\nA set of frequently asked questions and their corresponding answers. Each\nsection of the document is considered to be a different FAQ entry.\n\n`CODEOWNERS`\n------------\n\nLandr will parse `CODEOWNERS` to determine who are the maintainers of the\nrepository.\n\n`CONTRIBUTING.md`\n-----------------\n\nA getting started guide for starting to contribute to the project,\ncomplementary to the `ARCHITECTURE.md` document.\n\n`LICENSE`\n---------\n\nThe license of the project.\n\n`CNAME`\n-------\n\nThe canonical domain of the project.\n\n`docs/**/*.md`\n--------------\n\nA set of documentation files where sub-directories represent categories. The\nordering is determined alphabetically using the file names and the page title\nis determined from the first title from the contents of the files.\n\n`blog/YYYY-MM-DD-*.md`\n----------------------\n\nA set of blog posts. The published date is obtained from the file name, and the\nauthor information is obtained through git.\n"
            },
            "name": "03-conventions.md"
          },
          {
            "oid": "343d7d4e647d51955b327e2359c18676fc307713",
            "type": "blob",
            "object": {
              "text": "Running in CI\n=============\n\nThe Landr project makes use of [Netlify](https://www.netlify.com) to deploy the\ngenerated website. For this reason, you will need to generate a Netlify\n*Personal Access Token* and set it as an environment variable called\n`NETLIFY_AUTH_TOKEN`.\n\nGenerating a Netlify Access Token\n---------------------------------\n\nLogin to your Netlify account and head over to the [`Application` tab in the\n`User Settings` page](https://app.netlify.com/user/applications). Once there,\nclick on the `New Access Token` button:\n\n![](./assets/netlify-new-access-token.png)\n\nOnce there, put a descriptive name for your personal access token, such as\n\"Landr\", and click `Generate token`:\n\n![](./assets/netlify-create-token.png)\n\nCopy the token, and set it as the value for the `NETLIFY_AUTH_TOKEN` using the\nEnvironment Variables section of your preferred CI service:\n\n![](./assets/netlify-copy-access-token.png)\n\nClick `Done!` and you are all set! Landr will automatically use the token you\nset when it comes to deploying your static assets!\n"
            },
            "name": "04-running-landr-in-ci.md"
          },
          {
            "oid": "6778099faba33ae1cc7af629392755b2d3119a3c",
            "type": "tree",
            "object": {},
            "name": "assets"
          }
        ]
      }
    }
  }
}